summaryrefslogtreecommitdiffstats
path: root/include/clang/Basic/PartialDiagnostic.h
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-12-06 19:09:30 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-12-06 19:09:30 +0000
commit407a82fb22acad58be27f096748e74c83a295c40 (patch)
tree62aeb708e922e2a69da059dc80977292bc943ae1 /include/clang/Basic/PartialDiagnostic.h
parent2ab3b6d79434b57bb591dbb5493b3e400dae4eb8 (diff)
Add move semantics to PartialDiagnostic, which can be very expensive to copy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/PartialDiagnostic.h')
-rw-r--r--include/clang/Basic/PartialDiagnostic.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/clang/Basic/PartialDiagnostic.h b/include/clang/Basic/PartialDiagnostic.h
index 3f4626ec0a..63363a9e93 100644
--- a/include/clang/Basic/PartialDiagnostic.h
+++ b/include/clang/Basic/PartialDiagnostic.h
@@ -19,6 +19,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
@@ -200,6 +201,14 @@ public:
}
}
+#if LLVM_HAS_RVALUE_REFERENCES
+ PartialDiagnostic(PartialDiagnostic &&Other)
+ : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),
+ Allocator(Other.Allocator) {
+ Other.DiagStorage = 0;
+ }
+#endif
+
PartialDiagnostic(const PartialDiagnostic &Other, Storage *DiagStorage)
: DiagID(Other.DiagID), DiagStorage(DiagStorage),
Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0)))
@@ -242,6 +251,23 @@ public:
return *this;
}
+#if LLVM_HAS_RVALUE_REFERENCES
+ PartialDiagnostic &operator=(PartialDiagnostic &&Other) {
+ if (this != &Other) {
+ if (DiagStorage)
+ freeStorage();
+
+ DiagID = Other.DiagID;
+ DiagStorage = Other.DiagStorage;
+ Allocator = Other.Allocator;
+
+ Other.DiagStorage = 0;
+ }
+
+ return *this;
+ }
+#endif
+
~PartialDiagnostic() {
freeStorage();
}