[PATCH] D72202: [Diagnostic] make Wmisleading-indendation not warn about labels
Tyker via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 6 14:26:30 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5329bfc76bb: [Diagnostic] make Wmisleading-indendation not warn about labels (authored by Tyker).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72202/new/
https://reviews.llvm.org/D72202
Files:
clang/lib/Parse/ParseStmt.cpp
clang/test/Parser/warn-misleading-indentation.cpp
Index: clang/test/Parser/warn-misleading-indentation.cpp
===================================================================
--- clang/test/Parser/warn-misleading-indentation.cpp
+++ clang/test/Parser/warn-misleading-indentation.cpp
@@ -305,3 +305,10 @@
fail:;
}
+void f_label(int b) {
+ if (b)
+ return;
+ a:
+ return;
+ goto a;
+}
Index: clang/lib/Parse/ParseStmt.cpp
===================================================================
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -1272,10 +1272,12 @@
if (PrevColNum != 0 && CurColNum != 0 && StmtColNum != 0 &&
((PrevColNum > StmtColNum && PrevColNum == CurColNum) ||
- !Tok.isAtStartOfLine()) && SM.getPresumedLineNumber(StmtLoc) !=
- SM.getPresumedLineNumber(Tok.getLocation())) {
- P.Diag(Tok.getLocation(), diag::warn_misleading_indentation)
- << Kind;
+ !Tok.isAtStartOfLine()) &&
+ SM.getPresumedLineNumber(StmtLoc) !=
+ SM.getPresumedLineNumber(Tok.getLocation()) &&
+ (Tok.isNot(tok::identifier) ||
+ P.getPreprocessor().LookAhead(0).isNot(tok::colon))) {
+ P.Diag(Tok.getLocation(), diag::warn_misleading_indentation) << Kind;
P.Diag(StmtLoc, diag::note_previous_statement);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72202.236455.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200106/72d9fb07/attachment.bin>
More information about the cfe-commits
mailing list