]> granicus.if.org Git - clang/commitdiff
Resolve a layering violation by making AddTaggedVal public for
authorChandler Carruth <chandlerc@gmail.com>
Fri, 2 Apr 2010 01:39:03 +0000 (01:39 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 2 Apr 2010 01:39:03 +0000 (01:39 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100169 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclarationName.h
include/clang/AST/Type.h
include/clang/Basic/PartialDiagnostic.h

index 2254724410d0bf9644046589b5865998429c78c1..6225069c602fef5525418a3dfe6c24533408d7da 100644 (file)
@@ -378,7 +378,7 @@ inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
                   Diagnostic::ak_declarationname);
   return PD;
 }
-  
+
 }  // end namespace clang
 
 namespace llvm {
index b500b6cb00be2ec55e964c7e28072f8564058170..72793651c4be9fd1c6c773b7fbbfe95cb1d86bb0 100644 (file)
@@ -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 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
   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,
index de858eadb68efe2a0e420e2cc3c198cb77755765..89fae87ae8ef997ed92337733449ad790a6e3cba 100644 (file)
@@ -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 @@ private:
     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 @@ public:
 
   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;
@@ -247,13 +244,6 @@ public:
   
   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);
@@ -278,9 +268,6 @@ public:
     return PD;
   }
 
-  friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
-                                             DeclarationName N);
-  
   friend const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
                                              const FixItHint &Hint) {
     PD.AddFixItHint(Hint);