10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_LEXER_UTILS_H 13 #include "clang/AST/ASTContext.h" 14 #include "clang/Lex/Lexer.h" 23 const LangOptions &LangOpts,
bool SkipComments =
true);
26 const SourceManager &SM,
27 const LangOptions &LangOpts);
30 const SourceManager &SM,
31 const LangOptions &LangOpts,
35 const LangOptions &LangOpts);
37 template <
typename TokenKind,
typename... TokenKinds>
39 const SourceManager &SM,
40 const LangOptions &LangOpts,
41 TokenKind TK, TokenKinds... TKs) {
44 if (L.isInvalid() || L.isMacroID())
45 return SourceLocation();
49 if (Lexer::getRawToken(L, T, SM, LangOpts))
50 return SourceLocation();
52 if (T.isOneOf(TK, TKs...))
53 return T.getLocation();
59 template <
typename TokenKind,
typename... TokenKinds>
61 const SourceManager &SM,
62 const LangOptions &LangOpts, TokenKind TK,
65 Optional<Token> CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
68 return SourceLocation();
70 Token PotentialMatch = *CurrentToken;
71 if (PotentialMatch.isOneOf(TK, TKs...))
72 return PotentialMatch.getLocation();
74 Start = PotentialMatch.getLastLoc();
82 const SourceManager &SM,
83 const LangOptions &LangOpts);
90 const ASTContext &Context,
91 const SourceManager &SM);
98 #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)