Author: dgregor
Date: Sat Dec 12 01:48:51 2009
New Revision: 91212

URL: http://llvm.org/viewvc/llvm-project?rev=91212&view=rev
Log:
Give PartialDiagnostic copy semantics rather than move semantics, since we 
typically pass it by reference

Modified:
    cfe/trunk/include/clang/Basic/PartialDiagnostic.h

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

==============================================================================
--- cfe/trunk/include/clang/Basic/PartialDiagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/PartialDiagnostic.h Sat Dec 12 01:48:51 2009
@@ -51,11 +51,11 @@
     /// This is used when the argument is not an std::string. The specific 
value 
     /// is mangled into an intptr_t and the intepretation depends on exactly
     /// what sort of argument kind it is.
-    mutable intptr_t DiagArgumentsVal[MaxArguments];
+    intptr_t DiagArgumentsVal[MaxArguments];
   
     /// DiagRanges - The list of ranges added to this diagnostic.  It currently
     /// only support 10 ranges, could easily be extended if needed.
-    mutable SourceRange DiagRanges[10];
+    SourceRange DiagRanges[10];
   };
 
   /// DiagID - The diagnostic ID.
@@ -84,22 +84,37 @@
     DiagStorage->DiagRanges[DiagStorage->NumDiagRanges++] = R;
   }  
 
-  void operator=(const PartialDiagnostic &); // DO NOT IMPLEMENT
-
 public:
   PartialDiagnostic(unsigned DiagID)
     : DiagID(DiagID), DiagStorage(0) { }
 
   PartialDiagnostic(const PartialDiagnostic &Other) 
-    : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage) {
-    Other.DiagID = 0;
-    Other.DiagStorage = 0;
+    : DiagID(Other.DiagID), DiagStorage(0) 
+  {
+    if (Other.DiagStorage)
+      DiagStorage = new Storage(*Other.DiagStorage);
+  }
+
+  PartialDiagnostic &operator=(const PartialDiagnostic &Other) {
+    DiagID = Other.DiagID;
+    if (Other.DiagStorage) {
+      if (DiagStorage)
+        *DiagStorage = *Other.DiagStorage;
+      else
+        DiagStorage = new Storage(*Other.DiagStorage);
+    } else {
+      delete DiagStorage;
+      DiagStorage = 0;
+    }
+
+    return *this;
   }
 
   ~PartialDiagnostic() {
     delete DiagStorage;
   }
 
+
   unsigned getDiagID() const { return DiagID; }
 
   void Emit(const DiagnosticBuilder &DB) const {


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to