diff options
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/DirectoryLookup.h | 40 | ||||
-rw-r--r-- | include/clang/Lex/HeaderMap.h | 14 | ||||
-rw-r--r-- | include/clang/Lex/HeaderSearch.h | 50 | ||||
-rw-r--r-- | include/clang/Lex/LexDiagnostic.h | 2 | ||||
-rw-r--r-- | include/clang/Lex/Lexer.h | 94 | ||||
-rw-r--r-- | include/clang/Lex/LiteralSupport.h | 44 | ||||
-rw-r--r-- | include/clang/Lex/MacroInfo.h | 54 | ||||
-rw-r--r-- | include/clang/Lex/MultipleIncludeOpt.h | 22 | ||||
-rw-r--r-- | include/clang/Lex/PPCallbacks.h | 28 | ||||
-rw-r--r-- | include/clang/Lex/PTHLexer.h | 32 | ||||
-rw-r--r-- | include/clang/Lex/PTHManager.h | 44 | ||||
-rw-r--r-- | include/clang/Lex/Pragma.h | 14 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 196 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessorLexer.h | 56 | ||||
-rw-r--r-- | include/clang/Lex/ScratchBuffer.h | 4 | ||||
-rw-r--r-- | include/clang/Lex/Token.h | 70 | ||||
-rw-r--r-- | include/clang/Lex/TokenConcatenation.h | 16 | ||||
-rw-r--r-- | include/clang/Lex/TokenLexer.h | 40 |
18 files changed, 410 insertions, 410 deletions
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h index 618de39233..c94a990224 100644 --- a/include/clang/Lex/DirectoryLookup.h +++ b/include/clang/Lex/DirectoryLookup.h @@ -38,20 +38,20 @@ private: /// Dir - This is the actual directory that we're referring to for a normal /// directory or a framework. const DirectoryEntry *Dir; - + /// Map - This is the HeaderMap if this is a headermap lookup. /// const HeaderMap *Map; } u; - + /// DirCharacteristic - The type of directory this is: this is an instance of /// SrcMgr::CharacteristicKind. unsigned DirCharacteristic : 2; - + /// UserSupplied - True if this is a user-supplied directory. /// bool UserSupplied : 1; - + /// LookupType - This indicates whether this DirectoryLookup object is a /// normal directory, a framework, or a headermap. unsigned LookupType : 2; @@ -62,25 +62,25 @@ public: bool isUser, bool isFramework) : DirCharacteristic(DT), UserSupplied(isUser), LookupType(isFramework ? LT_Framework : LT_NormalDir) { - u.Dir = dir; + u.Dir = dir; } - + /// DirectoryLookup ctor - Note that this ctor *does not take ownership* of /// 'map'. DirectoryLookup(const HeaderMap *map, SrcMgr::CharacteristicKind DT, bool isUser) : DirCharacteristic(DT), UserSupplied(isUser), LookupType(LT_HeaderMap) { - u.Map = map; + u.Map = map; } - + /// getLookupType - Return the kind of directory lookup that this is: either a /// normal directory, a framework path, or a HeaderMap. LookupType_t getLookupType() const { return (LookupType_t)LookupType; } - + /// getName - Return the directory or filename corresponding to this lookup /// object. const char *getName() const; - + /// getDir - Return the directory that this entry refers to. /// const DirectoryEntry *getDir() const { return isNormalDir() ? u.Dir : 0; } @@ -90,42 +90,42 @@ public: const DirectoryEntry *getFrameworkDir() const { return isFramework() ? u.Dir : 0; } - + /// getHeaderMap - Return the directory that this entry refers to. /// const HeaderMap *getHeaderMap() const { return isHeaderMap() ? u.Map : 0; } /// isNormalDir - Return true if this is a normal directory, not a header map. bool isNormalDir() const { return getLookupType() == LT_NormalDir; } - + /// isFramework - True if this is a framework directory. /// bool isFramework() const { return getLookupType() == LT_Framework; } - + /// isHeaderMap - Return true if this is a header map, not a normal directory. bool isHeaderMap() const { return getLookupType() == LT_HeaderMap; } - + /// DirCharacteristic - The type of directory this is, one of the DirType enum /// values. SrcMgr::CharacteristicKind getDirCharacteristic() const { return (SrcMgr::CharacteristicKind)DirCharacteristic; } - + /// isUserSupplied - True if this is a user-supplied directory. /// bool isUserSupplied() const { return UserSupplied; } - - + + /// LookupFile - Lookup the specified file in this search path, returning it /// if it exists or returning null if not. const FileEntry *LookupFile(const char *FilenameStart, const char *FilenameEnd, HeaderSearch &HS) const; - + private: const FileEntry *DoFrameworkLookup(const char *FilenameStart, - const char *FilenameEnd, + const char *FilenameEnd, HeaderSearch &HS) const; - + }; } // end namespace clang diff --git a/include/clang/Lex/HeaderMap.h b/include/clang/Lex/HeaderMap.h index d8033093bd..6bb7c25947 100644 --- a/include/clang/Lex/HeaderMap.h +++ b/include/clang/Lex/HeaderMap.h @@ -30,31 +30,31 @@ namespace clang { class HeaderMap { HeaderMap(const HeaderMap&); // DO NOT IMPLEMENT void operator=(const HeaderMap&); // DO NOT IMPLEMENT - + const llvm::MemoryBuffer *FileBuffer; bool NeedsBSwap; - + HeaderMap(const llvm::MemoryBuffer *File, bool BSwap) : FileBuffer(File), NeedsBSwap(BSwap) { } public: ~HeaderMap(); - + /// HeaderMap::Create - This attempts to load the specified file as a header /// map. If it doesn't look like a HeaderMap, it gives up and returns null. static const HeaderMap *Create(const FileEntry *FE); - + /// LookupFile - Check to see if the specified relative filename is located in /// this HeaderMap. If so, open it and return its FileEntry. const FileEntry *LookupFile(const char *FilenameStart,const char *FilenameEnd, FileManager &FM) const; - + /// getFileName - Return the filename of the headermap. const char *getFileName() const; - + /// dump - Print the contents of this headermap to stderr. void dump() const; - + private: unsigned getEndianAdjustedWord(unsigned X) const; const HMapHeader &getHeader() const; diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index f21aab1b40..7517440983 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -30,17 +30,17 @@ class IdentifierInfo; struct HeaderFileInfo { /// isImport - True if this is a #import'd or #pragma once file. bool isImport : 1; - + /// DirInfo - Keep track of whether this is a system header, and if so, /// whether it is C++ clean or not. This can be set by the include paths or /// by #pragma gcc system_header. This is an instance of /// SrcMgr::CharacteristicKind. unsigned DirInfo : 2; - + /// NumIncludes - This is the number of times the file has been included /// already. unsigned short NumIncludes; - + /// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard /// that protects the entire contents of the file, this is the identifier /// for the macro that controls whether or not it has any effect. @@ -51,14 +51,14 @@ struct HeaderFileInfo { /// external storage. const IdentifierInfo *ControllingMacro; - /// \brief The ID number of the controlling macro. + /// \brief The ID number of the controlling macro. /// /// This ID number will be non-zero when there is a controlling /// macro whose IdentifierInfo may not yet have been loaded from /// external storage. unsigned ControllingMacroID; - HeaderFileInfo() + HeaderFileInfo() : isImport(false), DirInfo(SrcMgr::C_User), NumIncludes(0), ControllingMacro(0), ControllingMacroID(0) {} @@ -71,7 +71,7 @@ struct HeaderFileInfo { /// file referenced by a #include or #include_next, (sub-)framework lookup, etc. class HeaderSearch { FileManager &FileMgr; - + /// #include search path information. Requests for #include "x" search the /// directory of the #including file first, then each directory in SearchDirs /// consequtively. Requests for <x> search the current dir first, then each @@ -81,7 +81,7 @@ class HeaderSearch { std::vector<DirectoryLookup> SearchDirs; unsigned SystemDirIdx; bool NoCurDirSearch; - + /// FileInfo - This contains all of the preprocessor-specific data about files /// that are included. The vector is indexed by the FileEntry's UID. /// @@ -94,13 +94,13 @@ class HeaderSearch { /// ignored. The second value is the entry in SearchDirs that satisfied the /// query. llvm::StringMap<std::pair<unsigned, unsigned> > LookupFileCache; - - + + /// FrameworkMap - This is a collection mapping a framework or subframework /// name like "Carbon" to the Carbon.framework directory. llvm::StringMap<const DirectoryEntry *> FrameworkMap; - /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing + /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing /// headermaps. This vector owns the headermap. std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps; @@ -114,7 +114,7 @@ class HeaderSearch { unsigned NumFrameworkLookups, NumSubFrameworkLookups; // HeaderSearch doesn't support default or copy construction. - explicit HeaderSearch(); + explicit HeaderSearch(); explicit HeaderSearch(const HeaderSearch&); void operator=(const HeaderSearch&); public: @@ -132,12 +132,12 @@ public: NoCurDirSearch = noCurDirSearch; //LookupFileCache.clear(); } - + /// ClearFileInfo - Forget everything we know about headers so far. void ClearFileInfo() { FileInfo.clear(); } - + void SetExternalLookup(ExternalIdentifierLookup *EIL) { ExternalLookup = EIL; } @@ -155,7 +155,7 @@ public: const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, const FileEntry *CurFileEnt); - + /// LookupSubframeworkHeader - Look up a subframework for the specified /// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from /// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox @@ -164,7 +164,7 @@ public: const FileEntry *LookupSubframeworkHeader(const char *FilenameStart, const char *FilenameEnd, const FileEntry *RelativeFileEnt); - + /// LookupFrameworkCache - Look up the specified framework name in our /// framework cache, returning the DirectoryEntry it is in if we know, /// otherwise, return null. @@ -172,19 +172,19 @@ public: const char *FWNameEnd) { return FrameworkMap.GetOrCreateValue(FWNameStart, FWNameEnd).getValue(); } - + /// ShouldEnterIncludeFile - Mark the specified file as a target of of a /// #include, #include_next, or #import directive. Return false if #including /// the file will have no effect or true if we should include it. bool ShouldEnterIncludeFile(const FileEntry *File, bool isImport); - - + + /// getFileDirFlavor - Return whether the specified file is a normal header, /// a system header, or a C++ friendly system header. SrcMgr::CharacteristicKind getFileDirFlavor(const FileEntry *File) { return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo; } - + /// MarkFileIncludeOnce - Mark the specified file as a "once only" file, e.g. /// due to #pragma once. void MarkFileIncludeOnce(const FileEntry *File) { @@ -196,13 +196,13 @@ public: void MarkFileSystemHeader(const FileEntry *File) { getFileInfo(File).DirInfo = SrcMgr::C_System; } - + /// IncrementIncludeCount - Increment the count for the number of times the /// specified FileEntry has been entered. void IncrementIncludeCount(const FileEntry *File) { ++getFileInfo(File).NumIncludes; } - + /// SetFileControllingMacro - Mark the specified file as having a controlling /// macro. This is used by the multiple-include optimization to eliminate /// no-op #includes. @@ -210,11 +210,11 @@ public: const IdentifierInfo *ControllingMacro) { getFileInfo(File).ControllingMacro = ControllingMacro; } - + /// CreateHeaderMap - This method returns a HeaderMap for the specified /// FileEntry, uniquing them through the the 'HeaderMaps' datastructure. const HeaderMap *CreateHeaderMap(const FileEntry *FE); - + void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; } typedef std::vector<HeaderFileInfo>::iterator header_file_iterator; @@ -223,10 +223,10 @@ public: // Used by PCHReader. void setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID); - + void PrintStats(); private: - + /// getFileInfo - Return the HeaderFileInfo structure for the specified /// FileEntry. HeaderFileInfo &getFileInfo(const FileEntry *FE); diff --git a/include/clang/Lex/LexDiagnostic.h b/include/clang/Lex/LexDiagnostic.h index 03d9b7b3bb..a470aa0924 100644 --- a/include/clang/Lex/LexDiagnostic.h +++ b/include/clang/Lex/LexDiagnostic.h @@ -13,7 +13,7 @@ #include "clang/Basic/Diagnostic.h" namespace clang { - namespace diag { + namespace diag { enum { #define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,SFINAE) ENUM, #define LEXSTART diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index 3a73147152..1443ef1184 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -39,11 +39,11 @@ class Lexer : public PreprocessorLexer { SourceLocation FileLoc; // Location for start of file. LangOptions Features; // Features enabled by this language (cache). bool Is_PragmaLexer; // True if lexer for _Pragma handling. - + //===--------------------------------------------------------------------===// // Context-specific lexing flags set by the preprocessor. // - + /// ExtendedTokenMode - The lexer can optionally keep comments and whitespace /// and return them as tokens. This is used for -C and -CC modes, and /// whitespace preservation can be useful for some clients that want to lex @@ -52,7 +52,7 @@ class Lexer : public PreprocessorLexer { /// When this is set to 2 it returns comments and whitespace. When set to 1 /// it returns comments, when it is set to 0 it returns normal tokens only. unsigned char ExtendedTokenMode; - + //===--------------------------------------------------------------------===// // Context that changes as the file is lexed. // NOTE: any state that mutates when in raw mode must have save/restore code @@ -65,14 +65,14 @@ class Lexer : public PreprocessorLexer { // IsAtStartOfLine - True if the next lexed token should get the "start of // line" flag set on it. bool IsAtStartOfLine; - + Lexer(const Lexer&); // DO NOT IMPLEMENT void operator=(const Lexer&); // DO NOT IMPLEMENT friend class Preprocessor; - + void InitLexer(const char *BufStart, const char *BufPtr, const char *BufEnd); public: - + /// Lexer constructor - Create a new lexer object for the specified buffer /// with the specified preprocessor managing the lexing process. This lexer /// assumes that the associated file buffer and Preprocessor objects will @@ -84,21 +84,21 @@ public: /// range will outlive it, so it doesn't take ownership of it. Lexer(SourceLocation FileLoc, const LangOptions &Features, const char *BufStart, const char *BufPtr, const char *BufEnd); - + /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexRawToken'. This lexer assumes that the text /// range will outlive it, so it doesn't take ownership of it. Lexer(FileID FID, const SourceManager &SM, const LangOptions &Features); - + /// Create_PragmaLexer: Lexer constructor - Create a new lexer object for /// _Pragma expansion. This has a variety of magic semantics that this method /// sets up. It returns a new'd Lexer that must be delete'd when done. - static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc, + static Lexer *Create_PragmaLexer(SourceLocation SpellingLoc, SourceLocation InstantiationLocStart, SourceLocation InstantiationLocEnd, unsigned TokLen, Preprocessor &PP); - - + + /// getFeatures - Return the language features currently enabled. NOTE: this /// lexer modifies features as a file is parsed! const LangOptions &getFeatures() const { return Features; } @@ -108,7 +108,7 @@ public: /// the virtual location encodes where we should *claim* the characters came /// from. Currently this is only used by _Pragma handling. SourceLocation getFileLoc() const { return FileLoc; } - + /// Lex - Return the next token in the file. If this is the end of file, it /// return the tok::eof token. Return true if an error occurred and /// compilation should terminate, false if normal. This implicitly involves @@ -116,14 +116,14 @@ public: void Lex(Token &Result) { // Start a new token. Result.startToken(); - - // NOTE, any changes here should also change code after calls to + + // NOTE, any changes here should also change code after calls to // Preprocessor::HandleDirective if (IsAtStartOfLine) { Result.setFlag(Token::StartOfLine); IsAtStartOfLine = false; } - + // Get a token. Note that this may delete the current lexer if the end of // file is reached. LexTokenInternal(Result); @@ -131,11 +131,11 @@ public: /// isPragmaLexer - Returns true if this Lexer is being used to lex a pragma. bool isPragmaLexer() const { return Is_PragmaLexer; } - + /// IndirectLex - An indirect call to 'Lex' that can be invoked via /// the PreprocessorLexer interface. void IndirectLex(Token &Result) { Lex(Result); } - + /// LexFromRawLexer - Lex a token from a designated raw lexer (one with no /// associated preprocessor object. Return true if the 'next character to /// read' pointer points at the end of the lexer buffer, false otherwise. @@ -144,7 +144,7 @@ public: Lex(Result); // Note that lexing to the end of the buffer doesn't implicitly delete the // lexer when in raw mode. - return BufferPtr == BufferEnd; + return BufferPtr == BufferEnd; } /// isKeepWhitespaceMode - Return true if the lexer should return tokens for @@ -168,23 +168,23 @@ public: bool inKeepCommentMode() const { return ExtendedTokenMode > 0; } - + /// SetCommentRetentionMode - Change the comment retention mode of the lexer /// to the specified mode. This is really only useful when lexing in raw /// mode, because otherwise the lexer needs to manage this. - void SetCommentRetentionState(bool Mode) { + void SetCommentRetentionState(bool Mode) { assert(!isKeepWhitespaceMode() && "Can't play with comment retention state when retaining whitespace"); ExtendedTokenMode = Mode ? 1 : 0; } - + const char *getBufferStart() const { return BufferStart; } - + /// ReadToEndOfLine - Read the rest of the current preprocessor line as an /// uninterpreted string. This switches the lexer out of directive mode. std::string ReadToEndOfLine(); - - + + /// Diag - Forwarding function for diagnostics. This translate a source /// position in the current buffer into a SourceLocation object for rendering. DiagnosticBuilder Diag(const char *Loc, unsigned DiagID) const; @@ -192,20 +192,20 @@ public: /// getSourceLocation - Return a source location identifier for the specified /// offset in the current file. SourceLocation getSourceLocation(const char *Loc, unsigned TokLen = 1) const; - + /// getSourceLocation - Return a source location for the next character in /// the current file. SourceLocation getSourceLocation() { return getSourceLocation(BufferPtr); } - + /// Stringify - Convert the specified string into a C string by escaping '\' /// and " characters. This does not add surrounding ""'s to the string. /// If Charify is true, this escapes the ' character instead of ". static std::string Stringify(const std::string &Str, bool Charify = false); - + /// Stringify - Convert the specified string into a C string by escaping '\' /// and " characters. This does not add surrounding ""'s to the string. static void Stringify(llvm::SmallVectorImpl<char> &Str); - + /// MeasureTokenLength - Relex the token at the specified location and return /// its length in bytes in the input file. If the token needs cleaning (e.g. /// includes a trigraph or an escaped newline) then this count includes bytes @@ -213,7 +213,7 @@ public: static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts); - + //===--------------------------------------------------------------------===// // Internal implementation interfaces. private: @@ -228,7 +228,7 @@ private: /// takes that range and assigns it to the token as its location and size. In /// addition, since tokens cannot overlap, this also updates BufferPtr to be /// TokEnd. - void FormTokenWithChars(Token &Result, const char *TokEnd, + void FormTokenWithChars(Token &Result, const char *TokEnd, tok::TokenKind Kind) { unsigned TokLen = TokEnd-BufferPtr; Result.setLength(TokLen); @@ -236,7 +236,7 @@ private: Result.setKind(Kind); BufferPtr = TokEnd; } - + /// isNextPPTokenLParen - Return 1 if the next unexpanded token will return a /// tok::l_paren token, 0 if it is something else and 2 if there are no more /// tokens in the buffer controlled by this lexer. @@ -245,7 +245,7 @@ private: //===--------------------------------------------------------------------===// // Lexer character reading interfaces. public: - + // This lexer is built on two interfaces for reading characters, both of which // automatically provide phase 1/2 translation. getAndAdvanceChar is used // when we know that we will be reading a character from the input buffer and @@ -260,7 +260,7 @@ public: // approach allows us to emit diagnostics for characters (e.g. warnings about // trigraphs), knowing that they only are emitted if the character is // consumed. - + /// isObviouslySimpleCharacter - Return true if the specified character is /// obviously the same in translation phase 1 and translation phase 3. This /// can return false for characters that end up being the same, but it will @@ -268,7 +268,7 @@ public: static bool isObviouslySimpleCharacter(char C) { return C != '?' && C != '\\'; } - + /// getAndAdvanceChar - Read a single 'character' from the specified buffer, /// advance over it, and return it. This is tricky in several cases. Here we /// just handle the trivial case and fall-back to the non-inlined @@ -277,13 +277,13 @@ public: // If this is not a trigraph and not a UCN or escaped newline, return // quickly. if (isObviouslySimpleCharacter(Ptr[0])) return *Ptr++; - + unsigned Size = 0; char C = getCharAndSizeSlow(Ptr, Size, &Tok); Ptr += Size; return C; } - + private: /// ConsumeChar - When a character (identified by PeekCharAndSize) is consumed /// and added to a given token, check to see if there are diagnostics that @@ -300,7 +300,7 @@ private: getCharAndSizeSlow(Ptr, Size, &Tok); return Ptr+Size; } - + /// getCharAndSize - Peek a single 'character' from the specified buffer, /// get its size, and return it. This is tricky in several cases. Here we /// just handle the trivial case and fall-back to the non-inlined @@ -312,16 +312,16 @@ private: Size = 1; return *Ptr; } - + Size = 0; return getCharAndSizeSlow(Ptr, Size); } - + /// getCharAndSizeSlow - Handle the slow/uncommon case of the getCharAndSize /// method. char getCharAndSizeSlow(const char *Ptr, unsigned &Size, Token *Tok = 0); public: - + /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever /// emit a warning. static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size, @@ -332,30 +332,30 @@ public: Size = 1; return *Ptr; } - + Size = 0; return getCharAndSizeSlowNoWarn(Ptr, Size, Features); } - + /// getEscapedNewLineSize - Return the size of the specified escaped newline, /// or 0 if it is not an escaped newline. P[-1] is known to be a "\" on entry /// to this function. static unsigned getEscapedNewLineSize(const char *P); - + /// SkipEscapedNewLines - If P points to an escaped newline (or a series of /// them), skip over them and return the first non-escaped-newline found, /// otherwise return P. static const char *SkipEscapedNewLines(const char *P); private: - + /// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a /// diagnostic. static char getCharAndSizeSlowNoWarn(const char *Ptr, unsigned &Size, const LangOptions &Features); - + //===--------------------------------------------------------------------===// // Other lexer functions. - + // Helper functions to lex the remainder of a token of the specific type. void LexIdentifier (Token &Result, const char *CurPtr); void LexNumericConstant (Token &Result, const char *CurPtr); @@ -363,7 +363,7 @@ private: void LexAngledStringLiteral(Token &Result, const char *CurPtr); void LexCharConstant (Token &Result, const char *CurPtr); bool LexEndOfFile (Token &Result, const char *CurPtr); - + bool SkipWhitespace (Token &Result, const char *CurPtr); bool SkipBCPLComment (Token &Result, const char *CurPtr); bool SkipBlockComment (Token &Result, const char *CurPtr); diff --git a/include/clang/Lex/LiteralSupport.h b/include/clang/Lex/LiteralSupport.h index 29b82c1807..1c1cc8031f 100644 --- a/include/clang/Lex/LiteralSupport.h +++ b/include/clang/Lex/LiteralSupport.h @@ -32,22 +32,22 @@ class Preprocessor; class Token; class SourceLocation; class TargetInfo; - + /// NumericLiteralParser - This performs strict semantic analysis of the content /// of a ppnumber, classifying it as either integer, floating, or erroneous, /// determines the radix of the value and can convert it to a useful value. class NumericLiteralParser { Preprocessor &PP; // needed for diagnostics - + const char *const ThisTokBegin; const char *const ThisTokEnd; const char *DigitsBegin, *SuffixBegin; // markers const char *s; // cursor - + unsigned radix; - + bool saw_exponent, saw_period; - + public: NumericLiteralParser(const char *begin, const char *end, SourceLocation Loc, Preprocessor &PP); @@ -57,8 +57,8 @@ public: bool isLongLong; bool isFloat; // 1.0f bool isImaginary; // 1.0i - - bool isIntegerLiteral() const { + + bool isIntegerLiteral() const { return !saw_period && !saw_exponent; } bool isFloatingLiteral() const { @@ -67,27 +67,27 @@ public: bool hasSuffix() const { return SuffixBegin != ThisTokEnd; } - + unsigned getRadix() const { return radix; } - + /// GetIntegerValue - Convert this numeric literal value to an APInt that /// matches Val's input width. If there is an overflow (i.e., if the unsigned /// value read is larger than the APInt's bits will hold), set Val to the low /// bits of the result and return true. Otherwise, return false. bool GetIntegerValue(llvm::APInt &Val); - + /// GetFloatValue - Convert this numeric literal to a floating value, using /// the specified APFloat fltSemantics (specifying float, double, etc). /// The optional bool isExact (passed-by-reference) has its value /// set to true if the returned APFloat can represent the number in the /// literal exactly, and false otherwise. - llvm::APFloat GetFloatValue(const llvm::fltSemantics &Format, + llvm::APFloat GetFloatValue(const llvm::fltSemantics &Format, bool* isExact = NULL); -private: - +private: + void ParseNumberStartingWithZero(SourceLocation TokLoc); - + /// SkipHexDigits - Read and skip over any hex digits, up to End. /// Return a pointer to the first non-hex digit or End. const char *SkipHexDigits(const char *ptr) { @@ -95,7 +95,7 @@ private: ptr++; return ptr; } - + /// SkipOctalDigits - Read and skip over any octal digits, up to End. /// Return a pointer to the first non-hex digit or End. const char *SkipOctalDigits(const char *ptr) { @@ -103,7 +103,7 @@ private: ptr++; return ptr; } - + /// SkipDigits - Read and skip over any digits, up to End. /// Return a pointer to the first non-hex digit or End. const char *SkipDigits(const char *ptr) { @@ -111,7 +111,7 @@ private: ptr++; return ptr; } - + /// SkipBinaryDigits - Read and skip over any binary digits, up to End. /// Return a pointer to the first non-binary digit or End. const char *SkipBinaryDigits(const char *ptr) { @@ -119,7 +119,7 @@ private: ptr++; return ptr; } - + }; /// CharLiteralParser - Perform interpretation and semantic analysis of a @@ -144,7 +144,7 @@ public: /// literals) (C99 5.1.1.2p1). class StringLiteralParser { Preprocessor &PP; - + unsigned MaxTokenLength; unsigned SizeBound; unsigned wchar_tByteWidth; @@ -156,7 +156,7 @@ public: bool hadError; bool AnyWide; bool Pascal; - + const char *GetString() { return &ResultBuf[0]; } unsigned GetStringLength() const { return ResultPtr-&ResultBuf[0]; } @@ -164,14 +164,14 @@ public: if (AnyWide) return GetStringLength() / wchar_tByteWidth; return GetStringLength(); - } + } /// getOffsetOfStringByte - This function returns the offset of the /// specified byte of the string data represented by Token. This handles /// advancing over escape sequences in the string. static unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo, Preprocessor &PP); }; - + } // end namespace clang #endif diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h index ccd13c80d3..5887041c46 100644 --- a/include/clang/Lex/MacroInfo.h +++ b/include/clang/Lex/MacroInfo.h @@ -22,7 +22,7 @@ namespace clang { class Preprocessor; - + /// MacroInfo - Each identifier that is #define'd has an instance of this class /// associated with it, used to implement macro expansion. class MacroInfo { @@ -39,7 +39,7 @@ class MacroInfo { /// includes the __VA_ARGS__ identifier on the list. IdentifierInfo **ArgumentList; unsigned NumArguments; - + /// ReplacementTokens - This is the list of tokens that the macro is defined /// to. llvm::SmallVector<Token, 8> ReplacementTokens; @@ -47,21 +47,21 @@ class MacroInfo { /// IsFunctionLike - True if this macro is a function-like macro, false if it /// is an object-like macro. bool IsFunctionLike : 1; - + /// IsC99Varargs - True if this macro is of the form "#define X(...)" or /// "#define X(Y,Z,...)". The __VA_ARGS__ token should be replaced with the /// contents of "..." in an invocation. bool IsC99Varargs : 1; - + /// IsGNUVarargs - True if this macro is of the form "#define X(a...)". The /// "a" identifier in the replacement list will be replaced with all arguments /// of the macro starting with the specified one. bool IsGNUVarargs : 1; - + /// IsBuiltinMacro - True if this is a builtin macro, such as __LINE__, and if /// it has not yet been redefined or undefined. bool IsBuiltinMacro : 1; - + private: //===--------------------------------------------------------------------===// // State that changes as the macro is used. @@ -70,19 +70,19 @@ private: /// This disbles recursive expansion, which would be quite bad for things like /// #define A A. bool IsDisabled : 1; - + /// IsUsed - True if this macro is either defined in the main file and has - /// been used, or if it is not defined in the main file. This is used to + /// been used, or if it is not defined in the main file. This is used to /// emit -Wunused- |