summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r--contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp b/contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp
index 38f09a0..43899f0 100644
--- a/contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp
+++ b/contrib/llvm/tools/clang/lib/Basic/IdentifierTable.cpp
@@ -16,9 +16,10 @@
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ErrorHandling.h"
#include <cstdio>
using namespace clang;
@@ -37,7 +38,10 @@ IdentifierInfo::IdentifierInfo() {
IsCPPOperatorKeyword = false;
NeedsHandleIdentifier = false;
IsFromAST = false;
+ ChangedAfterLoad = false;
RevertedTokenID = false;
+ OutOfDate = false;
+ IsModulesImport = false;
FETokenInfo = 0;
Entry = 0;
}
@@ -74,6 +78,10 @@ IdentifierTable::IdentifierTable(const LangOptions &LangOpts,
// Populate the identifier table with info about keywords for the current
// language.
AddKeywords(LangOpts);
+
+
+ // Add the '_experimental_modules_import' contextual keyword.
+ get("__experimental_modules_import").setModulesImport(true);
}
//===----------------------------------------------------------------------===//
@@ -93,7 +101,7 @@ namespace {
KEYNOCXX = 0x80,
KEYBORLAND = 0x100,
KEYOPENCL = 0x200,
- KEYC1X = 0x400,
+ KEYC11 = 0x400,
KEYARC = 0x800,
KEYALL = 0x0fff
};
@@ -105,7 +113,7 @@ namespace {
///
/// The C90/C99/CPP/CPP0x flags are set to 3 if the token is a keyword in a
/// future language standard, set to 2 if the token should be enabled in the
-/// specified langauge, set to 1 if it is an extension in the specified
+/// specified language, set to 1 if it is an extension in the specified
/// language, and set to 0 if disabled in the specified language.
static void AddKeyword(StringRef Keyword,
tok::TokenKind TokenCode, unsigned Flags,
@@ -122,8 +130,10 @@ static void AddKeyword(StringRef Keyword,
else if (LangOpts.AltiVec && (Flags & KEYALTIVEC)) AddResult = 2;
else if (LangOpts.OpenCL && (Flags & KEYOPENCL)) AddResult = 2;
else if (!LangOpts.CPlusPlus && (Flags & KEYNOCXX)) AddResult = 2;
- else if (LangOpts.C1X && (Flags & KEYC1X)) AddResult = 2;
- else if (LangOpts.ObjCAutoRefCount && (Flags & KEYARC)) AddResult = 2;
+ else if (LangOpts.C11 && (Flags & KEYC11)) AddResult = 2;
+ // We treat bridge casts as objective-C keywords so we can warn on them
+ // in non-arc mode.
+ else if (LangOpts.ObjC2 && (Flags & KEYARC)) AddResult = 2;
else if (LangOpts.CPlusPlus && (Flags & KEYCXX0X)) AddResult = 3;
// Don't add this keyword if disabled in this language.
@@ -212,7 +222,7 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
CASE( 6, 'i', 'n', ifndef);
CASE( 6, 'i', 'p', import);
CASE( 6, 'p', 'a', pragma);
-
+
CASE( 7, 'd', 'f', defined);
CASE( 7, 'i', 'c', include);
CASE( 7, 'w', 'r', warning);
@@ -220,8 +230,11 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
CASE( 8, 'u', 'a', unassert);
CASE(12, 'i', 'c', include_next);
+ CASE(14, '_', 'p', __public_macro);
+
+ CASE(15, '_', 'p', __private_macro);
+
CASE(16, '_', 'i', __include_macros);
- CASE(16, '_', 'e', __export_macro__);
#undef CASE
#undef HASH
}
@@ -347,7 +360,7 @@ StringRef Selector::getNameForSlot(unsigned int argIndex) const {
}
std::string MultiKeywordSelector::getName() const {
- llvm::SmallString<256> Str;
+ SmallString<256> Str;
llvm::raw_svector_ostream OS(Str);
for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) {
if (*I)
@@ -445,6 +458,18 @@ static SelectorTableImpl &getSelectorTableImpl(void *P) {
return *static_cast<SelectorTableImpl*>(P);
}
+/*static*/ Selector
+SelectorTable::constructSetterName(IdentifierTable &Idents,
+ SelectorTable &SelTable,
+ const IdentifierInfo *Name) {
+ SmallString<100> SelectorName;
+ SelectorName = "set";
+ SelectorName += Name->getName();
+ SelectorName[3] = toupper(SelectorName[3]);
+ IdentifierInfo *SetterName = &Idents.get(SelectorName);
+ return SelTable.getUnarySelector(SetterName);
+}
+
size_t SelectorTable::getTotalMemory() const {
SelectorTableImpl &SelTabImpl = getSelectorTableImpl(Impl);
return SelTabImpl.Allocator.getTotalMemory();
@@ -495,5 +520,5 @@ const char *clang::getOperatorSpelling(OverloadedOperatorKind Operator) {
#include "clang/Basic/OperatorKinds.def"
}
- return 0;
+ llvm_unreachable("Invalid OverloadedOperatorKind!");
}
OpenPOWER on IntegriCloud