[llvm-dev] -Wmisleading-indentation violations

Dan Liew via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 1 22:51:40 PDT 2016


Hi,

I was building LLVM with gcc 6.1.1 recently and it was spitting out
some warnings relating to misleading indention that caught my eye.
This wasn't a fresh build so I may have missed some. I've CC'ed the
authors of the potentially misleading lines so they can decide what do
about the warnings (if anything).

I'm wondering if clang-format is making some inappropriate choices
here or these are just genuine mistakes.


Anyway here are the ones I saw in passing.

```

/home/dsl11/dev/llvm-upstream/src/lib/MC/MCParser/DarwinAsmParser.cpp:
In member function ‘bool
{anonymous}::DarwinAsmParser::parseVersionMin(llvm::StringRef,
llvm::SMLoc)’:

/home/dsl11/dev/llvm-upstream/src/lib/MC/MCParser/DarwinAsmParser.cpp:962:3:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

   if (Update > 255 || Update < 0)

   ^~

/home/dsl11/dev/llvm-upstream/src/lib/MC/MCParser/DarwinAsmParser.cpp:964:5:
note: ...this statement, but the latter is misleadingly indented

as if it is guarded by the ‘if’

     Lex();

     ^~~
```

```
/home/dsl11/dev/llvm-upstream/src/lib/Transforms/Scalar/LoopStrengthReduce.cpp:
In member function ‘void {anonymous}::Cost::RateRegister(const
llvm::SCEV*, llvm::SmallPtrSetImpl<const llvm::SCEV*>&, const
llvm::Loop*, llvm::ScalarEvolution&, llvm::DominatorTree&)’:

/home/dsl11/dev/llvm-upstream/src/lib/Transforms/Scalar/LoopStrengthReduce.cpp:943:3:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

   if (!isa<SCEVUnknown>(Reg) &&

   ^~

/home/dsl11/dev/llvm-upstream/src/lib/Transforms/Scalar/LoopStrengthReduce.cpp:950:5:
note: ...this statement, but the latter is misleadingly

indented as if it is guarded by the ‘if’

     NumIVMuls += isa<SCEVMulExpr>(Reg) &&

     ^~~~~~~~~
```

and

```

/home/dsl11/dev/llvm-upstream/src/lib/Target/AMDGPU/R600MachineScheduler.cpp:
In member function ‘llvm::R600SchedStrategy::AluKind llvm::R600S

chedStrategy::getAluKind(llvm::SUnit*) const’:

/home/dsl11/dev/llvm-upstream/src/lib/Target/AMDGPU/R600MachineScheduler.cpp:225:3:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

   if (TII->isTransOnly(MI))

   ^~

/home/dsl11/dev/llvm-upstream/src/lib/Target/AMDGPU/R600MachineScheduler.cpp:228:5:
note: ...this statement, but the latter is misleadingly in

dented as if it is guarded by the ‘if’

     switch (MI->getOpcode()) {

     ^~~~~~
```

and

```
/home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp: In
member function ‘bool llvm::LLParser::ParseTopLevelEntities()’:

/home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp:260:34:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

                                  if (ParseUseListOrderBB()) return true; break;

                                  ^~

/home/dsl11/dev/llvm-upstream/src/lib/AsmParser/LLParser.cpp:260:74:
note: ...this statement, but the latter is misleadingly indented as if
it

 is guarded by the ‘if’

                                  if (ParseUseListOrderBB()) return true; break;

                                                                          ^~~~~
```

and

```
/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:
In member function ‘void {anonymous}::ObjCDeal

locChecker::diagnoseMissingReleases(clang::ento::CheckerContext&) const’:

/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:532:5:
warning: this ‘if’ clause does not guard

... [-Wmisleading-indentation]

     if (SelfRegion != IvarRegion->getSuperRegion())

     ^~

/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:535:7:
note: ...this statement, but the latter

is misleadingly indented as if it is guarded by the ‘if’

       const ObjCIvarDecl *IvarDecl = IvarRegion->getDecl();
```

and

```

/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/Basic/Targets.cpp:
In member function ‘virtual void
{anonymous}::AMDGPUTargetInfo::setSupportedOpenCLOpts()’:

/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/Basic/Targets.cpp:2129:6:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentat

ion]

      if (GPU >= GK_SOUTHERN_ISLANDS)

      ^~

/home/dsl11/dev/llvm-upstream/src/tools/clang/lib/Basic/Targets.cpp:2131:8:
note: ...this statement, but the latter is misleadingly indented a

s if it is guarded by the ‘if’

        Opts.cl_khr_int64_base_atomics = 1;

        ^~~~
```

HTH,
Dan.


More information about the llvm-dev mailing list