]> granicus.if.org Git - clang/commitdiff
Revert my last couple patches until I can get them to not make the tests fail.
authorTed Kremenek <kremenek@apple.com>
Sat, 7 Mar 2009 01:47:10 +0000 (01:47 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 7 Mar 2009 01:47:10 +0000 (01:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66317 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
include/clang/Basic/IdentifierTable.h
lib/Basic/Diagnostic.cpp
lib/Sema/SemaDeclObjC.cpp

index 9dfcf3fe75a5787a0d9d06f4e0aa2d8d78919c52..1bb294e7a488640754b28d98e4cc548ad737c8f4 100644 (file)
@@ -15,7 +15,6 @@
 #define LLVM_CLANG_DIAGNOSTIC_H
 
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/IdentifierTable.h"
 #include <string>
 #include <cassert>
 
@@ -27,6 +26,7 @@ namespace clang {
   class DiagnosticClient;
   class SourceRange;
   class DiagnosticBuilder;
+  class IdentifierInfo;
   
   // Import the diagnostic enums themselves.
   namespace diag {
@@ -142,8 +142,7 @@ public:
     ak_identifierinfo,  // IdentifierInfo
     ak_qualtype,        // QualType
     ak_declarationname, // DeclarationName
-    ak_nameddecl,       // NamedDecl *
-    ak_selector         // Selector
+    ak_nameddecl        // NamedDecl *
   };
   
 private:  
@@ -484,13 +483,6 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
   return DB;
 }
   
-inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
-                                           Selector S) {
-  DB.AddTaggedVal(reinterpret_cast<intptr_t>(S.getAsOpaquePtr()),
-                  Diagnostic::ak_selector);
-  return DB;
-}  
-  
 inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
                                            const SourceRange &R) {
   DB.AddSourceRange(R);
@@ -574,12 +566,6 @@ public:
     return reinterpret_cast<IdentifierInfo*>(DiagObj->DiagArgumentsVal[Idx]);
   }
   
-  /// getArgSelector - Return the specified Selector argument.
-  Selector getArgSelector(unsigned Idx) const {
-    assert(getArgKind(Idx) == Diagnostic::ak_selector &&
-           "invalid argument accessor!");
-    return Selector(DiagObj->DiagArgumentsVal[Idx]);
-  }
   /// getRawArg - Return the specified non-string argument in an opaque form.
   intptr_t getRawArg(unsigned Idx) const {
     assert(getArgKind(Idx) != Diagnostic::ak_std_string &&
index 93651d3d91abd970a0ffd5074f7c95bdaf7c452b..32818a91371020771705a4939c3648fb61ca6e98 100644 (file)
@@ -267,27 +267,24 @@ public:
       HashTable.GetOrCreateValue(NameStart, NameEnd);
     
     IdentifierInfo *II = Entry.getValue();
-    if (II) return *II;
     
-    // No entry; if we have an external lookup, look there first.
-    if (ExternalLookup) {
-      II = ExternalLookup->get(NameStart, NameEnd);
-      if (II) {
-        // Cache in the StringMap for subsequent lookups.
-        Entry.setValue(II);
-        return *II;
+    if (!II) {
+      while (1) {
+        if (ExternalLookup) {
+          II = ExternalLookup->get(NameStart, NameEnd);          
+          if (II) break;
+        }
+        
+        void *Mem = getAllocator().Allocate<IdentifierInfo>();
+        II = new (Mem) IdentifierInfo();
+        break;
       }
-    }
-
-    // Lookups failed, make a new IdentifierInfo.
-    void *Mem = getAllocator().Allocate<IdentifierInfo>();
-    II = new (Mem) IdentifierInfo();
-    Entry.setValue(II);
 
-    // Make sure getName() knows how to find the IdentifierInfo
-    // contents.
-    II->Entry = &Entry;
+      Entry.setValue(II);
+      II->Entry = &Entry;
+    }
 
+    assert(II->Entry != 0);
     return *II;
   }
   
@@ -337,8 +334,6 @@ private:
 /// selectors that take no arguments and selectors that take 1 argument, which 
 /// accounts for 78% of all selectors in Cocoa.h.
 class Selector {
-  friend class DiagnosticInfo;
-  
   enum IdentifierInfoFlag {
     // MultiKeywordSelector = 0.
     ZeroArg  = 0x1,
@@ -358,6 +353,13 @@ class Selector {
     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())
@@ -367,14 +369,6 @@ class Selector {
   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;
index 84d4055b78e6fbdf6a99976c16d41950c8ea9ea5..893eae5d1a97d6f3338e705a5f7f4a1fddc722fe 100644 (file)
@@ -657,14 +657,6 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
       OutStr.push_back('\'');
       break;
     }
-    case Diagnostic::ak_selector: {
-      Selector S = getArgSelector(ArgNo);
-      OutStr.push_back('\'');
-      const std::string &s = S.getAsString();
-      OutStr.append(&s[0], &s[0]+s.length());
-      OutStr.push_back('\'');
-      break;
-    }
     case Diagnostic::ak_qualtype:
     case Diagnostic::ak_declarationname:
     case Diagnostic::ak_nameddecl:
index a26581824f9cada497429bdf706caf0c413f3a6f..476b6afea57151c62ae54f1f6f82f7f1193564ed 100644 (file)
@@ -1139,7 +1139,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
     Diag(property->getLocation(), 
          diag::err_accessor_property_type_mismatch) 
       << property->getDeclName()
-      << GetterMethod->getSelector();
+      << GetterMethod->getSelector().getAsIdentifierInfo();
     Diag(GetterMethod->getLocation(), diag::note_declared_at);
   }
   
@@ -1152,7 +1152,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
       Diag(property->getLocation(), 
            diag::err_accessor_property_type_mismatch) 
         << property->getDeclName()
-        << SetterMethod->getSelector();
+        << SetterMethod->getSelector().getAsIdentifierInfo();
       Diag(SetterMethod->getLocation(), diag::note_declared_at);
     }
   }