File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 10
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H
11
11
12
12
#include " clang/AST/ASTContext.h"
13
+ #include " clang/Basic/TokenKinds.h"
13
14
#include " clang/Lex/Lexer.h"
14
15
15
16
namespace clang {
@@ -70,6 +71,11 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
70
71
if (PotentialMatch.isOneOf (TK, TKs...))
71
72
return PotentialMatch.getLocation ();
72
73
74
+ // If we reach the end of the file, and eof is not the target token, we stop
75
+ // the loop, otherwise we will get infinite loop (findNextToken will return
76
+ // eof on eof).
77
+ if (PotentialMatch.is (tok::eof))
78
+ return SourceLocation ();
73
79
Start = PotentialMatch.getLastLoc ();
74
80
}
75
81
}
Original file line number Diff line number Diff line change
1
+ // RUN: %check_clang_tidy -expect-clang-tidy-error %s readability-isolate-declaration %t
2
+
3
+ int main (){
4
+ int a, b
5
+ // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
6
+ // CHECK-MESSAGES: [[@LINE-2]]:11: error: expected ';' at end of declaration [clang-diagnostic-error]
7
+ }
You can’t perform that action at this time.
0 commit comments