Remove spaces after control statements keywords
Spaces are useful to separate independent constructs, but can cause
confusion when added between dependent ones. For example "a*b [i]"
is hard for humans to read correctly at a glance. "a*b[i]" is better,
and "a * b[i]" is the easiest to understand immediately.
Control statements are no different. "if (a)if (b)x;" is hard to parse.
"if (a) if (b) x;" is better, but "if(a) if(b) x;" leaves no confusion
of what belongs where.
This recommendation also follows the 'zero one infinity' rule of thumb:
https://en.wikipedia.org/wiki/Zero_one_infinity_rule
Whether we write "a + b" or "a + b", they are equally readable, and
the additional spaces may help with alignment of surrounding
expressions. "for (int i : c)" on the other hand makes the keyword
unintentionally even more dissociated from its header than
"for (int i : c)" already does.
The argument that the space helps set it apart from function calls seems
moot when practically every editor supports keyword highlighting,
function names are typically longer than 2-3 characters, and function
calls are not followed by curly brackets (which while optional for
singular statements, are still recommended for reasons other than this
one).
Bug: b/144825072
Change-Id: I3432fadae8e5604123f5c537097323504fecbc8c
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39588
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Reactor/Coroutine.hpp b/src/Reactor/Coroutine.hpp
index 211d68b..8bd601e 100644
--- a/src/Reactor/Coroutine.hpp
+++ b/src/Reactor/Coroutine.hpp
@@ -89,7 +89,7 @@
// Yield(Int(1));
// Int current = 1;
// Int next = 1;
-// While (true) {
+// While(true) {
// Yield(next);
// auto tmp = current + next;
// current = next;
@@ -101,7 +101,7 @@
// auto s = coroutine();
//
// // Grab the first 20 yielded values and print them.
-// for (int i = 0; i < 20; i++)
+// for(int i = 0; i < 20; i++)
// {
// int val = 0;
// s->await(val);
diff --git a/src/Reactor/DebugAndroid.cpp b/src/Reactor/DebugAndroid.cpp
index c511fc3..2a6569c 100644
--- a/src/Reactor/DebugAndroid.cpp
+++ b/src/Reactor/DebugAndroid.cpp
@@ -31,7 +31,7 @@
{
ALOGE("Waiting for debugger: gdbserver :${PORT} --attach %u. Look for thread %u", getpid(), gettid());
volatile int waiting = 1;
- while (waiting) {
+ while(waiting) {
sleep(1);
}
}
diff --git a/src/Reactor/DebugAndroid.hpp b/src/Reactor/DebugAndroid.hpp
index eced194..bb7451e 100644
--- a/src/Reactor/DebugAndroid.hpp
+++ b/src/Reactor/DebugAndroid.hpp
@@ -49,7 +49,7 @@
void AndroidEnterDebugger();
#define ASSERT(E) do { \
- if (!(E)) { \
+ if(!(E)) { \
ALOGE("badness: assertion_failed %s in %s at %s:%d", #E, \
__FUNCTION__, __FILE__, __LINE__); \
AndroidEnterDebugger(); \
diff --git a/src/Reactor/EmulatedReactor.cpp b/src/Reactor/EmulatedReactor.cpp
index efdb5a3..3740224 100644
--- a/src/Reactor/EmulatedReactor.cpp
+++ b/src/Reactor/EmulatedReactor.cpp
@@ -49,7 +49,7 @@
Pointer<Byte> baseBytePtr = base;
out = T(0);
- for (int i = 0; i < 4; i++)
+ for(int i = 0; i < 4; i++)
{
If(Extract(mask, i) != 0)
{
@@ -72,7 +72,7 @@
Pointer<Byte> baseBytePtr = base;
- for (int i = 0; i < 4; i++)
+ for(int i = 0; i < 4; i++)
{
If(Extract(mask, i) != 0)
{
diff --git a/src/Reactor/ExecutableMemory.cpp b/src/Reactor/ExecutableMemory.cpp
index 8d5ec55..b6cee9c 100644
--- a/src/Reactor/ExecutableMemory.cpp
+++ b/src/Reactor/ExecutableMemory.cpp
@@ -38,7 +38,7 @@
#undef allocate
#undef deallocate
-#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined (_M_X64)) && !defined(__x86__)
+#if(defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined (_M_X64)) && !defined(__x86__)
#define __x86__
#endif
@@ -91,7 +91,7 @@
#if defined(_WIN32)
DWORD permissionsToProtectMode(int permissions)
{
- switch (permissions) {
+ switch(permissions) {
case PERMISSION_READ:
return PAGE_READONLY;
case PERMISSION_EXECUTE:
@@ -111,15 +111,15 @@
int permissionsToMmapProt(int permissions)
{
int result = 0;
- if (permissions & PERMISSION_READ)
+ if(permissions & PERMISSION_READ)
{
result |= PROT_READ;
}
- if (permissions & PERMISSION_WRITE)
+ if(permissions & PERMISSION_WRITE)
{
result |= PROT_WRITE;
}
- if (permissions & PERMISSION_EXECUTE)
+ if(permissions & PERMISSION_EXECUTE)
{
result |= PROT_EXEC;
}
@@ -177,15 +177,15 @@
#if defined(__Fuchsia__)
zx_vm_option_t permissionsToZxVmOptions(int permissions) {
zx_vm_option_t result = 0;
- if (permissions & PERMISSION_READ)
+ if(permissions & PERMISSION_READ)
{
result |= ZX_VM_PERM_READ;
}
- if (permissions & PERMISSION_WRITE)
+ if(permissions & PERMISSION_WRITE)
{
result |= ZX_VM_PERM_WRITE;
}
- if (permissions & PERMISSION_EXECUTE)
+ if(permissions & PERMISSION_EXECUTE)
{
result |= ZX_VM_PERM_EXECUTE;
}
@@ -277,10 +277,10 @@
}
#elif defined(__Fuchsia__)
zx_handle_t vmo;
- if (zx_vmo_create(length, 0, &vmo) != ZX_OK) {
+ if(zx_vmo_create(length, 0, &vmo) != ZX_OK) {
return nullptr;
}
- if (need_exec &&
+ if(need_exec &&
zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo) != ZX_OK)
{
return nullptr;
@@ -290,7 +290,7 @@
zx_vmar_root_self(), permissionsToZxVmOptions(permissions), 0, vmo,
0, length, &reservation);
zx_handle_close(vmo);
- if (status != ZX_OK) {
+ if(status != ZX_OK) {
return nullptr;
}
@@ -327,7 +327,7 @@
void protectMemoryPages(void *memory, size_t bytes, int permissions)
{
- if (bytes == 0)
+ if(bytes == 0)
return;
bytes = roundUp(bytes, memoryPageSize());
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index c76ff55..4b6bb77 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -153,7 +153,7 @@
{
std::unique_lock<std::mutex> lock(mutex);
auto it = map.find(key);
- if (it != map.end())
+ if(it != map.end())
{
return it->second;
}
@@ -244,9 +244,9 @@
#endif
std::vector<std::string> mattrs;
- for (auto &feature : features)
+ for(auto &feature : features)
{
- if (feature.second) { mattrs.push_back(feature.first()); }
+ if(feature.second) { mattrs.push_back(feature.first()); }
}
const char* march = nullptr;
@@ -289,7 +289,7 @@
llvm::CodeGenOpt::Level JITGlobals::toLLVM(rr::Optimization::Level level)
{
- switch (level)
+ switch(level)
{
case rr::Optimization::Level::None: return ::llvm::CodeGenOpt::None;
case rr::Optimization::Level::Less: return ::llvm::CodeGenOpt::Less;
@@ -333,7 +333,7 @@
purpose == llvm::SectionMemoryManager::AllocationPurpose::Code;
void* addr = rr::allocateMemoryPages(
numBytes, flagsToPermissions(flags), need_exec);
- if (!addr)
+ if(!addr)
return llvm::sys::MemoryBlock();
return llvm::sys::MemoryBlock(addr, numBytes);
}
@@ -362,15 +362,15 @@
private:
int flagsToPermissions(unsigned flags) {
int result = 0;
- if (flags & llvm::sys::Memory::MF_READ)
+ if(flags & llvm::sys::Memory::MF_READ)
{
result |= rr::PERMISSION_READ;
}
- if (flags & llvm::sys::Memory::MF_WRITE)
+ if(flags & llvm::sys::Memory::MF_WRITE)
{
result |= rr::PERMISSION_WRITE;
}
- if (flags & llvm::sys::Memory::MF_EXEC)
+ if(flags & llvm::sys::Memory::MF_EXEC)
{
result |= rr::PERMISSION_EXECUTE;
}
@@ -402,7 +402,7 @@
session,
[&](const std::string &name) {
void *func = rr::resolveExternalSymbol(name.c_str());
- if (func != nullptr)
+ if(func != nullptr)
{
return llvm::JITSymbol(
reinterpret_cast<uintptr_t>(func), llvm::JITSymbolFlags::Absolute);
@@ -410,7 +410,7 @@
return objLayer.findSymbol(name, true);
},
[](llvm::Error err) {
- if (err)
+ if(err)
{
// TODO: Log the symbol resolution errors.
return;
@@ -438,7 +438,7 @@
addresses(count)
{
std::vector<std::string> mangledNames(count);
- for (size_t i = 0; i < count; i++)
+ for(size_t i = 0; i < count; i++)
{
auto func = funcs[i];
static size_t numEmittedFunctions = 0;
@@ -461,7 +461,7 @@
llvm::cantFail(compileLayer.addModule(moduleKey, std::move(module)));
// Resolve the function addresses.
- for (size_t i = 0; i < count; i++)
+ for(size_t i = 0; i < count; i++)
{
auto symbol = compileLayer.findSymbolIn(moduleKey, mangledNames[i], false);
if(auto address = symbol.getAddress())
@@ -502,7 +502,7 @@
{
#ifdef ENABLE_RR_DEBUG_INFO
- if (debugInfo != nullptr)
+ if(debugInfo != nullptr)
{
return; // Don't optimize if we're generating debug info.
}
@@ -702,7 +702,7 @@
unsigned numBits = ty->getScalarSizeInBits();
llvm::Value *max, *min, *extX, *extY;
- if (isSigned)
+ if(isSigned)
{
max = llvm::ConstantInt::get(extTy, (1LL << (numBits - 1)) - 1, true);
min = llvm::ConstantInt::get(extTy, (-1LL << (numBits - 1)), true);
@@ -739,7 +739,7 @@
{
llvm::Type *ty = x->getType();
llvm::Constant *one;
- if (llvm::VectorType *vectorTy = llvm::dyn_cast<llvm::VectorType>(ty))
+ if(llvm::VectorType *vectorTy = llvm::dyn_cast<llvm::VectorType>(ty))
{
one = llvm::ConstantVector::getSplat(
vectorTy->getNumElements(),
@@ -797,7 +797,7 @@
llvm::SmallVector<uint32_t, 16> evenIdx;
llvm::SmallVector<uint32_t, 16> oddIdx;
- for (uint64_t i = 0, n = ty->getNumElements(); i < n; i += 2)
+ for(uint64_t i = 0, n = ty->getNumElements(); i < n; i += 2)
{
evenIdx.push_back(i);
oddIdx.push_back(i + 1);
@@ -819,7 +819,7 @@
uint64_t truncNumBits = dstElemTy->getIntegerBitWidth();
ASSERT_MSG(truncNumBits < 64, "shift 64 must be handled separately. truncNumBits: %d", int(truncNumBits));
llvm::Constant *max, *min;
- if (isSigned)
+ if(isSigned)
{
max = llvm::ConstantInt::get(srcTy, (1LL << (truncNumBits - 1)) - 1, true);
min = llvm::ConstantInt::get(srcTy, (-1LL << (truncNumBits - 1)), true);
@@ -852,7 +852,7 @@
llvm::Value *ret = jit->builder->CreateZExt(
jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
- for (uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
+ for(uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
{
llvm::Value *elem = jit->builder->CreateZExt(
jit->builder->CreateExtractElement(cmp, i), retTy);
@@ -869,7 +869,7 @@
llvm::Value *ret = jit->builder->CreateZExt(
jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
- for (uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
+ for(uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
{
llvm::Value *elem = jit->builder->CreateZExt(
jit->builder->CreateExtractElement(cmp, i), retTy);
@@ -879,7 +879,7 @@
}
#endif // !defined(__i386__) && !defined(__x86_64__)
-#if (LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
+#if(LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
llvm::Value *lowerPUADDSAT(llvm::Value *x, llvm::Value *y)
{
#if LLVM_VERSION_MAJOR >= 8
@@ -923,7 +923,7 @@
llvm::VectorType *extTy = llvm::VectorType::getExtendedElementVectorType(ty);
llvm::Value *extX, *extY;
- if (sext)
+ if(sext)
{
extX = jit->builder->CreateSExt(x, extTy);
extY = jit->builder->CreateSExt(y, extTy);
@@ -1051,12 +1051,12 @@
static uint32_t sync_fetch_and_op(uint32_t volatile *ptr, uint32_t val, F f)
{
// Build an arbitrary op out of looped CAS
- for (;;)
+ for(;;)
{
uint32_t expected = *ptr;
uint32_t desired = f(expected, val);
- if (expected == __sync_val_compare_and_swap_4(ptr, expected, desired))
+ if(expected == __sync_val_compare_and_swap_4(ptr, expected, desired))
return expected;
}
}
@@ -1068,7 +1068,7 @@
{
static void load(size_t size, void *ptr, void *ret, llvm::AtomicOrdering ordering)
{
- switch (size)
+ switch(size)
{
case 1: atomicLoad<uint8_t>(ptr, ret, ordering); break;
case 2: atomicLoad<uint16_t>(ptr, ret, ordering); break;
@@ -1080,7 +1080,7 @@
}
static void store(size_t size, void *ptr, void *ret, llvm::AtomicOrdering ordering)
{
- switch (size)
+ switch(size)
{
case 1: atomicStore<uint8_t>(ptr, ret, ordering); break;
case 2: atomicStore<uint16_t>(ptr, ret, ordering); break;
@@ -1211,7 +1211,7 @@
// Trim off any underscores from the start of the symbol. LLVM likes
// to append these on macOS.
const char* trimmed = name;
- while (trimmed[0] == '_') { trimmed++; }
+ while(trimmed[0] == '_') { trimmed++; }
auto it = resolver.functions.find(trimmed);
// Missing functions will likely make the module fail in exciting non-obvious ways.
@@ -1396,7 +1396,7 @@
}
#ifdef ENABLE_RR_DEBUG_INFO
- if (jit->debugInfo != nullptr)
+ if(jit->debugInfo != nullptr)
{
jit->debugInfo->Finalize();
}
@@ -1696,11 +1696,11 @@
auto elTy = T(type);
ASSERT(V(ptr)->getType()->getContainedType(0) == elTy);
- if (!atomic)
+ if(!atomic)
{
return V(jit->builder->CreateAlignedLoad(V(ptr), alignment, isVolatile));
}
- else if (elTy->isIntegerTy() || elTy->isPointerTy())
+ else if(elTy->isIntegerTy() || elTy->isPointerTy())
{
// Integers and pointers can be atomically loaded by setting
// the ordering constraint on the load instruction.
@@ -1708,7 +1708,7 @@
load->setAtomic(atomicOrdering(atomic, memoryOrder));
return V(load);
}
- else if (elTy->isFloatTy() || elTy->isDoubleTy())
+ else if(elTy->isFloatTy() || elTy->isDoubleTy())
{
// LLVM claims to support atomic loads of float types as
// above, but certain backends cannot deal with this.
@@ -1780,18 +1780,18 @@
auto elTy = T(type);
ASSERT(V(ptr)->getType()->getContainedType(0) == elTy);
- if (!atomic)
+ if(!atomic)
{
jit->builder->CreateAlignedStore(V(value), V(ptr), alignment, isVolatile);
}
- else if (elTy->isIntegerTy() || elTy->isPointerTy())
+ else if(elTy->isIntegerTy() || elTy->isPointerTy())
{
// Integers and pointers can be atomically stored by setting
// the ordering constraint on the store instruction.
auto store = jit->builder->CreateAlignedStore(V(value), V(ptr), alignment, isVolatile);
store->setAtomic(atomicOrdering(atomic, memoryOrder));
}
- else if (elTy->isFloatTy() || elTy->isDoubleTy())
+ else if(elTy->isFloatTy() || elTy->isDoubleTy())
{
// LLVM claims to support atomic stores of float types as
// above, but certain backends cannot deal with this.
@@ -3888,7 +3888,7 @@
auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), ::llvm::ArrayRef<llvm::Type*>(T(Float::getType())), false);
auto func = jit->module->getOrInsertFunction(name, funcTy);
llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
- for (uint64_t i = 0; i < 4; i++)
+ for(uint64_t i = 0; i < 4; i++)
{
auto el = jit->builder->CreateCall(func, V(Nucleus::createExtractElement(v.value, Float::getType(), i)));
out = V(Nucleus::createInsertElement(V(out), V(el), i));
@@ -3949,7 +3949,7 @@
auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), paramTys, false);
auto func = jit->module->getOrInsertFunction("atan2f", funcTy);
llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
- for (uint64_t i = 0; i < 4; i++)
+ for(uint64_t i = 0; i < 4; i++)
{
auto el = jit->builder->CreateCall2(func, ARGS(
V(Nucleus::createExtractElement(x.value, Float::getType(), i)),
@@ -4057,14 +4057,14 @@
Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> argTys)
{
::llvm::SmallVector<::llvm::Type*, 8> paramTys;
- for (auto ty : argTys) { paramTys.push_back(T(ty)); }
+ for(auto ty : argTys) { paramTys.push_back(T(ty)); }
auto funcTy = ::llvm::FunctionType::get(T(retTy), paramTys, false);
auto funcPtrTy = funcTy->getPointerTo();
auto funcPtr = jit->builder->CreatePointerCast(V(fptr.value), funcPtrTy);
::llvm::SmallVector<::llvm::Value*, 8> arguments;
- for (auto arg : args) { arguments.push_back(V(arg)); }
+ for(auto arg : args) { arguments.push_back(V(arg)); }
return V(jit->builder->CreateCall(funcPtr, arguments));
}
@@ -4558,7 +4558,7 @@
{
std::vector<Value*> elements;
elements.reserve(n);
- for (int i = 0; i < n; i++)
+ for(int i = 0; i < n; i++)
{
auto el = V(jit->builder->CreateExtractElement(V(vec), i));
elements.push_back(el);
@@ -4573,9 +4573,9 @@
auto intTy = ::llvm::Type::getIntNTy(jit->context, sizeof(int) * 8); // Natural integer width.
std::vector<Value*> elements;
elements.reserve(vals.size());
- for (auto v : vals)
+ for(auto v : vals)
{
- if (isSigned)
+ if(isSigned)
{
elements.push_back(V(jit->builder->CreateSExt(V(v), intTy)));
}
@@ -4593,7 +4593,7 @@
auto doubleTy = ::llvm::Type::getDoubleTy(jit->context);
std::vector<Value*> elements;
elements.reserve(vals.size());
- for (auto v : vals)
+ for(auto v : vals)
{
elements.push_back(V(jit->builder->CreateFPExt(V(v), doubleTy)));
}
@@ -4628,14 +4628,14 @@
// Build the printf format message string.
std::string str;
- if (file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; }
- if (function != nullptr) { str += "%s "; }
+ if(file != nullptr) { str += (line > 0) ? "%s:%d " : "%s "; }
+ if(function != nullptr) { str += "%s "; }
str += fmt;
// Perform subsitution on all '{n}' bracketed indices in the format
// message.
int i = 0;
- for (const PrintValue& arg : args)
+ for(const PrintValue& arg : args)
{
str = replace(str, "{" + std::to_string(i++) + "}", arg.format);
}
@@ -4646,23 +4646,23 @@
vals.push_back(jit->builder->CreateGlobalStringPtr(str));
// Add optional file, line and function info if provided.
- if (file != nullptr)
+ if(file != nullptr)
{
vals.push_back(jit->builder->CreateGlobalStringPtr(file));
- if (line > 0)
+ if(line > 0)
{
vals.push_back(::llvm::ConstantInt::get(intTy, line));
}
}
- if (function != nullptr)
+ if(function != nullptr)
{
vals.push_back(jit->builder->CreateGlobalStringPtr(function));
}
// Add all format arguments.
- for (const PrintValue& arg : args)
+ for(const PrintValue& arg : args)
{
- for (auto val : arg.values)
+ for(auto val : arg.values)
{
vals.push_back(V(val));
}
@@ -4683,7 +4683,7 @@
void EmitDebugLocation()
{
#ifdef ENABLE_RR_DEBUG_INFO
- if (jit->debugInfo != nullptr)
+ if(jit->debugInfo != nullptr)
{
jit->debugInfo->EmitLocation();
}
@@ -4693,7 +4693,7 @@
void EmitDebugVariable(Value* value)
{
#ifdef ENABLE_RR_DEBUG_INFO
- if (jit->debugInfo != nullptr)
+ if(jit->debugInfo != nullptr)
{
jit->debugInfo->EmitVariable(value);
}
@@ -4703,7 +4703,7 @@
void FlushDebug()
{
#ifdef ENABLE_RR_DEBUG_INFO
- if (jit->debugInfo != nullptr)
+ if(jit->debugInfo != nullptr)
{
jit->debugInfo->Flush();
}
@@ -4761,7 +4761,7 @@
//
// bool coroutine_await(CoroutineHandle* handle, YieldType* out)
// {
- // if (llvm.coro.done(handle))
+ // if(llvm.coro.done(handle))
// {
// return false;
// }
@@ -4823,7 +4823,7 @@
//
// end:
// SuspendAction action = llvm.coro.suspend(none, true /* final */); // <-- RESUME POINT
- // switch (action)
+ // switch(action)
// {
// case SuspendActionResume:
// UNREACHABLE(); // Illegal to resume after final suspend.
@@ -4916,7 +4916,7 @@
void Nucleus::yield(Value* val)
{
- if (jit->coroutine.id == nullptr)
+ if(jit->coroutine.id == nullptr)
{
// First call to yield().
// Promote the function to a full coroutine.
@@ -4927,7 +4927,7 @@
// promise = val;
//
// auto action = llvm.coro.suspend(none, false /* final */); // <-- RESUME POINT
- // switch (action)
+ // switch(action)
// {
// case SuspendActionResume:
// goto resume;
@@ -4969,7 +4969,7 @@
std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Config::Edit &cfgEdit /* = Config::Edit::None */)
{
bool isCoroutine = jit->coroutine.id != nullptr;
- if (isCoroutine)
+ if(isCoroutine)
{
jit->builder->CreateBr(jit->coroutine.endBlock);
}
@@ -4988,7 +4988,7 @@
}
#ifdef ENABLE_RR_DEBUG_INFO
- if (jit->debugInfo != nullptr)
+ if(jit->debugInfo != nullptr)
{
jit->debugInfo->Finalize();
}
@@ -5001,7 +5001,7 @@
jit->module->print(file, 0);
}
- if (isCoroutine)
+ if(isCoroutine)
{
// Run manadory coroutine transforms.
llvm::legacy::PassManager pm;
diff --git a/src/Reactor/LLVMReactorDebugInfo.cpp b/src/Reactor/LLVMReactorDebugInfo.cpp
index ee090cc..db97080 100644
--- a/src/Reactor/LLVMReactorDebugInfo.cpp
+++ b/src/Reactor/LLVMReactorDebugInfo.cpp
@@ -104,7 +104,7 @@
void DebugInfo::Finalize()
{
- while (diScope.size() > 0)
+ while(diScope.size() > 0)
{
emitPending(diScope.back(), builder);
diScope.pop_back();
@@ -120,12 +120,12 @@
#ifdef ENABLE_RR_EMIT_PRINT_LOCATION
static Location lastLocation;
- if (backtrace.size() == 0)
+ if(backtrace.size() == 0)
{
return;
}
Location currLocation = backtrace[backtrace.size() - 1];
- if (currLocation != lastLocation)
+ if(currLocation != lastLocation)
{
rr::Print("rr> {0} [{1}:{2}]\n", currLocation.function.name.c_str(), currLocation.function.file.c_str(), currLocation.line);
lastLocation = std::move(currLocation);
@@ -142,7 +142,7 @@
{
auto shrink = [this](size_t newsize)
{
- while (diScope.size() > newsize)
+ while(diScope.size() > newsize)
{
auto &scope = diScope.back();
LOG("- STACK(%d): di: %p, location: %s:%d",
@@ -154,18 +154,18 @@
}
};
- if (backtrace.size() < diScope.size())
+ if(backtrace.size() < diScope.size())
{
shrink(backtrace.size());
}
- for (size_t i = 0; i < diScope.size(); i++)
+ for(size_t i = 0; i < diScope.size(); i++)
{
auto &scope = diScope[i];
auto const &oldLocation = scope.location;
auto const &newLocation = backtrace[i];
- if (oldLocation.function != newLocation.function)
+ if(oldLocation.function != newLocation.function)
{
LOG(" STACK(%d): Changed function %s -> %s", int(i),
oldLocation.function.name.c_str(), newLocation.function.name.c_str());
@@ -173,7 +173,7 @@
break;
}
- if (oldLocation.line > newLocation.line)
+ if(oldLocation.line > newLocation.line)
{
// Create a new di block to shadow all the variables in the loop.
auto file = getOrCreateFile(newLocation.function.file.c_str());
@@ -189,7 +189,7 @@
scope.location = newLocation;
}
- while (backtrace.size() > diScope.size())
+ while(backtrace.size() > diScope.size())
{
auto i = diScope.size();
auto location = backtrace[i];
@@ -223,7 +223,7 @@
llvm::DILocation* DebugInfo::getLocation(const Backtrace &backtrace, size_t i)
{
- if (backtrace.size() == 0) { return nullptr; }
+ if(backtrace.size() == 0) { return nullptr; }
assert(backtrace.size() == diScope.size());
return llvm::DILocation::get(
*context,
@@ -239,18 +239,18 @@
auto const& backtrace = getCallerBacktrace();
syncScope(backtrace);
- for (int i = backtrace.size() - 1; i >= 0; i--)
+ for(int i = backtrace.size() - 1; i >= 0; i--)
{
auto const &location = backtrace[i];
auto tokens = getOrParseFileTokens(location.function.file.c_str());
auto tokIt = tokens->find(location.line);
- if (tokIt == tokens->end())
+ if(tokIt == tokens->end())
{
break;
}
auto token = tokIt->second;
auto name = token.identifier;
- if (token.kind == Token::Return)
+ if(token.kind == Token::Return)
{
// This is a:
//
@@ -269,7 +269,7 @@
}
auto &scope = diScope[i];
- if (scope.pending.location != location)
+ if(scope.pending.location != location)
{
emitPending(scope, builder);
}
@@ -278,7 +278,7 @@
auto block = builder->GetInsertBlock();
auto insertAfter = block->size() > 0 ? &block->back() : nullptr;
- while (insertAfter != nullptr && insertAfter->isTerminator())
+ while(insertAfter != nullptr && insertAfter->isTerminator())
{
insertAfter = insertAfter->getPrevNode();
}
@@ -292,7 +292,7 @@
scope.pending.insertAfter = insertAfter;
scope.pending.scope = scope.di;
- if (token.kind == Token::Return)
+ if(token.kind == Token::Return)
{
// Insert a noop instruction so the debugger can inspect the
// return value before the function scope closes.
@@ -308,12 +308,12 @@
void DebugInfo::emitPending(Scope &scope, IRBuilder *builder)
{
auto const &pending = scope.pending;
- if (pending.value == nullptr)
+ if(pending.value == nullptr)
{
return;
}
- if (!scope.symbols.emplace(pending.name).second)
+ if(!scope.symbols.emplace(pending.name).second)
{
return;
}
@@ -326,7 +326,7 @@
auto value = pending.value;
IRBuilder::InsertPointGuard guard(*builder);
- if (pending.insertAfter != nullptr)
+ if(pending.insertAfter != nullptr)
{
builder->SetInsertPoint(pending.block, ++pending.insertAfter->getIterator());
}
@@ -336,7 +336,7 @@
}
builder->SetCurrentDebugLocation(pending.diLocation);
- if (!isAlloca)
+ if(!isAlloca)
{
// While insertDbgValueIntrinsic should be enough to declare a
// variable with no storage, variables of RValues can share the same
@@ -362,9 +362,9 @@
auto diVar = diBuilder->createAutoVariable(scope.di, pending.name, diFile, pending.location.line, diType);
auto di = diBuilder->insertDeclare(value, diVar, diBuilder->createExpression(), pending.diLocation, pending.block);
- if (pending.insertAfter != nullptr) { di->moveAfter(pending.insertAfter); }
+ if(pending.insertAfter != nullptr) { di->moveAfter(pending.insertAfter); }
- if (pending.addNopOnNextLine)
+ if(pending.addNopOnNextLine)
{
builder->SetCurrentDebugLocation(llvm::DILocation::get(
*context,
@@ -451,9 +451,9 @@
// Note that bs::stacktrace() effectively returns a vector of addresses; bs::frame construction is where
// the heavy lifting is done: resolving the function name, file and line number.
namespace bs = boost::stacktrace;
- for (bs::frame frame : bs::stacktrace())
+ for(bs::frame frame : bs::stacktrace())
{
- if (shouldSkipFile(frame.source_file()))
+ if(shouldSkipFile(frame.source_file()))
{
continue;
}
@@ -464,7 +464,7 @@
location.line = frame.source_line();
locations.push_back(location);
- if (limit > 0 && locations.size() >= limit)
+ if(limit > 0 && locations.size() >= limit)
{
break;
}
@@ -478,7 +478,7 @@
llvm::DIType *DebugInfo::getOrCreateType(llvm::Type* type)
{
auto it = diTypes.find(type);
- if (it != diTypes.end()) { return it->second; }
+ if(it != diTypes.end()) { return it->second; }
if(type->isPointerTy())
{
@@ -496,7 +496,7 @@
llvm::DIFile *DebugInfo::getOrCreateFile(const char* path)
{
auto it = diFiles.find(path);
- if (it != diFiles.end()) { return it->second; }
+ if(it != diFiles.end()) { return it->second; }
auto dirAndName = splitPath(path);
auto file = diBuilder->createFile(dirAndName.second, dirAndName.first);
diFiles.emplace(path, file);
@@ -508,7 +508,7 @@
static std::regex reLocalDecl(
"^" // line start
"\\s*" // initial whitespace
- "(?:For\\s*\\(\\s*)?" // optional 'For ('
+ "(?:For\\s*\\(\\s*)?" // optional 'For('
"((?:\\w+(?:<[^>]+>)?)(?:::\\w+(?:<[^>]+>)?)*)" // type (match group 1)
"\\s+" // whitespace between type and name
"(\\w+)" // identifier (match group 2)
@@ -516,7 +516,7 @@
"(\\[.*\\])?"); // optional array suffix (match group 3)
auto it = fileTokens.find(path);
- if (it != fileTokens.end())
+ if(it != fileTokens.end())
{
return it->second.get();
}
@@ -526,16 +526,16 @@
std::ifstream file(path);
std::string line;
int lineCount = 0;
- while (std::getline(file, line))
+ while(std::getline(file, line))
{
lineCount++;
std::smatch match;
- if (std::regex_search(line, match, reLocalDecl) && match.size() > 3)
+ if(std::regex_search(line, match, reLocalDecl) && match.size() > 3)
{
bool isArray = match.str(3) != "";
- if (!isArray) // Cannot deal with C-arrays of values.
+ if(!isArray) // Cannot deal with C-arrays of values.
{
- if (match.str(1) == "return")
+ if(match.str(1) == "return")
{
(*tokens)[lineCount] = Token{Token::Return};
}
diff --git a/src/Reactor/Optimizer.cpp b/src/Reactor/Optimizer.cpp
index 7cc3540..8b74f82 100644
--- a/src/Reactor/Optimizer.cpp
+++ b/src/Reactor/Optimizer.cpp
@@ -381,7 +381,7 @@
Ice::Operand *storeValue = nullptr;
bool unmatchedLoads = false;
- for (auto& loadStoreInst : getLoadStoreInsts(singleBasicBlock))
+ for(auto& loadStoreInst : getLoadStoreInsts(singleBasicBlock))
{
Ice::Inst* inst = loadStoreInst.inst;
diff --git a/src/Reactor/Print.hpp b/src/Reactor/Print.hpp
index ca06f4e..ff4ad81 100644
--- a/src/Reactor/Print.hpp
+++ b/src/Reactor/Print.hpp
@@ -56,7 +56,7 @@
static std::vector<Value*> val(const T* list, int count) {
std::vector<Value*> values;
values.reserve(count);
- for (int i = 0; i < count; i++)
+ for(int i = 0; i < count; i++)
{
auto v = val(list[i]);
values.insert(values.end(), v.begin(), v.end());
@@ -70,9 +70,9 @@
static std::string fmt(const T* list, int count)
{
std::string out = "[";
- for (int i = 0; i < count; i++)
+ for(int i = 0; i < count; i++)
{
- if (i > 0) { out += ", "; }
+ if(i > 0) { out += ", "; }
out += fmt(list[i]);
}
return out + "]";
@@ -149,7 +149,7 @@
{
std::vector< std::vector<Value*> > lists = {val(v)...};
std::vector<Value*> joined;
- for (const auto& list : lists)
+ for(const auto& list : lists)
{
joined.insert(joined.end(), list.begin(), list.end());
}
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index 7767c0f..c088e7b 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -31,8 +31,8 @@
UnaryPredicate pred)
{
ForwardIterator result = first;
- while (first!=last) {
- if (!pred(*first)) {
+ while(first!=last) {
+ if(!pred(*first)) {
*result = std::move(*first);
++result;
}
@@ -49,7 +49,7 @@
Config Config::Edit::apply(const Config &cfg) const
{
- if (this == &None) { return cfg; }
+ if(this == &None) { return cfg; }
auto level = optLevelChanged ? optLevel : cfg.optimization.getLevel();
auto passes = cfg.optimization.getPasses();
@@ -60,9 +60,9 @@
template <typename T>
void rr::Config::Edit::apply(const std::vector<std::pair<ListEdit, T>> & edits, std::vector<T>& list) const
{
- for (auto & edit : edits)
+ for(auto & edit : edits)
{
- switch (edit.first)
+ switch(edit.first)
{
case ListEdit::Add:
list.push_back(edit.second);
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index 42cbb7c..fc55c51 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -3458,7 +3458,7 @@
BasicBlock *end__ = Nucleus::createBasicBlock(); \
Nucleus::createCondBr((cond).value, end__, body__); \
Nucleus::setInsertBlock(end__); \
-} do {} while (false) // Require a semi-colon at the end of the Until()
+} do {} while(false) // Require a semi-colon at the end of the Until()
enum {IF_BLOCK__, ELSE_CLAUSE__, ELSE_BLOCK__, IFELSE_NUM__};
diff --git a/src/Reactor/ReactorUnitTests.cpp b/src/Reactor/ReactorUnitTests.cpp
index afcb6e3..8ffeb7c 100644
--- a/src/Reactor/ReactorUnitTests.cpp
+++ b/src/Reactor/ReactorUnitTests.cpp
@@ -1177,7 +1177,7 @@
{
Pointer<Byte> ptrA = function.Arg<0>();
Pointer<Byte> ptrB = function.Arg<1>();
- If (ptrA == ptrB)
+ If(ptrA == ptrB)
{
Return(1);
}
@@ -1213,7 +1213,7 @@
Return(Float(a) + b);
}
- if (auto routine = function("one"))
+ if(auto routine = function("one"))
{
float result = routine(1, 2.f);
EXPECT_EQ(result, 3.f);
@@ -1232,7 +1232,7 @@
Return(Float(a) + b + Float(c) + d);
}
- if (auto routine = function("one"))
+ if(auto routine = function("one"))
{
float result = routine(1, 2.f, 3, 4.f);
EXPECT_EQ(result, 10.f);
@@ -1252,7 +1252,7 @@
Return(Float(a) + b + Float(c) + d + Float(e));
}
- if (auto routine = function("one"))
+ if(auto routine = function("one"))
{
float result = routine(1, 2.f, 3, 4.f, 5);
EXPECT_EQ(result, 15.f);
@@ -1277,7 +1277,7 @@
Return(Float(a) + b + Float(c) + d + Float(e) + f + Float(g) + h + Float(i) + j);
}
- if (auto routine = function("one"))
+ if(auto routine = function("one"))
{
float result = routine(1, 2.f, 3, 4.f, 5, 6.f, 7, 8.f, 9, 10.f);
EXPECT_EQ(result, 55.f);
@@ -1785,7 +1785,7 @@
PtrInt base;
base.i = 0x10000;
- for (int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++)
{
PtrInt reference;
reference.p = &base.p[i];
@@ -1805,7 +1805,7 @@
TEST(ReactorUnitTests, Coroutines_Fibonacci)
{
- if (!rr::Caps.CoroutinesSupported)
+ if(!rr::Caps.CoroutinesSupported)
{
SUCCEED() << "Coroutines not supported";
return;
@@ -1817,7 +1817,7 @@
Yield(Int(1));
Int current = 1;
Int next = 1;
- While (true) {
+ While(true) {
Yield(next);
auto tmp = current + next;
current = next;
@@ -1836,7 +1836,7 @@
auto count = sizeof(expected) / sizeof(expected[0]);
- for (size_t i = 0; i < count; i++)
+ for(size_t i = 0; i < count; i++)
{
int out = 0;
EXPECT_EQ(coroutine->await(out), true);
@@ -1846,7 +1846,7 @@
TEST(ReactorUnitTests, Coroutines_Parameters)
{
- if (!rr::Caps.CoroutinesSupported)
+ if(!rr::Caps.CoroutinesSupported)
{
SUCCEED() << "Coroutines not supported";
return;
@@ -1903,7 +1903,7 @@
auto routine = function("one");
- for (auto&& v : GetParam().testValues)
+ for(auto&& v : GetParam().testValues)
{
SCOPED_TRACE(v);
EXPECT_FLOAT_EQ(routine(v), GetParam().refFunc(v));
@@ -1924,7 +1924,7 @@
auto routine = function("one");
- for (auto&& v : GetParam().testValues)
+ for(auto&& v : GetParam().testValues)
{
SCOPED_TRACE(v);
float4_value result = invokeRoutine(routine, float4_value{ v });
@@ -1951,7 +1951,7 @@
auto routine = function("one");
- for (auto&& v : GetParam().testValues)
+ for(auto&& v : GetParam().testValues)
{
SCOPED_TRACE(v);
float4_value result = invokeRoutine(routine, float4_value{ v.first }, float4_value{ v.second });
@@ -2013,7 +2013,7 @@
auto callable = (uint32_t(*)(uint32_t))routine->getEntry();
- for (uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i) {
uint32_t result = callable(1 << i);
EXPECT_EQ(result, 31 - i);
}
@@ -2037,7 +2037,7 @@
uint32_t x[4];
- for (uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i) {
callable(x, 1 << i);
EXPECT_EQ(x[0], 31 - i);
EXPECT_EQ(x[1], 31 - i);
@@ -2070,7 +2070,7 @@
auto callable = (uint32_t(*)(uint32_t))routine->getEntry();
- for (uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i) {
uint32_t result = callable(1 << i);
EXPECT_EQ(result, i);
}
@@ -2094,7 +2094,7 @@
uint32_t x[4];
- for (uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i) {
callable(x, 1 << i);
EXPECT_EQ(x[0], i);
EXPECT_EQ(x[1], i);
diff --git a/src/Reactor/Routine.hpp b/src/Reactor/Routine.hpp
index 922d3ab..f8083b1 100644
--- a/src/Reactor/Routine.hpp
+++ b/src/Reactor/Routine.hpp
@@ -41,7 +41,7 @@
explicit RoutineT(const std::shared_ptr<Routine>& routine)
: routine(routine)
{
- if (routine)
+ if(routine)
{
callable = reinterpret_cast<CallableType>(const_cast<void*>(routine->getEntry(0)));
}
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 4b09748..6201ab1 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -89,7 +89,7 @@
static Ice::OptLevel toIce(rr::Optimization::Level level)
{
- switch (level)
+ switch(level)
{
// Note that Opt_0 and Opt_1 are not implemented by Subzero
case rr::Optimization::Level::None: return Ice::Opt_m1;
@@ -592,7 +592,7 @@
static llvm::raw_os_ostream cout(std::cout);
static llvm::raw_os_ostream cerr(std::cerr);
- if (subzeroEmitTextAsm)
+ if(subzeroEmitTextAsm)
{
// Decorate text asm with liveness info
Flags.setDecorateAsm(true);
@@ -648,7 +648,7 @@
std::shared_ptr<Routine> Nucleus::acquireRoutine(const char *name, const Config::Edit &cfgEdit /* = Config::Edit::None */)
{
- if (subzeroDumpEnabled)
+ if(subzeroDumpEnabled)
{
// Output dump strings immediately, rather than once buffer is full. Useful for debugging.
context->getStrDump().SetUnbuffered();
@@ -678,7 +678,7 @@
::context->emitFileHeader();
- if (subzeroEmitTextAsm)
+ if(subzeroEmitTextAsm)
{
::function->emit();
}
@@ -3529,7 +3529,7 @@
RValue<Pointer<Byte>> ConstantPointer(void const * ptr)
{
- if (sizeof(void*) == 8)
+ if(sizeof(void*) == 8)
{
return RValue<Pointer<Byte>>(V(::context->getConstantInt64(reinterpret_cast<intptr_t>(ptr))));
}
@@ -3549,12 +3549,12 @@
Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> argTys)
{
Ice::Variable *ret = nullptr;
- if (retTy != nullptr)
+ if(retTy != nullptr)
{
ret = ::function->makeVariable(T(retTy));
}
auto call = Ice::InstCall::create(::function, args.size(), ret, V(fptr.value), false);
- for (auto arg : args)
+ for(auto arg : args)
{
call->addArg(V(arg));
}
@@ -3696,7 +3696,7 @@
RValue<UInt> Ctlz(RValue<UInt> x, bool isZeroUndef)
{
- if (emulateIntrinsics)
+ if(emulateIntrinsics)
{
UNIMPLEMENTED("Subzero Ctlz()"); return UInt(0);
}
@@ -3715,7 +3715,7 @@
RValue<UInt4> Ctlz(RValue<UInt4> x, bool isZeroUndef)
{
- if (emulateIntrinsics)
+ if(emulateIntrinsics)
{
UNIMPLEMENTED("Subzero Ctlz()"); return UInt4(0);
}
@@ -3733,7 +3733,7 @@
RValue<UInt> Cttz(RValue<UInt> x, bool isZeroUndef)
{
- if (emulateIntrinsics)
+ if(emulateIntrinsics)
{
UNIMPLEMENTED("Subzero Cttz()"); return UInt(0);
}
@@ -3752,7 +3752,7 @@
RValue<UInt4> Cttz(RValue<UInt4> x, bool isZeroUndef)
{
- if (emulateIntrinsics)
+ if(emulateIntrinsics)
{
UNIMPLEMENTED("Subzero Cttz()"); return UInt4(0);
}