Preprocessor.h revision e3d5e3ae5bd8028774f07d7c3751d4db82118942
1//===--- Preprocessor.h - C Language Family Preprocessor --------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the Preprocessor interface. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_LEX_PREPROCESSOR_H 15#define LLVM_CLANG_LEX_PREPROCESSOR_H 16 17#include "clang/Lex/Lexer.h" 18#include "clang/Lex/PPCallbacks.h" 19#include "clang/Lex/TokenLexer.h" 20#include "clang/Basic/IdentifierTable.h" 21#include "clang/Basic/SourceLocation.h" 22#include "llvm/ADT/DenseMap.h" 23 24namespace clang { 25 26class SourceManager; 27class FileManager; 28class FileEntry; 29class HeaderSearch; 30class PragmaNamespace; 31class PragmaHandler; 32class ScratchBuffer; 33class TargetInfo; 34class PPCallbacks; 35class DirectoryLookup; 36 37/// Preprocessor - This object engages in a tight little dance with the lexer to 38/// efficiently preprocess tokens. Lexers know only about tokens within a 39/// single source file, and don't know anything about preprocessor-level issues 40/// like the #include stack, token expansion, etc. 41/// 42class Preprocessor { 43 Diagnostic &Diags; 44 const LangOptions &Features; 45 TargetInfo &Target; 46 FileManager &FileMgr; 47 SourceManager &SourceMgr; 48 ScratchBuffer *ScratchBuf; 49 HeaderSearch &HeaderInfo; 50 51 /// Identifiers for builtin macros and other builtins. 52 IdentifierInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__ 53 IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ 54 IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ 55 IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ 56 IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ 57 IdentifierInfo *Ident_Pragma, *Ident__VA_ARGS__; // _Pragma, __VA_ARGS__ 58 59 SourceLocation DATELoc, TIMELoc; 60 61 enum { 62 /// MaxIncludeStackDepth - Maximum depth of #includes. 63 MaxAllowedIncludeStackDepth = 200 64 }; 65 66 // State that is set before the preprocessor begins. 67 bool KeepComments : 1; 68 bool KeepMacroComments : 1; 69 70 // State that changes while the preprocessor runs: 71 bool DisableMacroExpansion : 1; // True if macro expansion is disabled. 72 bool InMacroArgs : 1; // True if parsing fn macro invocation args. 73 74 /// Identifiers - This is mapping/lookup information for all identifiers in 75 /// the program, including program keywords. 76 IdentifierTable Identifiers; 77 78 /// Selectors - This table contains all the selectors in the program. Unlike 79 /// IdentifierTable above, this table *isn't* populated by the preprocessor. 80 /// It is declared/instantiated here because it's role/lifetime is 81 /// conceptually similar the IdentifierTable. In addition, the current control 82 /// flow (in clang::ParseAST()), make it convenient to put here. 83 /// FIXME: Make sure the lifetime of Identifiers/Selectors *isn't* tied to 84 /// the lifetime fo the preprocessor. 85 SelectorTable Selectors; 86 87 /// PragmaHandlers - This tracks all of the pragmas that the client registered 88 /// with this preprocessor. 89 PragmaNamespace *PragmaHandlers; 90 91 /// CurLexer - This is the current top of the stack that we're lexing from if 92 /// not expanding a macro. One of CurLexer and CurTokenLexer must be null. 93 Lexer *CurLexer; 94 95 /// CurLookup - The DirectoryLookup structure used to find the current 96 /// FileEntry, if CurLexer is non-null and if applicable. This allows us to 97 /// implement #include_next and find directory-specific properties. 98 const DirectoryLookup *CurDirLookup; 99 100 /// CurTokenLexer - This is the current macro we are expanding, if we are 101 /// expanding a macro. One of CurLexer and CurTokenLexer must be null. 102 TokenLexer *CurTokenLexer; 103 104 /// IncludeMacroStack - This keeps track of the stack of files currently 105 /// #included, and macros currently being expanded from, not counting 106 /// CurLexer/CurTokenLexer. 107 struct IncludeStackInfo { 108 Lexer *TheLexer; 109 const DirectoryLookup *TheDirLookup; 110 TokenLexer *TheTokenLexer; 111 IncludeStackInfo(Lexer *L, const DirectoryLookup *D, TokenLexer *TL) 112 : TheLexer(L), TheDirLookup(D), TheTokenLexer(TL) { 113 } 114 }; 115 std::vector<IncludeStackInfo> IncludeMacroStack; 116 117 /// Callbacks - These are actions invoked when some preprocessor activity is 118 /// encountered (e.g. a file is #included, etc). 119 PPCallbacks *Callbacks; 120 121 /// Macros - For each IdentifierInfo with 'HasMacro' set, we keep a mapping 122 /// to the actual definition of the macro. 123 llvm::DenseMap<IdentifierInfo*, MacroInfo*> Macros; 124 125 // Various statistics we track for performance analysis. 126 unsigned NumDirectives, NumIncluded, NumDefined, NumUndefined, NumPragma; 127 unsigned NumIf, NumElse, NumEndif; 128 unsigned NumEnteredSourceFiles, MaxIncludeStackDepth; 129 unsigned NumMacroExpanded, NumFnMacroExpanded, NumBuiltinMacroExpanded; 130 unsigned NumFastMacroExpanded, NumTokenPaste, NumFastTokenPaste; 131 unsigned NumSkipped; 132 133 /// Predefines - This string is the predefined macros that preprocessor 134 /// should use from the command line etc. 135 std::string Predefines; 136 137 /// TokenLexerCache - Cache macro expanders to reduce malloc traffic. 138 enum { TokenLexerCacheSize = 8 }; 139 unsigned NumCachedTokenLexers; 140 TokenLexer *TokenLexerCache[TokenLexerCacheSize]; 141 142 /// PeekedToken - Cache the token that was retrieved through LookNext(). 143 /// This is a valid token (its Location is valid) when LookNext() is 144 /// called and gets invalid again when it is "consumed" by Lex(). 145 Token PeekedToken; 146public: 147 Preprocessor(Diagnostic &diags, const LangOptions &opts, TargetInfo &target, 148 SourceManager &SM, HeaderSearch &Headers); 149 ~Preprocessor(); 150 151 Diagnostic &getDiagnostics() const { return Diags; } 152 const LangOptions &getLangOptions() const { return Features; } 153 TargetInfo &getTargetInfo() const { return Target; } 154 FileManager &getFileManager() const { return FileMgr; } 155 SourceManager &getSourceManager() const { return SourceMgr; } 156 HeaderSearch &getHeaderSearchInfo() const { return HeaderInfo; } 157 158 IdentifierTable &getIdentifierTable() { return Identifiers; } 159 SelectorTable &getSelectorTable() { return Selectors; } 160 161 inline FullSourceLoc getFullLoc(SourceLocation Loc) const { 162 return FullSourceLoc(Loc, getSourceManager()); 163 } 164 165 /// SetCommentRetentionState - Control whether or not the preprocessor retains 166 /// comments in output. 167 void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments) { 168 this->KeepComments = KeepComments | KeepMacroComments; 169 this->KeepMacroComments = KeepMacroComments; 170 } 171 172 bool getCommentRetentionState() const { return KeepComments; } 173 174 /// isCurrentLexer - Return true if we are lexing directly from the specified 175 /// lexer. 176 bool isCurrentLexer(const Lexer *L) const { 177 return CurLexer == L; 178 } 179 180 /// getCurrentLexer - Return the current file lexer being lexed from. Note 181 /// that this ignores any potentially active macro expansions and _Pragma 182 /// expansions going on at the time. 183 Lexer *getCurrentFileLexer() const; 184 185 /// getPPCallbacks/setPPCallbacks - Accessors for preprocessor callbacks. 186 /// Note that this class takes ownership of any PPCallbacks object given to 187 /// it. 188 PPCallbacks *getPPCallbacks() const { return Callbacks; } 189 void setPPCallbacks(PPCallbacks *C) { 190 delete Callbacks; 191 Callbacks = C; 192 } 193 194 /// getMacroInfo - Given an identifier, return the MacroInfo it is #defined to 195 /// or null if it isn't #define'd. 196 MacroInfo *getMacroInfo(IdentifierInfo *II) const { 197 return II->hasMacroDefinition() ? Macros.find(II)->second : 0; 198 } 199 200 /// setMacroInfo - Specify a macro for this identifier. 201 /// 202 void setMacroInfo(IdentifierInfo *II, MacroInfo *MI); 203 204 const std::string &getPredefines() const { return Predefines; } 205 /// setPredefines - Set the predefines for this Preprocessor. These 206 /// predefines are automatically injected when parsing the main file. 207 void setPredefines(const char *P) { Predefines = P; } 208 void setPredefines(const std::string &P) { Predefines = P; } 209 210 /// getIdentifierInfo - Return information about the specified preprocessor 211 /// identifier token. The version of this method that takes two character 212 /// pointers is preferred unless the identifier is already available as a 213 /// string (this avoids allocation and copying of memory to construct an 214 /// std::string). 215 IdentifierInfo *getIdentifierInfo(const char *NameStart, 216 const char *NameEnd) { 217 return &Identifiers.get(NameStart, NameEnd); 218 } 219 IdentifierInfo *getIdentifierInfo(const char *NameStr) { 220 return getIdentifierInfo(NameStr, NameStr+strlen(NameStr)); 221 } 222 223 /// AddPragmaHandler - Add the specified pragma handler to the preprocessor. 224 /// If 'Namespace' is non-null, then it is a token required to exist on the 225 /// pragma line before the pragma string starts, e.g. "STDC" or "GCC". 226 void AddPragmaHandler(const char *Namespace, PragmaHandler *Handler); 227 228 /// EnterMainSourceFile - Enter the specified FileID as the main source file, 229 /// which implicitly adds the builtin defines etc. 230 void EnterMainSourceFile(); 231 232 /// EnterSourceFile - Add a source file to the top of the include stack and 233 /// start lexing tokens from it instead of the current buffer. If isMainFile 234 /// is true, this is the main file for the translation unit. 235 void EnterSourceFile(unsigned CurFileID, const DirectoryLookup *Dir); 236 237 /// EnterMacro - Add a Macro to the top of the include stack and start lexing 238 /// tokens from it instead of the current buffer. Args specifies the 239 /// tokens input to a function-like macro. 240 void EnterMacro(Token &Identifier, MacroArgs *Args); 241 242 /// EnterTokenStream - Add a "macro" context to the top of the include stack, 243 /// which will cause the lexer to start returning the specified tokens. 244 /// 245 /// If DisableMacroExpansion is true, tokens lexed from the token stream will 246 /// not be subject to further macro expansion. Otherwise, these tokens will 247 /// be re-macro-expanded when/if expansion is enabled. 248 /// 249 /// If OwnsTokens is false, this method assumes that the specified stream of 250 /// tokens has a permanent owner somewhere, so they do not need to be copied. 251 /// If it is true, it assumes the array of tokens is allocated with new[] and 252 /// must be freed. 253 /// 254 void EnterTokenStream(const Token *Toks, unsigned NumToks, 255 bool DisableMacroExpansion, bool OwnsTokens); 256 257 /// RemoveTopOfLexerStack - Pop the current lexer/macro exp off the top of the 258 /// lexer stack. This should only be used in situations where the current 259 /// state of the top-of-stack lexer is known. 260 void RemoveTopOfLexerStack(); 261 262 /// Lex - To lex a token from the preprocessor, just pull a token from the 263 /// current lexer or macro object. 264 void Lex(Token &Result) { 265 if (CurLexer) 266 CurLexer->Lex(Result); 267 else if (CurTokenLexer) 268 CurTokenLexer->Lex(Result); 269 else { 270 // We have a peeked token that hasn't been consumed yet. 271 Result = PeekedToken; 272 ConsumedPeekedToken(); 273 } 274 } 275 276 /// LexNonComment - Lex a token. If it's a comment, keep lexing until we get 277 /// something not a comment. This is useful in -E -C mode where comments 278 /// would foul up preprocessor directive handling. 279 void LexNonComment(Token &Result) { 280 do 281 Lex(Result); 282 while (Result.getKind() == tok::comment); 283 } 284 285 /// LexUnexpandedToken - This is just like Lex, but this disables macro 286 /// expansion of identifier tokens. 287 void LexUnexpandedToken(Token &Result) { 288 // Disable macro expansion. 289 bool OldVal = DisableMacroExpansion; 290 DisableMacroExpansion = true; 291 // Lex the token. 292 Lex(Result); 293 294 // Reenable it. 295 DisableMacroExpansion = OldVal; 296 } 297 298 /// LookAhead - This peeks ahead N tokens and returns that token without 299 /// consuming any tokens. LookAhead(0) returns the next token that would be 300 /// returned by Lex(), LookAhead(1) returns the token after it, etc. This 301 /// returns normal tokens after phase 5. As such, it is equivalent to using 302 /// 'Lex', not 'LexUnexpandedToken'. 303 /// 304 /// NOTE: is a relatively expensive method, so it should not be used in common 305 /// code paths if possible! 306 /// 307 Token LookAhead(unsigned N); 308 309 /// LookNext - Returns the next token that would be returned by Lex() without 310 /// consuming it. 311 const Token &LookNext() { 312 if (PeekedToken.getLocation().isInvalid()) { 313 // We don't have a peeked token that hasn't been consumed yet. 314 // Peek it now. 315 PeekToken(); 316 } 317 return PeekedToken; 318 } 319 320private: 321 /// PeekToken - Lexes one token into PeekedToken and pushes CurLexer, 322 /// CurLexerToken into the IncludeMacroStack before setting them to null. 323 void PeekToken(); 324 325 /// ConsumedPeekedToken - Called when Lex() is about to return the PeekedToken 326 /// and have it "consumed". 327 void ConsumedPeekedToken(); 328public: 329 330 /// Diag - Forwarding function for diagnostics. This emits a diagnostic at 331 /// the specified Token's location, translating the token's start 332 /// position in the current buffer into a SourcePosition object for rendering. 333 void Diag(SourceLocation Loc, unsigned DiagID); 334 void Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg); 335 void Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, 336 const SourceRange &R1, const SourceRange &R2); 337 void Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R); 338 void Diag(SourceLocation Loc, unsigned DiagID, const SourceRange &R1, 339 const SourceRange &R2); 340 void Diag(const Token &Tok, unsigned DiagID) { 341 Diag(Tok.getLocation(), DiagID); 342 } 343 void Diag(const Token &Tok, unsigned DiagID, const std::string &Msg) { 344 Diag(Tok.getLocation(), DiagID, Msg); 345 } 346 347 /// getSpelling() - Return the 'spelling' of the Tok token. The spelling of a 348 /// token is the characters used to represent the token in the source file 349 /// after trigraph expansion and escaped-newline folding. In particular, this 350 /// wants to get the true, uncanonicalized, spelling of things like digraphs 351 /// UCNs, etc. 352 std::string getSpelling(const Token &Tok) const; 353 354 /// getSpelling - This method is used to get the spelling of a token into a 355 /// preallocated buffer, instead of as an std::string. The caller is required 356 /// to allocate enough space for the token, which is guaranteed to be at least 357 /// Tok.getLength() bytes long. The length of the actual result is returned. 358 /// 359 /// Note that this method may do two possible things: it may either fill in 360 /// the buffer specified with characters, or it may *change the input pointer* 361 /// to point to a constant buffer with the data already in it (avoiding a 362 /// copy). The caller is not allowed to modify the returned buffer pointer 363 /// if an internal buffer is returned. 364 unsigned getSpelling(const Token &Tok, const char *&Buffer) const; 365 366 367 /// CreateString - Plop the specified string into a scratch buffer and return 368 /// a location for it. If specified, the source location provides a source 369 /// location for the token. 370 SourceLocation CreateString(const char *Buf, unsigned Len, 371 SourceLocation SourceLoc = SourceLocation()); 372 373 /// DumpToken - Print the token to stderr, used for debugging. 374 /// 375 void DumpToken(const Token &Tok, bool DumpFlags = false) const; 376 void DumpLocation(SourceLocation Loc) const; 377 void DumpMacro(const MacroInfo &MI) const; 378 379 /// AdvanceToTokenCharacter - Given a location that specifies the start of a 380 /// token, return a new location that specifies a character within the token. 381 SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart,unsigned Char); 382 383 /// IncrementPasteCounter - Increment the counters for the number of token 384 /// paste operations performed. If fast was specified, this is a 'fast paste' 385 /// case we handled. 386 /// 387 void IncrementPasteCounter(bool isFast) { 388 if (isFast) 389 ++NumFastTokenPaste; 390 else 391 ++NumTokenPaste; 392 } 393 394 void PrintStats(); 395 396 /// HandleMicrosoftCommentPaste - When the macro expander pastes together a 397 /// comment (/##/) in microsoft mode, this method handles updating the current 398 /// state, returning the token on the next source line. 399 void HandleMicrosoftCommentPaste(Token &Tok); 400 401 //===--------------------------------------------------------------------===// 402 // Preprocessor callback methods. These are invoked by a lexer as various 403 // directives and events are found. 404 405 /// LookUpIdentifierInfo - Given a tok::identifier token, look up the 406 /// identifier information for the token and install it into the token. 407 IdentifierInfo *LookUpIdentifierInfo(Token &Identifier, 408 const char *BufPtr = 0); 409 410 /// HandleIdentifier - This callback is invoked when the lexer reads an 411 /// identifier and has filled in the tokens IdentifierInfo member. This 412 /// callback potentially macro expands it or turns it into a named token (like 413 /// 'for'). 414 void HandleIdentifier(Token &Identifier); 415 416 417 /// HandleEndOfFile - This callback is invoked when the lexer hits the end of 418 /// the current file. This either returns the EOF token and returns true, or 419 /// pops a level off the include stack and returns false, at which point the 420 /// client should call lex again. 421 bool HandleEndOfFile(Token &Result, bool isEndOfMacro = false); 422 423 /// HandleEndOfTokenLexer - This callback is invoked when the current 424 /// TokenLexer hits the end of its token stream. 425 bool HandleEndOfTokenLexer(Token &Result); 426 427 /// HandleDirective - This callback is invoked when the lexer sees a # token 428 /// at the start of a line. This consumes the directive, modifies the 429 /// lexer/preprocessor state, and advances the lexer(s) so that the next token 430 /// read is the correct one. 431 void HandleDirective(Token &Result); 432 433 /// CheckEndOfDirective - Ensure that the next token is a tok::eom token. If 434 /// not, emit a diagnostic and consume up until the eom. 435 void CheckEndOfDirective(const char *Directive); 436private: 437 /// isInPrimaryFile - Return true if we're in the top-level file, not in a 438 /// #include. 439 bool isInPrimaryFile() const; 440 441 /// DiscardUntilEndOfDirective - Read and discard all tokens remaining on the 442 /// current line until the tok::eom token is found. 443 void DiscardUntilEndOfDirective(); 444 445 /// ReadMacroName - Lex and validate a macro name, which occurs after a 446 /// #define or #undef. This emits a diagnostic, sets the token kind to eom, 447 /// and discards the rest of the macro line if the macro name is invalid. 448 void ReadMacroName(Token &MacroNameTok, char isDefineUndef = 0); 449 450 /// ReadMacroDefinitionArgList - The ( starting an argument list of a macro 451 /// definition has just been read. Lex the rest of the arguments and the 452 /// closing ), updating MI with what we learn. Return true if an error occurs 453 /// parsing the arg list. 454 bool ReadMacroDefinitionArgList(MacroInfo *MI); 455 456 /// SkipExcludedConditionalBlock - We just read a #if or related directive and 457 /// decided that the subsequent tokens are in the #if'd out portion of the 458 /// file. Lex the rest of the file, until we see an #endif. If 459 /// FoundNonSkipPortion is true, then we have already emitted code for part of 460 /// this #if directive, so #else/#elif blocks should never be entered. If 461 /// FoundElse is false, then #else directives are ok, if not, then we have 462 /// already seen one so a #else directive is a duplicate. When this returns, 463 /// the caller can lex the first valid token. 464 void SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, 465 bool FoundNonSkipPortion, bool FoundElse); 466 467 /// EvaluateDirectiveExpression - Evaluate an integer constant expression that 468 /// may occur after a #if or #elif directive and return it as a bool. If the 469 /// expression is equivalent to "!defined(X)" return X in IfNDefMacro. 470 bool EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro); 471 472 /// RegisterBuiltinPragmas - Install the standard preprocessor pragmas: 473 /// #pragma GCC poison/system_header/dependency and #pragma once. 474 void RegisterBuiltinPragmas(); 475 476 /// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the 477 /// identifier table. 478 void RegisterBuiltinMacros(); 479 IdentifierInfo *RegisterBuiltinMacro(const char *Name); 480 481 /// HandleMacroExpandedIdentifier - If an identifier token is read that is to 482 /// be expanded as a macro, handle it and return the next token as 'Tok'. If 483 /// the macro should not be expanded return true, otherwise return false. 484 bool HandleMacroExpandedIdentifier(Token &Tok, MacroInfo *MI); 485 486 /// isNextPPTokenLParen - Determine whether the next preprocessor token to be 487 /// lexed is a '('. If so, consume the token and return true, if not, this 488 /// method should have no observable side-effect on the lexed tokens. 489 bool isNextPPTokenLParen(); 490 491 /// ReadFunctionLikeMacroArgs - After reading "MACRO(", this method is 492 /// invoked to read all of the formal arguments specified for the macro 493 /// invocation. This returns null on error. 494 MacroArgs *ReadFunctionLikeMacroArgs(Token &MacroName, MacroInfo *MI); 495 496 /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded 497 /// as a builtin macro, handle it and return the next token as 'Tok'. 498 void ExpandBuiltinMacro(Token &Tok); 499 500 /// Handle_Pragma - Read a _Pragma directive, slice it up, process it, then 501 /// return the first token after the directive. The _Pragma token has just 502 /// been read into 'Tok'. 503 void Handle_Pragma(Token &Tok); 504 505 506 /// EnterSourceFileWithLexer - Add a lexer to the top of the include stack and 507 /// start lexing tokens from it instead of the current buffer. 508 void EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *Dir); 509 510 /// GetIncludeFilenameSpelling - Turn the specified lexer token into a fully 511 /// checked and spelled filename, e.g. as an operand of #include. This returns 512 /// true if the input filename was in <>'s or false if it were in ""'s. The 513 /// caller is expected to provide a buffer that is large enough to hold the 514 /// spelling of the filename, but is also expected to handle the case when 515 /// this method decides to use a different buffer. 516 bool GetIncludeFilenameSpelling(SourceLocation Loc, 517 const char *&BufStart, const char *&BufEnd); 518 519 /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file, 520 /// return null on failure. isAngled indicates whether the file reference is 521 /// for system #include's or not (i.e. using <> instead of ""). 522 const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd, 523 bool isAngled, const DirectoryLookup *FromDir, 524 const DirectoryLookup *&CurDir); 525 526 //===--------------------------------------------------------------------===// 527 /// Handle*Directive - implement the various preprocessor directives. These 528 /// should side-effect the current preprocessor object so that the next call 529 /// to Lex() will return the appropriate token next. 530 531 void HandleUserDiagnosticDirective(Token &Tok, bool isWarning); 532 void HandleIdentSCCSDirective(Token &Tok); 533 534 // File inclusion. 535 void HandleIncludeDirective(Token &Tok, 536 const DirectoryLookup *LookupFrom = 0, 537 bool isImport = false); 538 void HandleIncludeNextDirective(Token &Tok); 539 void HandleImportDirective(Token &Tok); 540 541 // Macro handling. 542 void HandleDefineDirective(Token &Tok); 543 void HandleUndefDirective(Token &Tok); 544 // HandleAssertDirective(Token &Tok); 545 // HandleUnassertDirective(Token &Tok); 546 547 // Conditional Inclusion. 548 void HandleIfdefDirective(Token &Tok, bool isIfndef, 549 bool ReadAnyTokensBeforeDirective); 550 void HandleIfDirective(Token &Tok, bool ReadAnyTokensBeforeDirective); 551 void HandleEndifDirective(Token &Tok); 552 void HandleElseDirective(Token &Tok); 553 void HandleElifDirective(Token &Tok); 554 555 // Pragmas. 556 void HandlePragmaDirective(); 557public: 558 void HandlePragmaOnce(Token &OnceTok); 559 void HandlePragmaMark(); 560 void HandlePragmaPoison(Token &PoisonTok); 561 void HandlePragmaSystemHeader(Token &SysHeaderTok); 562 void HandlePragmaDependency(Token &DependencyTok); 563}; 564 565/// PreprocessorFactory - A generic factory interface for lazily creating 566/// Preprocessor objects on-demand when they are needed. 567class PreprocessorFactory { 568public: 569 virtual ~PreprocessorFactory(); 570 virtual Preprocessor* CreatePreprocessor() = 0; 571}; 572 573} // end namespace clang 574 575#endif 576