Change Parser & Sema to use interned "super" for comparions.
- Added as private members for each because it is not clear where to
put the common definition. Perhaps the IdentifierInfos all of these
"pseudo-keywords" should be collected into one place (this would
KnownFunctionIDs and Objective-C property IDs, for example).
Remove Token::isNamedIdentifier.
- There isn't a good reason to use strcmp when we have interned
strings, and there isn't a good reason to encourage clients to do
so.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54794 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 46c9e99..c8d83bd 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -103,6 +103,8 @@
KnownFunctionIDs[id_vsprintf] = &IT.get("vsprintf");
KnownFunctionIDs[id_vprintf] = &IT.get("vprintf");
+ SuperID = &IT.get("super");
+
TUScope = 0;
if (getLangOptions().CPlusPlus)
FieldCollector.reset(new CXXFieldCollector());
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index d6dcaf2..98f98aa 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -137,7 +137,10 @@
/// kinds of checking (e.g. checking format string errors in printf calls).
/// This list is populated upon the creation of a Sema object.
IdentifierInfo* KnownFunctionIDs[ id_num_known_functions ];
-
+
+ /// SuperID - Identifier for "super" used for Objective-C checking.
+ IdentifierInfo* SuperID;
+
/// Translation Unit Scope - useful to Objective-C actions that need
/// to lookup file scope declarations in the "ordinary" C decl namespace.
/// For example, user-defined classes, built-in "id" type, etc.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2e99b3d..58a126b 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -328,7 +328,7 @@
}
}
// Needed to implement property "super.method" notation.
- if (SD == 0 && !strcmp(II.getName(), "super")) {
+ if (SD == 0 && &II == SuperID) {
QualType T = Context.getPointerType(Context.getObjCInterfaceType(
getCurMethodDecl()->getClassInterface()));
return new PredefinedExpr(Loc, T, PredefinedExpr::ObjCSuper);
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 75546ea..7c2f45b6 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -150,7 +150,7 @@
ObjCInterfaceDecl* ClassDecl = 0;
bool isSuper = false;
- if (!strcmp(receiverName->getName(), "super") && getCurMethodDecl()) {
+ if (receiverName == SuperID && getCurMethodDecl()) {
isSuper = true;
ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass();
if (!ClassDecl)