[cfe-commits] r100169 - in /cfe/trunk/include/clang: AST/DeclarationName.h AST/Type.h Basic/PartialDiagnostic.h

Chandler Carruth chandlerc at gmail.com
Thu Apr 1 18:39:03 PDT 2010


Author: chandlerc
Date: Thu Apr  1 20:39:03 2010
New Revision: 100169

URL: http://llvm.org/viewvc/llvm-project?rev=100169&view=rev
Log:
Resolve a layering violation by making AddTaggedVal public for
PartialDiagnostic objects, and hoisting the stream operator for QualType into
Type.h with the operator for the normal DiagnosticBuilder. Also remove the no
longer needed friend declaration for the DeclarationName stream operator.

Modified:
    cfe/trunk/include/clang/AST/DeclarationName.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/include/clang/Basic/PartialDiagnostic.h

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=100169&r1=100168&r2=100169&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Thu Apr  1 20:39:03 2010
@@ -378,7 +378,7 @@
                   Diagnostic::ak_declarationname);
   return PD;
 }
-  
+
 }  // end namespace clang
 
 namespace llvm {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=100169&r1=100168&r2=100169&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Apr  1 20:39:03 2010
@@ -17,6 +17,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/Linkage.h"
+#include "clang/Basic/PartialDiagnostic.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/TemplateName.h"
 #include "llvm/Support/Casting.h"
@@ -3229,6 +3230,15 @@
   return DB;
 }
 
+/// Insertion operator for partial diagnostics.  This allows sending QualType's
+/// into a diagnostic with <<.
+inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
+                                           QualType T) {
+  PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()),
+                  Diagnostic::ak_qualtype);
+  return PD;
+}
+
 // Helper class template that is used by Type::getAs to ensure that one does
 // not try to look through a qualified type to get to an array type.
 template<typename T,

Modified: cfe/trunk/include/clang/Basic/PartialDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/PartialDiagnostic.h?rev=100169&r1=100168&r2=100169&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/PartialDiagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/PartialDiagnostic.h Thu Apr  1 20:39:03 2010
@@ -15,7 +15,6 @@
 #ifndef LLVM_CLANG_PARTIALDIAGNOSTIC_H
 #define LLVM_CLANG_PARTIALDIAGNOSTIC_H
 
-#include "clang/AST/Type.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/STLExtras.h"
@@ -24,8 +23,6 @@
 
 namespace clang {
 
-class DeclarationName;
-  
 class PartialDiagnostic {
 public:
   struct Storage {
@@ -145,16 +142,6 @@
     DiagStorage = 0;
   }
   
-  void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const {
-    if (!DiagStorage)
-      DiagStorage = getStorage();
-    
-    assert(DiagStorage->NumDiagArgs < Storage::MaxArguments &&
-           "Too many arguments to diagnostic!");
-    DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = Kind;
-    DiagStorage->DiagArgumentsVal[DiagStorage->NumDiagArgs++] = V;
-  }
-
   void AddSourceRange(const SourceRange &R) const {
     if (!DiagStorage)
       DiagStorage = getStorage();
@@ -219,6 +206,16 @@
 
   unsigned getDiagID() const { return DiagID; }
 
+  void AddTaggedVal(intptr_t V, Diagnostic::ArgumentKind Kind) const {
+    if (!DiagStorage)
+      DiagStorage = getStorage();
+
+    assert(DiagStorage->NumDiagArgs < Storage::MaxArguments &&
+           "Too many arguments to diagnostic!");
+    DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = Kind;
+    DiagStorage->DiagArgumentsVal[DiagStorage->NumDiagArgs++] = V;
+  }
+
   void Emit(const DiagnosticBuilder &DB) const {
     if (!DiagStorage)
       return;
@@ -248,13 +245,6 @@
   bool hasStorage() const { return DiagStorage != 0; }
   
   friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
-                                             QualType T) {
-    PD.AddTaggedVal(reinterpret_cast<intptr_t>(T.getAsOpaquePtr()),
-                    Diagnostic::ak_qualtype);
-    return PD;
-  }
-
-  friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
                                              unsigned I) {
     PD.AddTaggedVal(I, Diagnostic::ak_uint);
     return PD;
@@ -279,9 +269,6 @@
   }
 
   friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
-                                             DeclarationName N);
-  
-  friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
                                              const FixItHint &Hint) {
     PD.AddFixItHint(Hint);
     return PD;





More information about the cfe-commits mailing list