17#ifndef LLVM_CLANG_LEX_DEPENDENCYDIRECTIVESSCANNER_H
18#define LLVM_CLANG_LEX_DEPENDENCYDIRECTIVESSCANNER_H
21#include "llvm/ADT/ArrayRef.h"
30class DiagnosticsEngine;
32namespace dependency_directives_scan {
50 template <
typename... Ts>
bool isOneOf(Ts... Ks)
const {
51 static_assert(
sizeof...(Ts) > 0,
52 "requires at least one tok::TokenKind specified");
53 return (
is(Ks) || ...);
118 StringRef Input, SmallVectorImpl<dependency_directives_scan::Token> &Tokens,
119 SmallVectorImpl<dependency_directives_scan::Directive> &Directives,
120 DiagnosticsEngine *Diags =
nullptr,
121 SourceLocation InputSourceLoc = SourceLocation());
135 ArrayRef<dependency_directives_scan::Directive> Directives,
136 llvm::raw_ostream &OS);
149 virtual std::unique_ptr<DependencyDirectivesGetter>
153 virtual std::optional<ArrayRef<dependency_directives_scan::Directive>>
Defines the clang::SourceLocation class and associated facilities.
Functor that returns the dependency directives for a given file.
virtual std::optional< ArrayRef< dependency_directives_scan::Directive > > operator()(FileEntryRef File)=0
Get the dependency directives for the given file.
virtual ~DependencyDirectivesGetter()=default
virtual std::unique_ptr< DependencyDirectivesGetter > cloneFor(FileManager &FileMgr)=0
Clone the getter for a new FileManager instance.
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Implements support for file system lookup, file system caching, and directory search management.
DirectiveKind
Represents the kind of preprocessor directive or a module declaration that is tracked by the scanner ...
@ tokens_present_before_eof
Indicates that there are tokens present between the last scanned directive and eof.
@ pp_pragma_system_header
@ pp_pragma_include_alias
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
void printDependencyDirectivesAsSource(StringRef Source, ArrayRef< dependency_directives_scan::Directive > Directives, llvm::raw_ostream &OS)
Print the previously scanned dependency directives as minimized source text.
bool scanInputForCXX20ModulesUsage(StringRef Source)
Scan an input source buffer for C++20 named module usage.
bool scanSourceForDependencyDirectives(StringRef Input, SmallVectorImpl< dependency_directives_scan::Token > &Tokens, SmallVectorImpl< dependency_directives_scan::Directive > &Directives, DiagnosticsEngine *Diags=nullptr, SourceLocation InputSourceLoc=SourceLocation())
Scan the input for the preprocessor directives that might have an effect on the dependencies for a co...
Represents a directive that's lexed as part of the dependency directives scanning.
Directive(DirectiveKind K, ArrayRef< Token > Tokens)
DirectiveKind Kind
The kind of token.
Token lexed as part of dependency directive scanning.
bool isNot(tok::TokenKind K) const
Token(unsigned Offset, unsigned Length, tok::TokenKind Kind, unsigned short Flags)
unsigned Offset
Offset into the original source input.
bool is(tok::TokenKind K) const
bool isOneOf(Ts... Ks) const