summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2017-05-09 12:41:11 +0000
committerAlexander Kornienko <alexfh@google.com>2017-05-09 12:41:11 +0000
commit7aedf33a241da0c5bffc4d5a9e723bf8291993e5 (patch)
treed1cda3494284f6e71a5949f160668fa7b215c427
parentf8622dff7ad7b38e3e6fc80a65f7de06ea22c18a (diff)
downloadbcm5719-llvm-7aedf33a241da0c5bffc4d5a9e723bf8291993e5.tar.gz
bcm5719-llvm-7aedf33a241da0c5bffc4d5a9e723bf8291993e5.zip
[clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC
llvm-svn: 302522
-rw-r--r--clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp10
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp11
2 files changed, 16 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index 4dea41dfb4a..6f35fe210a8 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -39,7 +39,7 @@ SourceLocation forwardSkipWhitespaceAndComments(SourceLocation Loc,
const ASTContext *Context) {
assert(Loc.isValid());
for (;;) {
- while (isWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+ while (isWhitespace(*SM.getCharacterData(Loc)))
Loc = Loc.getLocWithOffset(1);
tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -69,7 +69,6 @@ SourceLocation findEndLocation(SourceLocation LastTokenLoc,
Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, Context->getLangOpts());
// Loc points past the last token before end or after ';'.
-
if (SkipEndWhitespaceAndComments) {
Loc = forwardSkipWhitespaceAndComments(Loc, SM, Context);
tok::TokenKind TokKind = getTokenKind(Loc, SM, Context);
@@ -79,10 +78,11 @@ SourceLocation findEndLocation(SourceLocation LastTokenLoc,
for (;;) {
assert(Loc.isValid());
- while (isHorizontalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData()))
+ while (isHorizontalWhitespace(*SM.getCharacterData(Loc))) {
Loc = Loc.getLocWithOffset(1);
+ }
- if (isVerticalWhitespace(*FullSourceLoc(Loc, SM).getCharacterData())) {
+ if (isVerticalWhitespace(*SM.getCharacterData(Loc))) {
// EOL, insert brace before.
break;
}
@@ -159,7 +159,7 @@ void BracesAroundStatementsCheck::check(
ForceBracesStmts.insert(Else);
if (Else && !isa<IfStmt>(Else)) {
// Omit 'else if' statements here, they will be handled directly.
- checkStmt(Result, Else, S->getElseLoc(), SourceLocation());
+ checkStmt(Result, Else, S->getElseLoc());
}
} else {
llvm_unreachable("Invalid match");
diff --git a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp
index ee147f62349..97307351e15 100644
--- a/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp
+++ b/clang-tools-extra/test/clang-tidy/readability-braces-around-statements.cpp
@@ -172,6 +172,17 @@ void test() {
// CHECK-FIXES-NEXT: }
}
+void f(const char *p) {
+ if (!p)
+ f("\
+");
+ // CHECK-MESSAGES: :[[@LINE-3]]:10: warning: statement should be inside braces
+ // CHECK-FIXES: {{^ }}if (!p) {{{$}}
+ // CHECK-FIXES-NEXT: {{^ }}f("\{{$}}
+ // CHECK-FIXES-_NEXT: {{^}}");{{$}} FIXME: This breaks (http://llvm.org/PR26228)
+ // CHECK-FIXES-_NEXT: {{^}}}{{$}}
+}
+
#define M(x) x
int test_macros(bool b) {
OpenPOWER on IntegriCloud