|
clang-tools 24.0.0git
|
Classes | |
| struct | CommentToken |
Functions | |
| StringRef | getTokenName (const Token &Tok) |
| Returns the spelling of an identifier token. | |
| std::vector< Token > | getRawTokens (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) |
Returns the raw tokens in Range. | |
| std::pair< std::optional< Token >, SourceLocation > | getPreviousTokenAndStart (SourceLocation Location, const SourceManager &SM, const LangOptions &LangOpts, bool SkipComments) |
| std::optional< Token > | getPreviousToken (SourceLocation Location, const SourceManager &SM, const LangOptions &LangOpts, bool SkipComments=true) |
| Returns previous token or std::nullopt if not found. | |
| SourceLocation | findPreviousTokenStart (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) |
| SourceLocation | findPreviousTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, tok::TokenKind TK) |
| SourceLocation | findNextTerminator (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) |
| 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. | |
| static std::vector< CommentToken > | collectCommentsInRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, CommentCollectionMode Mode) |
| std::vector< CommentToken > | getCommentsInRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) |
| Returns all comment tokens found in the given range. | |
| std::vector< CommentToken > | getTrailingCommentsInRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) |
| Returns comment tokens found in the given range. If a non-comment token is encountered, clears previously collected comments and continues. | |
| CharSourceRange | findTokenTextInRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, llvm::function_ref< bool(const Token &)> Pred) |
Returns source range of the first token in Range matching Pred. The returned char range starts at the matched token and ends at the start of the next token. Returns invalid range if no token matches. | |
| std::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 the qualification. Range must be valid with respect to SM. Returns std::nullopt if no. | |
| static bool | breakAndReturnEnd (const Stmt &S) |
| static bool | breakAndReturnEndPlus1Token (const Stmt &S) |
| static SourceLocation | getSemicolonAfterStmtEndLoc (const SourceLocation &EndLoc, const SourceManager &SM, const LangOptions &LangOpts) |
| SourceLocation | getUnifiedEndLoc (const Stmt &S, const SourceManager &SM, const LangOptions &LangOpts) |
| Stmt->getEndLoc does not always behave the same way depending on Token type. | |
| SourceLocation | getLocationForNoexceptSpecifier (const FunctionDecl *FuncDecl, const SourceManager &SM) |
| For a given FunctionDecl returns the location where you would need to place the noexcept specifier. | |
| template<typename TokenKind, typename... TokenKinds> | |
| SourceLocation | findPreviousAnyTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs) |
| template<typename TokenKind, typename... TokenKinds> | |
| SourceLocation | findNextAnyTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs) |
| std::optional< Token > | findNextTokenIncludingComments (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) |
| std::optional< Token > | findNextTokenSkippingComments (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) |
|
static |
Definition at line 316 of file LexerUtils.cpp.
Referenced by getUnifiedEndLoc().
|
static |
Definition at line 320 of file LexerUtils.cpp.
Referenced by getUnifiedEndLoc().
|
static |
Definition at line 148 of file LexerUtils.cpp.
Referenced by getCommentsInRange(), and getTrailingCommentsInRange().
| SourceLocation clang::tidy::utils::lexer::findNextAnyTokenKind | ( | SourceLocation | Start, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| TokenKind | TK, | ||
| TokenKinds... | TKs ) |
Definition at line 81 of file LexerUtils.h.
Referenced by clang::tidy::modernize::findInsertionForConstraint(), and findNextTerminator().
| SourceLocation clang::tidy::utils::lexer::findNextTerminator | ( | SourceLocation | Start, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Definition at line 114 of file LexerUtils.cpp.
References findNextAnyTokenKind().
Referenced by clang::tidy::cppcoreguidelines::changePrivateDestructorVisibilityTo(), clang::tidy::cppcoreguidelines::InitVariablesCheck::check(), clang::tidy::performance::TriviallyDestructibleCheck::check(), clang::tidy::readability::AvoidReturnWithVoidValueCheck::check(), clang::tidy::readability::declRanges(), and clang::tidy::bugprone::hintMakeCtorPrivate().
|
inline |
Definition at line 107 of file LexerUtils.h.
Referenced by clang::tidy::modernize::UseOverrideCheck::check(), and clang::tidy::modernize::NS::getNamespaceBackRange().
|
inline |
Definition at line 114 of file LexerUtils.h.
Referenced by clang::tidy::utils::FormatStringConverter::applyFixes(), clang::tidy::bugprone::RedundantBranchConditionCheck::check(), clang::tidy::cppcoreguidelines::PreferMemberInitializerCheck::check(), clang::tidy::llvm_check::UseVectorUtilsCheck::check(), clang::tidy::llvm_libc::InlineFunctionDeclCheck::check(), clang::tidy::modernize::RedundantVoidArgCheck::check(), clang::tidy::modernize::UseEqualsDefaultCheck::check(), clang::tidy::readability::RedundantLambdaParameterListCheck::check(), clang::tidy::readability::cleanInitialValue(), clang::tidy::modernize::generateReplacements(), clang::tidy::modernize::NS::getCleanedNamespaceFrontRange(), clang::tidy::readability::getInlineTokenLocation(), clang::tidy::readability::getNamespaceNameAsWritten(), getSemicolonAfterStmtEndLoc(), clang::tidy::cppcoreguidelines::getVirtualKeywordRange(), clang::tidy::readability::hasTrailingSyntaxAfterRhsType(), rangeContainsExpansionsOrDirectives(), clang::tidy::performance::recordRemoval(), and clang::tidy::llvm_check::rewrite().
| SourceLocation clang::tidy::utils::lexer::findPreviousAnyTokenKind | ( | SourceLocation | Start, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| TokenKind | TK, | ||
| TokenKinds... | TKs ) |
Definition at line 57 of file LexerUtils.h.
References findPreviousTokenStart().
Referenced by clang::tidy::utils::fixit::changeReferencee(), and clang::tidy::readability::findStartOfIndirection().
| SourceLocation clang::tidy::utils::lexer::findPreviousTokenKind | ( | SourceLocation | Start, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| tok::TokenKind | TK ) |
Definition at line 91 of file LexerUtils.cpp.
References findPreviousTokenStart().
Referenced by clang::tidy::utils::fixit::changePointer(), clang::tidy::readability::declRanges(), clang::tidy::cppcoreguidelines::findDefaultCaptureEnd(), clang::tidy::modernize::findInsertionForConstraint(), clang::tidy::modernize::getConditionRange(), clang::tidy::modernize::getTypeRange(), and clang::tidy::modernize::handleTrailingTemplateType().
| SourceLocation clang::tidy::utils::lexer::findPreviousTokenStart | ( | SourceLocation | Start, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Definition at line 78 of file LexerUtils.cpp.
Referenced by clang::tidy::readability::declRanges(), findPreviousAnyTokenKind(), findPreviousTokenKind(), and clang::tidy::utils::fixit::skipLParensBackwards().
| CharSourceRange clang::tidy::utils::lexer::findTokenTextInRange | ( | CharSourceRange | Range, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| llvm::function_ref< bool(const Token &)> | Pred ) |
Returns source range of the first token in Range matching Pred. The returned char range starts at the matched token and ends at the start of the next token. Returns invalid range if no token matches.
Definition at line 223 of file LexerUtils.cpp.
Referenced by clang::tidy::misc::ExplicitConstructorCheck::check(), and clang::tidy::readability::RedundantQualifiedAliasCheck::check().
| std::vector< CommentToken > clang::tidy::utils::lexer::getCommentsInRange | ( | CharSourceRange | Range, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Returns all comment tokens found in the given range.
Definition at line 208 of file LexerUtils.cpp.
References collectCommentsInRange().
Referenced by clang::tidy::readability::hasOnlyPayloadCommentsInNestedHeader().
| SourceLocation clang::tidy::utils::lexer::getLocationForNoexceptSpecifier | ( | const FunctionDecl * | FuncDecl, |
| const SourceManager & | SM ) |
For a given FunctionDecl returns the location where you would need to place the noexcept specifier.
Definition at line 378 of file LexerUtils.cpp.
References FuncDecl.
Referenced by clang::tidy::performance::NoexceptFunctionBaseCheck::check().
| std::optional< Token > clang::tidy::utils::lexer::getPreviousToken | ( | SourceLocation | Location, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| bool | SkipComments ) |
Returns previous token or std::nullopt if not found.
Definition at line 69 of file LexerUtils.cpp.
References getPreviousTokenAndStart().
Referenced by clang::tidy::utils::fixit::changeVarDeclToReference(), clang::tidy::bugprone::OptionalValueConversionCheck::check(), clang::tidy::bugprone::SuspiciousSemicolonCheck::check(), clang::tidy::readability::DeleteNullPointerCheck::check(), clang::tidy::readability::declRanges(), clang::tidy::utils::getBraceInsertionsHints(), clang::tidy::bugprone::getCommentsBeforeLoc(), clang::tidy::readability::getFullInitRangeInclWhitespaces(), and clang::tidy::utils::fixit::skipLParensBackwards().
| std::pair< std::optional< Token >, SourceLocation > clang::tidy::utils::lexer::getPreviousTokenAndStart | ( | SourceLocation | Location, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts, | ||
| bool | SkipComments ) |
Definition at line 58 of file LexerUtils.cpp.
Referenced by clang::tidy::modernize::getConditionText(), getPreviousToken(), and clang::tidy::readability::isAtStartOfLineIncludingEmptyMacro().
| std::optional< Token > clang::tidy::utils::lexer::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 the qualification. Range must be valid with respect to SM. Returns std::nullopt if no.
qualifying tokens are found.
Definition at line 276 of file LexerUtils.cpp.
Referenced by clang::tidy::readability::findConstToRemove(), clang::tidy::readability::findConstToRemove(), and clang::tidy::readability::findQualToken().
| std::vector< Token > clang::tidy::utils::lexer::getRawTokens | ( | CharSourceRange | Range, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Returns the raw tokens in Range.
The returned tokens refer to the source manager's backing buffer.
Definition at line 25 of file LexerUtils.cpp.
|
static |
Definition at line 327 of file LexerUtils.cpp.
References findNextTokenSkippingComments().
Referenced by getUnifiedEndLoc().
| StringRef clang::tidy::utils::lexer::getTokenName | ( | const Token & | Tok | ) |
Returns the spelling of an identifier token.
Definition at line 17 of file LexerUtils.cpp.
| std::vector< CommentToken > clang::tidy::utils::lexer::getTrailingCommentsInRange | ( | CharSourceRange | Range, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Returns comment tokens found in the given range. If a non-comment token is encountered, clears previously collected comments and continues.
Definition at line 216 of file LexerUtils.cpp.
References collectCommentsInRange().
| SourceLocation clang::tidy::utils::lexer::getUnifiedEndLoc | ( | const Stmt & | S, |
| const SourceManager & | SM, | ||
| const LangOptions & | LangOpts ) |
Stmt->getEndLoc does not always behave the same way depending on Token type.
See implementation for exceptions.
Definition at line 363 of file LexerUtils.cpp.
References breakAndReturnEnd(), breakAndReturnEndPlus1Token(), and getSemicolonAfterStmtEndLoc().
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check(), and clang::tidy::utils::findEndLocation().
| bool clang::tidy::utils::lexer::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.
Definition at line 119 of file LexerUtils.cpp.
References findNextTokenSkippingComments().
Referenced by clang::tidy::modernize::UseEqualsDefaultCheck::check(), clang::tidy::readability::declRanges(), clang::tidy::readability::hasMacroInRange(), clang::tidy::readability::isUnsafeCharRange(), and clang::tidy::readability::isUnsafeTokenRange().