diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-05-04 18:24:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-05-04 18:24:37 +0000 |
commit | 51603be62ba78adeb64246b222583dcde4b20b2a (patch) | |
tree | aa5b116b81638ab49694645631f42833aa2887e4 /include/clang/Basic/IdentifierTable.h | |
parent | d2cf348f0df76bf1745f131db2ceeb59f23a7305 (diff) |
Synchronize the representations of DeclarationName and Selector so
that bridging between the two is free. Saves ~4k of code size,
although I don't see any measurable performance difference
(unfortunately).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/IdentifierTable.h')
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index cc0080b877..d79e28b295 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -574,9 +574,10 @@ class Selector { friend class Diagnostic; enum IdentifierInfoFlag { - // MultiKeywordSelector = 0. + // Empty selector = 0. ZeroArg = 0x1, OneArg = 0x2, + MultiArg = 0x3, ArgFlags = ZeroArg|OneArg }; uintptr_t InfoPtr; // a pointer to the MultiKeywordSelector or IdentifierInfo. @@ -590,13 +591,18 @@ class Selector { Selector(MultiKeywordSelector *SI) { InfoPtr = reinterpret_cast<uintptr_t>(SI); assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo"); + InfoPtr |= MultiArg; } IdentifierInfo *getAsIdentifierInfo() const { - if (getIdentifierInfoFlag()) + if (getIdentifierInfoFlag() < MultiArg) return reinterpret_cast<IdentifierInfo *>(InfoPtr & ~ArgFlags); return 0; } + MultiKeywordSelector *getMultiKeywordSelector() const { + return reinterpret_cast<MultiKeywordSelector *>(InfoPtr & ~ArgFlags); + } + unsigned getIdentifierInfoFlag() const { return InfoPtr & ArgFlags; } |