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/Basic/TokenKinds.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) {
42 if (Start.isInvalid() || Start.isMacroID())
43 return SourceLocation();
46 if (L.isInvalid() || L.isMacroID())
47 return SourceLocation();
51 if (Lexer::getRawToken(L, T, SM, LangOpts,
true))
52 return SourceLocation();
54 if (T.isOneOf(TK, TKs...))
55 return T.getLocation();
61 template <
typename TokenKind,
typename... TokenKinds>
63 const SourceManager &SM,
64 const LangOptions &LangOpts, TokenKind TK,
67 Optional<Token> CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
70 return SourceLocation();
72 Token PotentialMatch = *CurrentToken;
73 if (PotentialMatch.isOneOf(TK, TKs...))
74 return PotentialMatch.getLocation();
79 if (PotentialMatch.is(tok::eof))
80 return SourceLocation();
81 Start = PotentialMatch.getLastLoc();
87 const SourceManager &SM,
88 const LangOptions &LangOpts);
94 const SourceManager &SM,
95 const LangOptions &LangOpts);
103 CharSourceRange Range,
104 const ASTContext &Context,
105 const SourceManager &SM);
112 #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)
Optional< Token > findNextTokenSkippingComments(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
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)
llvm::Optional< Token > getQualifyingToken(tok::TokenKind TK, CharSourceRange Range, const ASTContext &Context, const SourceManager &SM)
Assuming that Range spans a CVR-qualified type, returns the token in Range that is responsible for th...