aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorTyker <tyker1@outlook.com>2019-12-10 22:09:20 +0100
committerTyker <tyker1@outlook.com>2019-12-12 14:52:47 +0100
commit9c8cfa09d762a307bae55b75b621cbc53f4a3b3b (patch)
tree235d2fe1db0efdd66f6f9af2b25c4c22dc05ee7f /clang/lib
parent021b613cdc9091092e3429f36abdbe89a988681d (diff)
downloadllvm-9c8cfa09d762a307bae55b75b621cbc53f4a3b3b.zip
llvm-9c8cfa09d762a307bae55b75b621cbc53f4a3b3b.tar.gz
llvm-9c8cfa09d762a307bae55b75b621cbc53f4a3b3b.tar.bz2
[Diagnsotics] Small Improvement on -Wmisleading-indentation
Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: xbolva00 Differential Revision: https://reviews.llvm.org/D71083
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index dc951dc..203f306 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1201,13 +1201,12 @@ struct MisleadingIndentationChecker {
SourceLocation PrevLoc;
unsigned NumDirectives;
MisleadingStatementKind Kind;
- bool NeedsChecking;
bool ShouldSkip;
MisleadingIndentationChecker(Parser &P, MisleadingStatementKind K,
SourceLocation SL)
: P(P), StmtLoc(SL), PrevLoc(P.getCurToken().getLocation()),
NumDirectives(P.getPreprocessor().getNumDirectives()), Kind(K),
- NeedsChecking(true), ShouldSkip(P.getCurToken().is(tok::l_brace)) {
+ ShouldSkip(P.getCurToken().is(tok::l_brace)) {
if (!P.MisleadingIndentationElseLoc.isInvalid()) {
StmtLoc = P.MisleadingIndentationElseLoc;
P.MisleadingIndentationElseLoc = SourceLocation();
@@ -1216,9 +1215,10 @@ struct MisleadingIndentationChecker {
P.MisleadingIndentationElseLoc = SL;
}
void Check() {
- NeedsChecking = false;
Token Tok = P.getCurToken();
- if (ShouldSkip || NumDirectives != P.getPreprocessor().getNumDirectives() ||
+ if (P.getActions().getDiagnostics().isIgnored(
+ diag::warn_misleading_indentation, Tok.getLocation()) ||
+ ShouldSkip || NumDirectives != P.getPreprocessor().getNumDirectives() ||
Tok.isOneOf(tok::semi, tok::r_brace) || Tok.isAnnotation() ||
Tok.getLocation().isMacroID() || PrevLoc.isMacroID() ||
StmtLoc.isMacroID() ||
@@ -1226,6 +1226,8 @@ struct MisleadingIndentationChecker {
P.MisleadingIndentationElseLoc = SourceLocation();
return;
}
+ if (Kind == MSK_else)
+ P.MisleadingIndentationElseLoc = SourceLocation();
SourceManager &SM = P.getPreprocessor().getSourceManager();
unsigned PrevColNum = SM.getSpellingColumnNumber(PrevLoc);