clang-tools 23.0.0git
LexerUtils.h File Reference
#include "clang/AST/ASTContext.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include <optional>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  clang::tidy::utils::lexer::CommentToken

Namespaces

namespace  clang
 ===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
namespace  clang::tidy
namespace  clang::tidy::utils
namespace  clang::tidy::utils::lexer

Functions

std::optional< Token > clang::tidy::utils::lexer::getPreviousToken (SourceLocation Location, const SourceManager &SM, const LangOptions &LangOpts, bool SkipComments=true)
 Returns previous token or std::nullopt if not found.
std::pair< std::optional< Token >, SourceLocation > clang::tidy::utils::lexer::getPreviousTokenAndStart (SourceLocation Location, const SourceManager &SM, const LangOptions &LangOpts, bool SkipComments)
SourceLocation clang::tidy::utils::lexer::findPreviousTokenStart (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
SourceLocation clang::tidy::utils::lexer::findPreviousTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, tok::TokenKind TK)
SourceLocation clang::tidy::utils::lexer::findNextTerminator (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
template<typename TokenKind, typename... TokenKinds>
SourceLocation clang::tidy::utils::lexer::findPreviousAnyTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs)
template<typename TokenKind, typename... TokenKinds>
SourceLocation clang::tidy::utils::lexer::findNextAnyTokenKind (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, TokenKind TK, TokenKinds... TKs)
std::optional< Token > clang::tidy::utils::lexer::findNextTokenIncludingComments (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
std::optional< Token > clang::tidy::utils::lexer::findNextTokenSkippingComments (SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
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.
std::vector< CommentTokenclang::tidy::utils::lexer::getCommentsInRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
 Returns all comment tokens found in the given range.
std::vector< CommentTokenclang::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.
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.
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.
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.
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.