aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-12 07:48:51 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-12 07:48:51 +0000
commita63d40f85c4621f5ad2362e0d00879933625404b (patch)
tree324510d323834cbe4aeda407bb93e09ea8f68602
parentcc5ee6be70278def952fdbe0a3ec2b4ff79b05e8 (diff)
Give PartialDiagnostic copy semantics rather than move semantics, since we typically pass it by reference
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91212 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/PartialDiagnostic.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index 766aac1526..ae11a755cc 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -51,11 +51,11 @@ class PartialDiagnostic {
/// 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 @@ class PartialDiagnostic {
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 {