diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-04 15:04:32 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-11-04 15:04:32 +0000 |
commit | 51fb8b013e7734b795139f49d3b1f77c539be20a (patch) | |
tree | 59e0e47a9831dcf0e21e547927c8ebb7e113bfd1 /include/clang/Lex | |
parent | 73490b890977362d28dd6326843a1ecae413921d (diff) | |
download | src-test2-51fb8b013e7734b795139f49d3b1f77c539be20a.tar.gz src-test2-51fb8b013e7734b795139f49d3b1f77c539be20a.zip |
Notes
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/LiteralSupport.h | 2 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 68 | ||||
-rw-r--r-- | include/clang/Lex/Token.h | 8 |
3 files changed, 52 insertions, 26 deletions
diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h index 97656f7d39d6..c4ab5aebf721 100644 --- a/include/clang/Lex/LiteralSupport.h +++ b/include/clang/Lex/LiteralSupport.h @@ -17,7 +17,7 @@ #include <string> #include "llvm/ADT/SmallString.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/System/DataTypes.h" namespace llvm { class APInt; diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 0765ac391be3..35960ff328a6 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -75,6 +75,8 @@ class Preprocessor { IdentifierInfo *Ident_Pragma, *Ident__VA_ARGS__; // _Pragma, __VA_ARGS__ IdentifierInfo *Ident__has_feature; // __has_feature IdentifierInfo *Ident__has_builtin; // __has_builtin + IdentifierInfo *Ident__has_include; // __has_include + IdentifierInfo *Ident__has_include_next; // __has_include_next SourceLocation DATELoc, TIMELoc; unsigned CounterValue; // Next __COUNTER__ value. @@ -244,7 +246,12 @@ public: return CurPPLexer == L; } - /// getCurrentLexer - Return the current file lexer being lexed from. Note + /// getCurrentLexer - Return the current lexer being lexed from. Note + /// that this ignores any potentially active macro expansions and _Pragma + /// expansions going on at the time. + PreprocessorLexer *getCurrentLexer() const { return CurPPLexer; } + + /// getCurrentFileLexer - Return the current file lexer being lexed from. Note /// that this ignores any potentially active macro expansions and _Pragma /// expansions going on at the time. PreprocessorLexer *getCurrentFileLexer() const; @@ -622,6 +629,43 @@ public: /// SourceLocation. MacroInfo* AllocateMacroInfo(SourceLocation L); + /// GetIncludeFilenameSpelling - Turn the specified lexer token into a fully + /// checked and spelled filename, e.g. as an operand of #include. This returns + /// true if the input filename was in <>'s or false if it were in ""'s. The + /// caller is expected to provide a buffer that is large enough to hold the + /// spelling of the filename, but is also expected to handle the case when + /// this method decides to use a different buffer. + bool GetIncludeFilenameSpelling(SourceLocation Loc, + const char *&BufStart, const char *&BufEnd); + + /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file, + /// return null on failure. isAngled indicates whether the file reference is + /// for system #include's or not (i.e. using <> instead of ""). + const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd, + bool isAngled, const DirectoryLookup *FromDir, + const DirectoryLookup *&CurDir); + + /// GetCurLookup - The DirectoryLookup structure used to find the current + /// FileEntry, if CurLexer is non-null and if applicable. This allows us to + /// implement #include_next and find directory-specific properties. + const DirectoryLookup *GetCurDirLookup() { return CurDirLookup; } + + /// isInPrimaryFile - Return true if we're in the top-level file, not in a + /// #include. + bool isInPrimaryFile() const; + + /// ConcatenateIncludeName - Handle cases where the #include name is expanded + /// from a macro as multiple tokens, which need to be glued together. This + /// occurs for code like: + /// #define FOO <a/b.h> + /// #include FOO + /// because in this case, "<a/b.h>" is returned as 7 tokens, not one. + /// + /// This code concatenates and consumes tokens up to the '>' token. It returns + /// false if the > was found, otherwise it returns true if it finds and consumes + /// the EOM marker. + bool ConcatenateIncludeName(llvm::SmallVector<char, 128> &FilenameBuffer); + private: void PushIncludeMacroStack() { @@ -646,10 +690,6 @@ private: /// be reused for allocating new MacroInfo objects. void ReleaseMacroInfo(MacroInfo* MI); - /// isInPrimaryFile - Return true if we're in the top-level file, not in a - /// #include. - bool isInPrimaryFile() const; - /// ReadMacroName - Lex and validate a macro name, which occurs after a /// #define or #undef. This emits a diagnostic, sets the token kind to eom, /// and discards the rest of the macro line if the macro name is invalid. @@ -722,24 +762,6 @@ private: /// start getting tokens from it using the PTH cache. void EnterSourceFileWithPTH(PTHLexer *PL, const DirectoryLookup *Dir); - /// GetIncludeFilenameSpelling - Turn the specified lexer token into a fully - /// checked and spelled filename, e.g. as an operand of #include. This returns - /// true if the input filename was in <>'s or false if it were in ""'s. The - /// caller is expected to provide a buffer that is large enough to hold the - /// spelling of the filename, but is also expected to handle the case when - /// this method decides to use a different buffer. - bool GetIncludeFilenameSpelling(SourceLocation Loc, - const char *&BufStart, const char *&BufEnd); - - /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file, - /// return null on failure. isAngled indicates whether the file reference is - /// for system #include's or not (i.e. using <> instead of ""). - const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd, - bool isAngled, const DirectoryLookup *FromDir, - const DirectoryLookup *&CurDir); - - - /// IsFileLexer - Returns true if we are lexing from a file and not a /// pragma or a macro. static bool IsFileLexer(const Lexer* L, const PreprocessorLexer* P) { diff --git a/include/clang/Lex/Token.h b/include/clang/Lex/Token.h index 8acdb30cc705..8d910959b9fa 100644 --- a/include/clang/Lex/Token.h +++ b/include/clang/Lex/Token.h @@ -17,6 +17,7 @@ #include "clang/Basic/TemplateKinds.h" #include "clang/Basic/TokenKinds.h" #include "clang/Basic/SourceLocation.h" +#include "clang/Basic/OperatorKinds.h" #include <cstdlib> namespace clang { @@ -62,12 +63,12 @@ class Token { /// Kind - The actual flavor of token this is. /// - unsigned Kind : 8; // DON'T make Kind a 'tok::TokenKind'; + unsigned char Kind; // DON'T make Kind a 'tok::TokenKind'; // MSVC will treat it as a signed char and // TokenKinds > 127 won't be handled correctly. /// Flags - Bits we track about this token, members of the TokenFlags enum. - unsigned Flags : 8; + unsigned char Flags; public: // Various flags set per token: @@ -261,6 +262,9 @@ struct TemplateIdAnnotation { /// FIXME: Temporarily stores the name of a specialization IdentifierInfo *Name; + /// FIXME: Temporarily stores the overloaded operator kind. + OverloadedOperatorKind Operator; + /// The declaration of the template corresponding to the /// template-name. This is an Action::DeclTy*. void *Template; |