[cfe-commits] r66313 - in /cfe/trunk: include/clang/Basic/IdentifierTable.h lib/Basic/IdentifierTable.cpp lib/Sema/SemaDeclObjC.cpp

Ted Kremenek kremenek at apple.com
Fri Mar 6 17:22:02 PST 2009


Author: kremenek
Date: Fri Mar  6 19:22:02 2009
New Revision: 66313

URL: http://llvm.org/viewvc/llvm-project?rev=66313&view=rev
Log:
Selector: (changes made after discussing this more with Steve Naroff)
- Make Selector::getAsIdentifierInfo() private.  Using IdentifierInfo* in
  Selector is an implementation detail that clients shouldn't think about.
- Modify diagnostic emission in Sema::ProcessPropertyDecl to not use
  Selector::getAsIdentifierInfo() (which could crash when IdentifierInfo* is
  null) and instead use Selector::getAsString().
- Tidy up Selector::getAsString() implementation.

Modified:
    cfe/trunk/include/clang/Basic/IdentifierTable.h
    cfe/trunk/lib/Basic/IdentifierTable.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=66313&r1=66312&r2=66313&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Mar  6 19:22:02 2009
@@ -353,13 +353,6 @@
     assert((InfoPtr & ArgFlags) == 0 &&"Insufficiently aligned IdentifierInfo");
   }
   Selector(uintptr_t V) : InfoPtr(V) {}
-public:
-  friend class SelectorTable; // only the SelectorTable can create these
-  friend class DeclarationName; // and the AST's DeclarationName.
-
-  /// The default ctor should only be used when creating data structures that
-  ///  will contain selectors.
-  Selector() : InfoPtr(0) {}
   
   IdentifierInfo *getAsIdentifierInfo() const {
     if (getIdentifierInfoFlag())
@@ -369,6 +362,14 @@
   unsigned getIdentifierInfoFlag() const {
     return InfoPtr & ArgFlags;
   }
+public:
+  friend class SelectorTable; // only the SelectorTable can create these
+  friend class DeclarationName; // and the AST's DeclarationName.
+
+  /// The default ctor should only be used when creating data structures that
+  ///  will contain selectors.
+  Selector() : InfoPtr(0) {}
+
   /// operator==/!= - Indicate whether the specified selectors are identical.
   bool operator==(Selector RHS) const {
     return InfoPtr == RHS.InfoPtr;

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=66313&r1=66312&r2=66313&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Mar  6 19:22:02 2009
@@ -352,8 +352,9 @@
   if (InfoPtr & ArgFlags) {
     IdentifierInfo *II = getAsIdentifierInfo();
     
+    // If the number of arguments is 0 then II is guaranteed to not be null.
     if (getNumArgs() == 0)
-      return II ? II->getName() : "";
+      return II->getName();
 
     std::string Res = II ? II->getName() : "";
     Res += ":";

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=66313&r1=66312&r2=66313&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Mar  6 19:22:02 2009
@@ -1139,7 +1139,7 @@
     Diag(property->getLocation(), 
          diag::err_accessor_property_type_mismatch) 
       << property->getDeclName()
-      << GetterMethod->getSelector().getAsIdentifierInfo();
+      << GetterMethod->getSelector().getAsString();
     Diag(GetterMethod->getLocation(), diag::note_declared_at);
   }
   
@@ -1152,7 +1152,7 @@
       Diag(property->getLocation(), 
            diag::err_accessor_property_type_mismatch) 
         << property->getDeclName()
-        << SetterMethod->getSelector().getAsIdentifierInfo();
+        << SetterMethod->getSelector().getAsString();
       Diag(SetterMethod->getLocation(), diag::note_declared_at);
     }
   }





More information about the cfe-commits mailing list