diff options
Diffstat (limited to 'clang/include/clang/Parse/Parser.h')
-rw-r--r-- | clang/include/clang/Parse/Parser.h | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 01dafba6460..00533f0e044 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -736,32 +736,45 @@ private: void CheckNestedObjCContexts(SourceLocation AtLoc); public: + + // Control flags for SkipUntil functions. + enum SkipUntilFlags { + StopAtSemi = 1 << 0, /// \brief Stop skipping at semicolon + /// \brief Stop skipping at specified token, but don't skip the token itself + StopBeforeMatch = 1 << 1, + StopAtCodeCompletion = 1 << 2 /// \brief Stop at code completion + }; + + friend LLVM_CONSTEXPR SkipUntilFlags operator|(SkipUntilFlags L, + SkipUntilFlags R) { + return static_cast<SkipUntilFlags>(static_cast<unsigned>(L) | + static_cast<unsigned>(R)); + } + /// SkipUntil - Read tokens until we get to the specified token, then consume - /// it (unless DontConsume is true). Because we cannot guarantee that the - /// token will ever occur, this skips to the next token, or to some likely - /// good stopping point. If StopAtSemi is true, skipping will stop at a ';' - /// character. + /// it (unless StopBeforeMatch is specified). Because we cannot guarantee + /// that the token will ever occur, this skips to the next token, or to some + /// likely good stopping point. If Flags has StopAtSemi flag, skipping will + /// stop at a ';' character. /// /// If SkipUntil finds the specified token, it returns true, otherwise it /// returns false. - bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true, - bool DontConsume = false, bool StopAtCodeCompletion = false) { - return SkipUntil(llvm::makeArrayRef(T), StopAtSemi, DontConsume, - StopAtCodeCompletion); + bool SkipUntil(tok::TokenKind T, + SkipUntilFlags Flags = static_cast<SkipUntilFlags>(0)) { + return SkipUntil(llvm::makeArrayRef(T), Flags); } - bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true, - bool DontConsume = false, bool StopAtCodeCompletion = false) { + bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, + SkipUntilFlags Flags = static_cast<SkipUntilFlags>(0)) { tok::TokenKind TokArray[] = {T1, T2}; - return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); + return SkipUntil(TokArray, Flags); } bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3, - bool StopAtSemi = true, bool DontConsume = false, - bool StopAtCodeCompletion = false) { + SkipUntilFlags Flags = static_cast<SkipUntilFlags>(0)) { tok::TokenKind TokArray[] = {T1, T2, T3}; - return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion); + return SkipUntil(TokArray, Flags); } - bool SkipUntil(ArrayRef<tok::TokenKind> Toks, bool StopAtSemi = true, - bool DontConsume = false, bool StopAtCodeCompletion = false); + bool SkipUntil(ArrayRef<tok::TokenKind> Toks, + SkipUntilFlags Flags = static_cast<SkipUntilFlags>(0)); /// SkipMalformedDecl - Read tokens until we get to some likely good stopping /// point for skipping past a simple-declaration. |