45 #include "llvm/ADT/APFloat.h"
46 #include "llvm/ADT/STLExtras.h"
47 #include "llvm/ADT/SmallString.h"
48 #include "llvm/ADT/StringExtras.h"
49 #include "llvm/Support/Capacity.h"
50 #include "llvm/Support/ConvertUTF.h"
51 #include "llvm/Support/MemoryBuffer.h"
52 #include "llvm/Support/raw_ostream.h"
53 using namespace clang;
64 : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(nullptr),
65 FileMgr(Headers.getFileMgr()),
SourceMgr(SM),
67 TheModuleLoader(TheModuleLoader), ExternalSource(nullptr),
68 Identifiers(opts, IILookup),
70 IncrementalProcessing(
false), TUKind(TUKind),
71 CodeComplete(nullptr), CodeCompletionFile(nullptr),
72 CodeCompletionOffset(0), LastTokenWasAt(
false),
73 ModuleImportExpectsIdentifier(
false), CodeCompletionReached(0),
74 MainFileDir(nullptr), SkipMainFilePreamble(0,
true), CurPPLexer(nullptr),
75 CurDirLookup(nullptr), CurLexerKind(CLK_Lexer), CurSubmodule(nullptr),
76 Callbacks(nullptr), CurSubmoduleState(&NullSubmoduleState),
77 MacroArgCache(nullptr), Record(nullptr),
78 MIChainHead(nullptr), DeserialMIChainHead(nullptr) {
79 OwnsHeaderSearch = OwnsHeaders;
84 NumDirectives = NumDefined = NumUndefined = NumPragma = 0;
85 NumIf = NumElse = NumEndif = 0;
86 NumEnteredSourceFiles = 0;
87 NumMacroExpanded = NumFnMacroExpanded = NumBuiltinMacroExpanded = 0;
88 NumFastMacroExpanded = NumTokenPaste = NumFastTokenPaste = 0;
89 MaxIncludeStackDepth = 0;
94 KeepMacroComments =
false;
95 SuppressIncludeNotFoundError =
false;
98 DisableMacroExpansion =
false;
99 MacroExpansionInDirectivesOverride =
false;
101 InMacroArgPreExpansion =
false;
102 NumCachedTokenLexers = 0;
103 PragmasEnabled =
true;
104 ParsingIfOrElifDirective =
false;
105 PreprocessedOutput =
false;
110 ReadMacrosFromExternalSource =
false;
118 RegisterBuiltinPragmas();
121 RegisterBuiltinMacros();
123 if(LangOpts.Borland) {
134 Ident__exception_info = Ident__exception_code =
nullptr;
135 Ident__abnormal_termination = Ident___exception_info =
nullptr;
136 Ident___exception_code = Ident___abnormal_termination =
nullptr;
137 Ident_GetExceptionInfo = Ident_GetExceptionCode =
nullptr;
138 Ident_AbnormalTermination =
nullptr;
143 assert(BacktrackPositions.empty() &&
"EnableBacktrack/Backtrack imbalance!");
145 IncludeMacroStack.clear();
148 while (MacroInfoChain *I = MIChainHead) {
149 MIChainHead = I->Next;
150 I->~MacroInfoChain();
156 std::fill(TokenLexerCache, TokenLexerCache + NumCachedTokenLexers,
nullptr);
157 CurTokenLexer.reset();
159 while (DeserializedMacroInfoChain *I = DeserialMIChainHead) {
160 DeserialMIChainHead = I->Next;
161 I->~DeserializedMacroInfoChain();
165 for (
MacroArgs *ArgList = MacroArgCache; ArgList;)
166 ArgList = ArgList->deallocate();
169 if (OwnsHeaderSearch)
174 assert((!this->Target || this->Target == &Target) &&
175 "Invalid override of target information");
176 this->Target = &Target;
184 NumEnteredSourceFiles = 0;
187 PragmaHandlersBackup = std::move(PragmaHandlers);
188 PragmaHandlers = llvm::make_unique<PragmaNamespace>(StringRef());
189 RegisterBuiltinPragmas();
192 PredefinesFileID =
FileID();
196 NumEnteredSourceFiles = 1;
198 PragmaHandlers = std::move(PragmaHandlersBackup);
210 if (!DumpFlags)
return;
212 llvm::errs() <<
"\t";
214 llvm::errs() <<
" [StartOfLine]";
216 llvm::errs() <<
" [LeadingSpace]";
218 llvm::errs() <<
" [ExpandDisabled]";
221 llvm::errs() <<
" [UnClean='" << StringRef(Start, Tok.
getLength())
225 llvm::errs() <<
"\tLoc=<";
235 llvm::errs() <<
"MACRO: ";
236 for (
unsigned i = 0, e = MI.
getNumTokens(); i != e; ++i) {
240 llvm::errs() <<
"\n";
244 llvm::errs() <<
"\n*** Preprocessor Stats:\n";
245 llvm::errs() << NumDirectives <<
" directives found:\n";
246 llvm::errs() <<
" " << NumDefined <<
" #define.\n";
247 llvm::errs() <<
" " << NumUndefined <<
" #undef.\n";
248 llvm::errs() <<
" #include/#include_next/#import:\n";
249 llvm::errs() <<
" " << NumEnteredSourceFiles <<
" source files entered.\n";
250 llvm::errs() <<
" " << MaxIncludeStackDepth <<
" max include stack depth\n";
251 llvm::errs() <<
" " << NumIf <<
" #if/#ifndef/#ifdef.\n";
252 llvm::errs() <<
" " << NumElse <<
" #else/#elif.\n";
253 llvm::errs() <<
" " << NumEndif <<
" #endif.\n";
254 llvm::errs() <<
" " << NumPragma <<
" #pragma.\n";
255 llvm::errs() << NumSkipped <<
" #if/#ifndef#ifdef regions skipped\n";
257 llvm::errs() << NumMacroExpanded <<
"/" << NumFnMacroExpanded <<
"/"
258 << NumBuiltinMacroExpanded <<
" obj/fn/builtin macros expanded, "
259 << NumFastMacroExpanded <<
" on the fast path.\n";
260 llvm::errs() << (NumFastTokenPaste+NumTokenPaste)
261 <<
" token paste (##) operations performed, "
262 << NumFastTokenPaste <<
" on the fast path.\n";
264 llvm::errs() <<
"\nPreprocessor Memory: " <<
getTotalMemory() <<
"B total";
266 llvm::errs() <<
"\n BumpPtr: " << BP.getTotalMemory();
267 llvm::errs() <<
"\n Macro Expanded Tokens: "
268 << llvm::capacity_in_bytes(MacroExpandedTokens);
269 llvm::errs() <<
"\n Predefines Buffer: " << Predefines.capacity();
271 llvm::errs() <<
"\n Macros: "
272 << llvm::capacity_in_bytes(CurSubmoduleState->Macros);
273 llvm::errs() <<
"\n #pragma push_macro Info: "
274 << llvm::capacity_in_bytes(PragmaPushMacroInfo);
275 llvm::errs() <<
"\n Poison Reasons: "
276 << llvm::capacity_in_bytes(PoisonReasons);
277 llvm::errs() <<
"\n Comment Handlers: "
278 << llvm::capacity_in_bytes(CommentHandlers) <<
"\n";
283 if (IncludeExternalMacros && ExternalSource &&
284 !ReadMacrosFromExternalSource) {
285 ReadMacrosFromExternalSource =
true;
291 CurSubmoduleState->Macros.insert(std::make_pair(Macro.II, MacroState()));
293 return CurSubmoduleState->Macros.begin();
297 return BP.getTotalMemory()
298 + llvm::capacity_in_bytes(MacroExpandedTokens)
299 + Predefines.capacity()
302 + llvm::capacity_in_bytes(CurSubmoduleState->Macros)
303 + llvm::capacity_in_bytes(PragmaPushMacroInfo)
304 + llvm::capacity_in_bytes(PoisonReasons)
305 + llvm::capacity_in_bytes(CommentHandlers);
310 if (IncludeExternalMacros && ExternalSource &&
311 !ReadMacrosFromExternalSource) {
312 ReadMacrosFromExternalSource =
true;
316 return CurSubmoduleState->Macros.end();
323 std::equal(Tokens.begin(), Tokens.end(), MI->
tokens_begin());
330 StringRef BestSpelling;
334 Def = I->second.findDirectiveAtLoc(Loc,
SourceMgr);
346 BestLocation = Location;
347 BestSpelling = I->first->getName();
355 CurLexerKind = CLK_Lexer;
356 else if (CurPTHLexer)
357 CurLexerKind = CLK_PTHLexer;
358 else if (CurTokenLexer)
359 CurLexerKind = CLK_TokenLexer;
361 CurLexerKind = CLK_CachingLexer;
365 unsigned CompleteLine,
366 unsigned CompleteColumn) {
368 assert(CompleteLine && CompleteColumn &&
"Starts from 1:1");
369 assert(!CodeCompletionFile &&
"Already set");
371 using llvm::MemoryBuffer;
374 bool Invalid =
false;
380 const char *
Position = Buffer->getBufferStart();
383 if (*Position !=
'\r' && *Position !=
'\n')
387 if ((Position[1] ==
'\r' || Position[1] ==
'\n') &&
388 Position[0] != Position[1])
395 Position += CompleteColumn - 1;
399 if (SkipMainFilePreamble.first &&
401 if (Position - Buffer->getBufferStart() < SkipMainFilePreamble.first)
402 Position = Buffer->getBufferStart() + SkipMainFilePreamble.first;
405 if (Position > Buffer->getBufferEnd())
406 Position = Buffer->getBufferEnd();
408 CodeCompletionFile = File;
409 CodeCompletionOffset = Position - Buffer->getBufferStart();
411 std::unique_ptr<MemoryBuffer> NewBuffer =
412 MemoryBuffer::getNewUninitMemBuffer(Buffer->getBufferSize() + 1,
413 Buffer->getBufferIdentifier());
414 char *NewBuf =
const_cast<char*
>(NewBuffer->getBufferStart());
415 char *NewPos = std::copy(Buffer->getBufferStart(),
Position, NewBuf);
417 std::copy(Position, Buffer->getBufferEnd(), NewPos+1);
434 bool *Invalid)
const {
436 if (Tok.
isNot(tok::raw_identifier) && !Tok.
hasUCN()) {
439 return II->getName();
446 const char *Ptr = Buffer.data();
448 return StringRef(Ptr, Len);
460 SourceLocation Loc = ScratchBuf->getToken(Str.data(), Str.size(), DestPtr);
462 if (ExpansionLocStart.
isValid())
464 ExpansionLocEnd, Str.size());
468 if (Tok.
is(tok::raw_identifier))
492 assert(NumEnteredSourceFiles == 0 &&
"Cannot reenter the main file!");
503 if (SkipMainFilePreamble.first > 0)
504 CurLexer->SkipBytes(SkipMainFilePreamble.first,
505 SkipMainFilePreamble.second);
514 std::unique_ptr<llvm::MemoryBuffer> SB =
515 llvm::MemoryBuffer::getMemBufferCopy(Predefines,
"<built-in>");
516 assert(SB &&
"Cannot create predefined source buffer");
518 assert(!FID.
isInvalid() &&
"Could not create FileID for predefines?");
519 setPredefinesFileID(FID);
528 Callbacks->EndOfMainFile();
539 assert(!Identifier.
getRawIdentifier().empty() &&
"No raw identifier data!");
549 StringRef CleanedStr =
getSpelling(Identifier, IdentifierBuffer);
551 if (Identifier.
hasUCN()) {
562 Identifier.
setKind(II->getTokenID());
568 PoisonReasons[II] = DiagID;
572 assert(Ident__exception_code && Ident__exception_info);
573 assert(Ident___exception_code && Ident___exception_info);
587 "Can't handle identifiers without identifier info!");
588 llvm::DenseMap<IdentifierInfo*,unsigned>::const_iterator it =
590 if(it == PoisonReasons.end())
591 Diag(Identifier, diag::err_pp_used_poisoned_id);
602 if (LangOpts.CPlusPlus)
603 return llvm::StringSwitch<diag::kind>(II.
getName())
605 .Case(#NAME, diag::warn_cxx11_keyword)
606 #include "clang/Basic/TokenKinds.def"
610 "Keyword not known to come from a newer Standard or proposed Standard");
623 "Can't handle identifiers without identifier info!");
632 if (II.isOutOfDate()) {
633 bool CurrentIsPoisoned =
false;
634 if (&II == Ident__VA_ARGS__)
635 CurrentIsPoisoned = Ident__VA_ARGS__->
isPoisoned();
638 Identifier.
setKind(II.getTokenID());
640 if (&II == Ident__VA_ARGS__)
641 II.setIsPoisoned(CurrentIsPoisoned);
646 if (II.isPoisoned() && CurPPLexer) {
652 auto *MI = MD.getMacroInfo();
653 assert(MI &&
"macro definition with no macro info?");
654 if (!DisableMacroExpansion) {
658 if (!MI->isFunctionLike() || isNextPPTokenLParen())
659 return HandleMacroExpandedIdentifier(Identifier, MD);
665 if (MI->isObjectLike() || isNextPPTokenLParen())
666 Diag(Identifier, diag::pp_disabled_macro_expansion);
676 if (II.isFutureCompatKeyword() && !DisableMacroExpansion) {
680 II.setIsFutureCompatKeyword(
false);
686 if (II.isCPlusPlusOperatorKeyword())
693 if (II.isExtensionToken() && !DisableMacroExpansion)
694 Diag(Identifier, diag::ext_token_used);
702 if (LastTokenWasAt && II.isModulesImport() && !InMacroArgs &&
703 !DisableMacroExpansion &&
705 CurLexerKind != CLK_CachingLexer) {
707 ModuleImportPath.clear();
708 ModuleImportExpectsIdentifier =
true;
709 CurLexerKind = CLK_LexAfterModuleImport;
718 switch (CurLexerKind) {
720 ReturnedToken = CurLexer->Lex(Result);
723 ReturnedToken = CurPTHLexer->Lex(Result);
726 ReturnedToken = CurTokenLexer->Lex(Result);
728 case CLK_CachingLexer:
730 ReturnedToken =
true;
732 case CLK_LexAfterModuleImport:
734 ReturnedToken =
true;
737 }
while (!ReturnedToken);
739 LastTokenWasAt = Result.
is(tok::at);
758 if (ModuleImportExpectsIdentifier && Result.
getKind() == tok::identifier) {
763 ModuleImportExpectsIdentifier =
false;
764 CurLexerKind = CLK_LexAfterModuleImport;
770 if (!ModuleImportExpectsIdentifier && Result.
getKind() == tok::period) {
771 ModuleImportExpectsIdentifier =
true;
772 CurLexerKind = CLK_LexAfterModuleImport;
777 if (!ModuleImportPath.empty()) {
778 Module *Imported =
nullptr;
780 Imported = TheModuleLoader.
loadModule(ModuleImportLoc,
788 Callbacks->moduleImport(ModuleImportLoc, ModuleImportPath, Imported);
793 CurSubmoduleState->VisibleModules.setVisible(
798 Diag(ModuleImportLoc, diag::warn_module_conflict)
799 << Path[0]->getFullModuleName()
800 << Conflict->getFullModuleName()
805 if (!BuildingSubmoduleStack.empty() && M != BuildingSubmoduleStack.back().M)
806 BuildingSubmoduleStack.back().M->Imports.insert(M);
810 const char *DiagnosticTag,
811 bool AllowMacroExpansion) {
813 if (Result.
isNot(tok::string_literal)) {
814 Diag(Result, diag::err_expected_string_literal)
815 << 0 << DiagnosticTag;
822 StrToks.push_back(Result);
825 Diag(Result, diag::err_invalid_string_udl);
827 if (AllowMacroExpansion)
831 }
while (Result.
is(tok::string_literal));
835 assert(Literal.
isAscii() &&
"Didn't allow wide strings in");
841 Diag(StrToks[0].getLocation(), diag::err_expected_string_literal)
842 << 0 << DiagnosticTag;
851 assert(Tok.
is(tok::numeric_constant));
853 bool NumberInvalid =
false;
854 StringRef Spelling =
getSpelling(Tok, IntegerBuffer, &NumberInvalid);
858 if (Literal.hadError || !Literal.isIntegerLiteral() || Literal.hasUDSuffix())
860 llvm::APInt APVal(64, 0);
861 if (Literal.GetIntegerValue(APVal))
864 Value = APVal.getLimitedValue();
869 assert(Handler &&
"NULL comment handler");
870 assert(std::find(CommentHandlers.begin(), CommentHandlers.end(), Handler) ==
871 CommentHandlers.end() &&
"Comment handler already registered");
872 CommentHandlers.push_back(Handler);
876 std::vector<CommentHandler *>::iterator Pos
877 = std::find(CommentHandlers.begin(), CommentHandlers.end(), Handler);
878 assert(Pos != CommentHandlers.end() &&
"Comment handler not registered");
879 CommentHandlers.erase(Pos);
883 bool AnyPendingTokens =
false;
884 for (std::vector<CommentHandler *>::iterator H = CommentHandlers.begin(),
885 HEnd = CommentHandlers.end();
887 if ((*H)->HandleComment(*
this, Comment))
888 AnyPendingTokens =
true;
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens. If there are multiple macro...
bool isAtStartOfLine() const
SourceManager & getSourceManager() const
bool isPoisoned() const
Return true if this token has been poisoned.
void FinalizeForModelFile()
Cleanup after model file parsing.
bool isLoadedFileID(FileID FID) const
Returns true if FID came from a PCH/Module.
Defines the clang::FileManager interface and associated types.
Defines the SourceManager interface.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
static const Builtin::Info BuiltinInfo[]
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
Defines the FileSystemStatCache interface.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
void EndSourceFile()
Inform the preprocessor callbacks that processing is complete.
bool isObjectLike() const
virtual void CodeCompleteNaturalLanguage()
Callback invoked when performing code completion in a part of the file where we expect natural langua...
Defines the clang::MacroInfo and clang::MacroDirective classes.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
A description of the current definition of a macro.
void LexAfterModuleImport(Token &Result)
Lex a token following the 'import' contextual keyword.
bool hasUCN() const
Returns true if this token contains a universal character name.
void setFlag(TokenFlags Flag)
Set the specified flag.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
MacroMap::const_iterator macro_iterator
void setCodeCompletionReached()
Note that we hit the code-completion point.
void createPreprocessingRecord()
Create a new preprocessing record, which will keep track of all macro expansions, macro definitions...
bool parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value)
Parses a simple integer literal to get its numeric value. Floating point literals and user defined li...
void setPTHManager(PTHManager *pm)
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
void DumpToken(const Token &Tok, bool DumpFlags=false) const
Print the token to stderr, used for debugging.
void SetPoisonReason(IdentifierInfo *II, unsigned DiagID)
Specifies the reason for poisoning an identifier.
Represents a macro directive exported by a module.
void setRawIdentifierData(const char *Ptr)
SourceLocation getLocation() const
virtual ~ExternalPreprocessorSource()
const LangOptions & getLangOpts() const
void setKind(tok::TokenKind K)
void removeCommentHandler(CommentHandler *Handler)
Remove the specified comment handler.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Describes a module or submodule.
bool SetCodeCompletionPoint(const FileEntry *File, unsigned Line, unsigned Column)
Specify the point at which code-completion will be performed.
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
bool getCommentRetentionState() const
Concrete class used by the front-end to report problems and issues.
HeaderSearch & getHeaderSearchInfo() const
bool isFutureCompatKeyword() const
tokens_iterator tokens_begin() const
void dump(const SourceManager &SM) const
tok::TokenKind getKind() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
void recomputeCurLexerKind()
Recompute the current lexer kind based on the CurLexer/CurPTHLexer/ CurTokenLexer pointers...
StringRef getRawIdentifier() const
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
Provides lookups to, and iteration over, IdentiferInfo objects.
Exposes information about the current target.
StringRef getName() const
Return the actual identifier string.
void makeModuleVisible(Module *M, SourceLocation Loc)
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
virtual void ReadDefinedMacros()=0
Read the set of macros defined by this external macro source.
void EnterMainSourceFile()
Enter the specified FileID as the main source file, which implicitly adds the builtin defines etc...
Defines the clang::Preprocessor interface.
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix. ...
void setIsPoisoned(bool Value=true)
static bool MacroDefinitionEquals(const MacroInfo *MI, ArrayRef< TokenValue > Tokens)
Compares macro tokens with a specified token value sequence.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isNot(tok::TokenKind K) const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
SourceLocation createExpansionLoc(SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, int LoadedID=0, unsigned LoadedOffset=0)
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be re...
Preprocessor(IntrusiveRefCntPtr< PreprocessorOptions > PPOpts, DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup=nullptr, bool OwnsHeaderSearch=false, TranslationUnitKind TUKind=TU_Complete)
void overrideFileContents(const FileEntry *SourceFile, llvm::MemoryBuffer *Buffer, bool DoNotFree)
Override the contents of the given source file by providing an already-allocated buffer.
size_t getTotalMemory() const
void addStatCache(std::unique_ptr< FileSystemStatCache > statCache, bool AtBeginning=false)
Installs the provided FileSystemStatCache object within the FileManager.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
void setLength(unsigned Len)
StringRef GetString() const
bool isValid() const
Return true if this is a valid SourceLocation object.
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
macro_iterator macro_end(bool IncludeExternalMacros=true) const
All of the names in this module are hidden.
Cached information about one file (either on disk or in the virtual file system). ...
void setIdentifierInfo(IdentifierInfo *II)
void Lex(Token &Result)
Lex the next token for this preprocessor.
llvm::MemoryBuffer * getMemoryBufferForFile(const FileEntry *File, bool *Invalid=nullptr)
Retrieve the memory buffer associated with the given file.
const Token & getReplacementToken(unsigned Tok) const
FileID getMainFileID() const
Returns the FileID of the main source file.
bool is(tok::TokenKind K) const
void expandUCNs(SmallVectorImpl< char > &Buf, StringRef Input)
Copy characters from Input to Buf, expanding any UCNs.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
static diag::kind getFutureCompatDiagKind(const IdentifierInfo &II, const LangOptions &LangOpts)
Returns a diagnostic message kind for reporting a future keyword as appropriate for the identifier an...
void addCommentHandler(CommentHandler *Handler)
Add the specified comment handler to the preprocessor.
MacroInfo * getMacroInfo()
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
void CodeCompleteNaturalLanguage()
Hook used by the lexer to invoke the "natural language" code completion point.
Abstract interface for a module loader.
void PoisonSEHIdentifiers(bool Poison=true)
void setLiteralData(const char *Ptr)
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
Encapsulates the data about a macro definition (e.g. its tokens).
bool HandleIdentifier(Token &Identifier)
Callback invoked when the lexer reads an identifier and has filled in the tokens IdentifierInfo membe...
bool FinishLexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Complete the lexing of a string literal where the first token has already been lexed (see LexStringLi...
virtual void updateOutOfDateIdentifier(IdentifierInfo &II)=0
Update an out-of-date identifier.
void CreateString(StringRef Str, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation())
Plop the specified string into a scratch buffer and set the specified token's location and length to ...
void InitializeForModelFile()
Initialize the preprocessor to parse a model file.
void HandlePoisonedIdentifier(Token &Tok)
Display reason for poisoned identifier.
#define CXX11_KEYWORD(NAME, FLAGS)
bool HandleComment(Token &Token, SourceRange Comment)
void DumpMacro(const MacroInfo &MI) const
TranslationUnitKind
Describes the kind of translation unit being processed.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
void Initialize(const TargetInfo &Target)
Initialize the preprocessor using information about the target.
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
Defines the clang::TargetInfo interface.
IdentifierInfo * LookUpIdentifierInfo(Token &Identifier) const
unsigned getLength() const
void DumpLocation(SourceLocation Loc) const
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
bool isExpandDisabled() const
Return true if this identifier token should never be expanded in the future, due to C99 6...
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
This class handles loading and caching of source files into memory.
virtual ~CodeCompletionHandler()
bool EnterSourceFile(FileID CurFileID, const DirectoryLookup *Dir, SourceLocation Loc)
Add a source file to the top of the include stack and start lexing tokens from it instead of the curr...
IdentifierInfo * getIdentifierInfo() const