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/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);
}