diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-02-23 01:05:54 +0000 | 
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-02-23 01:05:54 +0000 | 
| commit | f948d2a75f6b5b5413de726e2e10a0fd098d16e2 (patch) | |
| tree | 7fe1f75d62bce88c2d3a70d79f93a3ec3e06e1ee | |
| parent | d9955512615a5f7517f859493f49d4916db8be16 (diff) | |
| download | bcm5719-llvm-f948d2a75f6b5b5413de726e2e10a0fd098d16e2.tar.gz bcm5719-llvm-f948d2a75f6b5b5413de726e2e10a0fd098d16e2.zip  | |
Change encoding of TokenKind in IdentifierTable to be of type "unsigned"
instead of TokenKind because of signedness issues with MSVC and enums.
Patch from Argiris Kirtzidis.
llvm-svn: 47515
| -rw-r--r-- | clang/include/clang/Basic/IdentifierTable.h | 6 | ||||
| -rw-r--r-- | clang/include/clang/Lex/Token.h | 18 | 
2 files changed, 16 insertions, 8 deletions
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index bb68e650cb0..97119261d95 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -36,7 +36,9 @@ namespace clang {  /// variable or function name).  The preprocessor keeps this information in a  /// set, and all tok::identifier tokens have a pointer to one of these.    class IdentifierInfo { -  tok::TokenKind TokenID      : 8; // Front-end token ID or tok::identifier. +  // Note: DON'T make TokenID a 'tok::TokenKind'; MSVC will treat it as a +  //       signed char and TokenKinds > 127 won't be handled correctly. +  unsigned TokenID            : 8; // Front-end token ID or tok::identifier.     unsigned BuiltinID          : 9; // ID if this is a builtin (__builtin_inf).    tok::ObjCKeywordKind ObjCID : 5; // ID for objc @ keyword like @'protocol'.    bool HasMacro               : 1; // True if there is a #define for this. @@ -79,7 +81,7 @@ public:    /// get/setTokenID - If this is a source-language token (e.g. 'for'), this API    /// can be used to cause the lexer to map identifiers to source-language    /// tokens. -  tok::TokenKind getTokenID() const { return TokenID; } +  tok::TokenKind getTokenID() const { return (tok::TokenKind)TokenID; }    void setTokenID(tok::TokenKind ID) { TokenID = ID; }    /// getPPKeywordID - Return the preprocessor keyword ID for this identifier. diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h index 9204b435673..d5bfd9cdf59 100644 --- a/clang/include/clang/Lex/Token.h +++ b/clang/include/clang/Lex/Token.h @@ -36,7 +36,9 @@ class Token {    /// Kind - The actual flavor of token this is.    /// -  tok::TokenKind Kind : 8; +  unsigned Kind : 8;  // 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; @@ -50,13 +52,13 @@ public:      NeedsCleaning = 0x08   // Contained an escaped newline or trigraph.    }; -  tok::TokenKind getKind() const { return Kind; } +  tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }    void setKind(tok::TokenKind K) { Kind = K; }    /// is/isNot - Predicates to check if this token is a specific kind, as in    /// "if (Tok.is(tok::l_brace)) {...}". -  bool is(tok::TokenKind K) const { return Kind == K; } -  bool isNot(tok::TokenKind K) const { return Kind != K; } +  bool is(tok::TokenKind K) const { return Kind == (unsigned) K; } +  bool isNot(tok::TokenKind K) const { return Kind != (unsigned) K; }    /// getLocation - Return a source location identifier for the specified    /// offset in the current file. @@ -66,7 +68,9 @@ public:    void setLocation(SourceLocation L) { Loc = L; }    void setLength(unsigned Len) { Length = Len; } -  const char *getName() const { return tok::getTokenName(Kind); } +  const char *getName() const { +    return tok::getTokenName( (tok::TokenKind) Kind); +  }    /// startToken - Reset all flags to cleared.    /// @@ -113,7 +117,9 @@ public:    /// isExpandDisabled - Return true if this identifier token should never    /// be expanded in the future, due to C99 6.10.3.4p2. -  bool isExpandDisabled() const { return (Flags & DisableExpand) ? true : false; } +  bool isExpandDisabled() const { +    return (Flags & DisableExpand) ? true : false; +  }    /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier.     bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;  | 

