9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H 12 #include "clang/AST/ASTContext.h" 13 #include "clang/Lex/Lexer.h" 22 const LangOptions &LangOpts,
bool SkipComments =
true);
25 const SourceManager &SM,
26 const LangOptions &LangOpts);
29 const SourceManager &SM,
30 const LangOptions &LangOpts,
34 const LangOptions &LangOpts);
36 template <
typename TokenKind,
typename... TokenKinds>
38 const SourceManager &SM,
39 const LangOptions &LangOpts,
40 TokenKind TK, TokenKinds... TKs) {
43 if (L.isInvalid() || L.isMacroID())
44 return SourceLocation();
48 if (Lexer::getRawToken(L, T, SM, LangOpts))
49 return SourceLocation();
51 if (T.isOneOf(TK, TKs...))
52 return T.getLocation();
58 template <
typename TokenKind,
typename... TokenKinds>
60 const SourceManager &SM,
61 const LangOptions &LangOpts, TokenKind TK,
64 Optional<Token> CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
67 return SourceLocation();
69 Token PotentialMatch = *CurrentToken;
70 if (PotentialMatch.isOneOf(TK, TKs...))
71 return PotentialMatch.getLocation();
73 Start = PotentialMatch.getLastLoc();
81 const SourceManager &SM,
82 const LangOptions &LangOpts);
89 const ASTContext &Context,
90 const SourceManager &SM);
97 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H bool rangeContainsExpansionsOrDirectives(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
Re-lex the provide Range and return false if either a macro spans multiple tokens, a pre-processor directive or failure to retrieve the next token is found, otherwise true.
Token getPreviousToken(SourceLocation Location, const SourceManager &SM, const LangOptions &LangOpts, bool SkipComments)
Returns previous token or tok::unknown if not found.
SourceLocation findNextTerminator(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
SourceLocation findNextAnyTokenKind(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs)
llvm::Optional< Token > getConstQualifyingToken(CharSourceRange Range, const ASTContext &Context, const SourceManager &SM)
Assuming that Range spans a const-qualified type, returns the const token in Range that is responsibl...
SourceLocation findPreviousTokenStart(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
CharSourceRange Range
SourceRange for the file name.
SourceLocation findPreviousAnyTokenKind(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs)
SourceLocation findPreviousTokenKind(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, tok::TokenKind TK)