diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-04-09 16:37:11 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-04-09 16:37:11 +0000 |
commit | eb52f86a62db523e3c993686b3ed92c55d59d53c (patch) | |
tree | 5134ec06185e7f16efc2e2cac6543cd84f0a45a5 /include/clang/Parse/Parser.h | |
parent | 649ee3fec12dcf7167630ff88087ad116e9eefa6 (diff) |
Fix bugs found by -Wconstant-conversion improvements currently under review.
Specifically, using a an integer outside [0, 1] as a boolean constant seems to
be an easy mistake to make with things like "x == a || b" where the author
intended "x == a || x == b".
The bug caused by calling SkipUntil with three token kinds was also identified
by a VC diagnostic & reported by Francois Pichet as review feedback for my
commit r154163. I've included test cases to verify the error recovery that was
broken/poorly implemented due to this bug.
The other fix (lib/Sema/SemaExpr.cpp) seems like that code was never actually
reached in any of Clang's tests & is related to Objective C features I'm not
familiar with, so I've not been able to construct a test case for it. Perhaps
someone else can.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Parse/Parser.h')
-rw-r--r-- | include/clang/Parse/Parser.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 892d5fa501..0721417f7b 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -725,16 +725,22 @@ private: /// returns false. bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true, bool DontConsume = false, bool StopAtCodeCompletion = false) { - return SkipUntil(&T, 1, StopAtSemi, DontConsume, StopAtCodeCompletion); + return SkipUntil(llvm::makeArrayRef(T), StopAtSemi, DontConsume, + StopAtCodeCompletion); } bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true, bool DontConsume = false, bool StopAtCodeCompletion = false) { tok::TokenKind TokArray[] = {T1, T2}; - return SkipUntil(TokArray, 2, StopAtSemi, DontConsume,StopAtCodeCompletion); + return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); } - bool SkipUntil(const tok::TokenKind *Toks, unsigned NumToks, + bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, bool StopAtSemi = true, bool DontConsume = false, - bool StopAtCodeCompletion = false); + bool StopAtCodeCompletion = false) { + tok::TokenKind TokArray[] = {T1, T2, T3}; + return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); + } + bool SkipUntil(ArrayRef<tok::TokenKind> Toks, bool StopAtSemi = true, + bool DontConsume = false, bool StopAtCodeCompletion = false); //===--------------------------------------------------------------------===// // Lexing and parsing of C++ inline methods. |