[cfe-commits] r65083 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/Basic/Diagnostic.h lib/Basic/Diagnostic.cpp lib/Sema/Sema.cpp

Chris Lattner sabre at nondot.org
Thu Feb 19 15:53:21 PST 2009


Author: lattner
Date: Thu Feb 19 17:53:20 2009
New Revision: 65083

URL: http://llvm.org/viewvc/llvm-project?rev=65083&view=rev
Log:
replace a dirty hack with a clean solution.  Too bad we can't 
use Blocks for our callbacks ;-)


Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/Basic/Diagnostic.h
    cfe/trunk/lib/Basic/Diagnostic.cpp
    cfe/trunk/lib/Sema/Sema.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=65083&r1=65082&r2=65083&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Feb 19 17:53:20 2009
@@ -283,7 +283,8 @@
   /// ObjCQualifiedInterfaceType type for the given interface decl and
   /// the conforming protocol list.
   QualType getObjCQualifiedInterfaceType(ObjCInterfaceDecl *Decl,
-             ObjCProtocolDecl **ProtocolList, unsigned NumProtocols);
+                                         ObjCProtocolDecl **ProtocolList,
+                                         unsigned NumProtocols);
   
   /// getObjCQualifiedIdType - Return an ObjCQualifiedIdType for a 
   /// given 'id' and conforming protocol list.

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

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Feb 19 17:53:20 2009
@@ -125,7 +125,9 @@
   typedef void (*ArgToStringFnTy)(ArgumentKind Kind, intptr_t Val,
                                   const char *Modifier, unsigned ModifierLen,
                                   const char *Argument, unsigned ArgumentLen,
-                                  llvm::SmallVectorImpl<char> &Output);
+                                  llvm::SmallVectorImpl<char> &Output,
+                                  void *Cookie);
+  void *ArgToStringCookie;
   ArgToStringFnTy ArgToStringFn;
 public:
   explicit Diagnostic(DiagnosticClient *client = 0);
@@ -202,11 +204,13 @@
                           const char *Modifier, unsigned ModLen,
                           const char *Argument, unsigned ArgLen,
                           llvm::SmallVectorImpl<char> &Output) const {
-    ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, Output);
+    ArgToStringFn(Kind, Val, Modifier, ModLen, Argument, ArgLen, Output,
+                  ArgToStringCookie);
   }
   
-  void SetArgToStringFn(ArgToStringFnTy Fn) {
+  void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie) {
     ArgToStringFn = Fn;
+    ArgToStringCookie = Cookie;
   }
   
   //===--------------------------------------------------------------------===//

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

==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Feb 19 17:53:20 2009
@@ -175,7 +175,8 @@
 static void DummyArgToStringFn(Diagnostic::ArgumentKind AK, intptr_t QT,
                                const char *Modifier, unsigned ML,
                                const char *Argument, unsigned ArgLen,
-                               llvm::SmallVectorImpl<char> &Output) {
+                               llvm::SmallVectorImpl<char> &Output,
+                               void *Cookie) {
   const char *Str = "<can't format argument>";
   Output.append(Str, Str+strlen(Str));
 }
@@ -199,6 +200,7 @@
   LastDiagLevel = Fatal;
   
   ArgToStringFn = DummyArgToStringFn;
+  ArgToStringCookie = 0;
 }
 
 Diagnostic::~Diagnostic() {

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Feb 19 17:53:20 2009
@@ -24,7 +24,9 @@
 static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
                                  const char *Modifier, unsigned ModLen,
                                  const char *Argument, unsigned ArgLen,
-                                 llvm::SmallVectorImpl<char> &Output) {
+                                 llvm::SmallVectorImpl<char> &Output,
+                                 void *Cookie) {
+  ASTContext &Context = *static_cast<ASTContext*>(Cookie);
   
   std::string S;
   if (Kind == Diagnostic::ak_qualtype) {
@@ -47,8 +49,14 @@
         // it will turn into an attribute mess. People want their "vec4".
         !isa<VectorType>(DesugaredTy) &&
       
-        // Don't desugar objc types.  FIXME: THIS IS A HACK.
-        S != "id" && S != "Class") {
+        // Don't desugar magic Objective-C types.
+        Ty.getUnqualifiedType() != Context.getObjCIdType() &&
+        Ty.getUnqualifiedType() != Context.getObjCSelType() &&
+        Ty.getUnqualifiedType() != Context.getObjCProtoType() &&
+        Ty.getUnqualifiedType() != Context.getObjCClassType() &&
+        
+        // Not va_list.
+        Ty.getUnqualifiedType() != Context.getBuiltinVaListType()) {
       S = "'"+S+"' (aka '";
       S += DesugaredTy.getAsString();
       S += "')";
@@ -165,7 +173,7 @@
     FieldCollector.reset(new CXXFieldCollector());
       
   // Tell diagnostics how to render things from the AST library.
-  PP.getDiagnostics().SetArgToStringFn(ConvertArgToStringFn);
+  PP.getDiagnostics().SetArgToStringFn(ConvertArgToStringFn, &Context);
 }
 
 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast. 





More information about the cfe-commits mailing list