Before this patch readability-misleading-indentation could issue diagnostics
with an invalid location, which would lead to an assertion failure in
ClangTidyContext::diag()
llvm-svn: 358589
SourceLocation InnerLoc = Inner->getBeginLoc();
SourceLocation OuterLoc = CurrentStmt->getBeginLoc();
+ if (InnerLoc.isInvalid() || InnerLoc.isMacroID() || OuterLoc.isInvalid() ||
+ OuterLoc.isMacroID())
+ continue;
+
if (SM.getExpansionLineNumber(InnerLoc) ==
SM.getExpansionLineNumber(OuterLoc))
continue;
const Stmt *NextStmt = CStmt->body_begin()[i + 1];
SourceLocation NextLoc = NextStmt->getBeginLoc();
- if (InnerLoc.isMacroID() || OuterLoc.isMacroID() || NextLoc.isMacroID())
+ if (NextLoc.isInvalid() || NextLoc.isMacroID())
continue;
if (SM.getExpansionColumnNumber(InnerLoc) ==
foo1(); \
foo2();
-int main()
+void f()
{
bool cond1 = true;
bool cond2 = true;
else {
}
// CHECK-MESSAGES: :[[@LINE-2]]:8: warning: different indentation for 'if' and corresponding 'else' [readability-misleading-indentation]
-
+
if (cond1) {
if (cond1) {
}
BLOCK
}
+
+void g(bool x) {
+ if (x)
+ #pragma unroll
+ for (int k = 0; k < 1; ++k) {}
+
+ #pragma unroll
+ for (int k = 0; k < 1; ++k) {}
+}