aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/APValue.h
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-10 00:28:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-10 00:28:11 +0000
commit0069b84c2aa7cc39263e85997b7cb1ed0b132ccd (patch)
tree0a1829e841beb468d9a25fc474a8b9b5b662be56 /include/clang/AST/APValue.h
parent97c1fd651c24638a4989b4e1f8eb2e629c2073d1 (diff)
Assign APValues by swapping from a temporary. Removes a bunch of unnecessary
copy-construction, which Daniel Dunbar reports as giving a 0.75% speedup on 403.gcc/combine.c. The performance differences on my constexpr torture tests are below the noise floor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/APValue.h')
-rw-r--r--include/clang/AST/APValue.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/clang/AST/APValue.h b/include/clang/AST/APValue.h
index b7e588fba4..1b6e90cf4a 100644
--- a/include/clang/AST/APValue.h
+++ b/include/clang/AST/APValue.h
@@ -135,9 +135,7 @@ public:
APValue(const APFloat &R, const APFloat &I) : Kind(Uninitialized) {
MakeComplexFloat(); setComplexFloat(R, I);
}
- APValue(const APValue &RHS) : Kind(Uninitialized) {
- *this = RHS;
- }
+ APValue(const APValue &RHS);
APValue(LValueBase B, const CharUnits &O, NoLValuePath N, unsigned CallIndex)
: Kind(Uninitialized) {
MakeLValue(); setLValue(B, O, N, CallIndex);
@@ -170,6 +168,9 @@ public:
MakeUninit();
}
+ /// \brief Swaps the contents of this and the given APValue.
+ void swap(APValue &RHS);
+
ValueKind getKind() const { return Kind; }
bool isUninit() const { return Kind == Uninitialized; }
bool isInt() const { return Kind == Int; }
@@ -382,7 +383,11 @@ public:
((AddrLabelDiffData*)(char*)Data)->RHSExpr = RHSExpr;
}
- const APValue &operator=(const APValue &RHS);
+ /// Assign by swapping from a copy of the RHS.
+ APValue &operator=(APValue RHS) {
+ swap(RHS);
+ return *this;
+ }
private:
void DestroyDataAndMakeUninit();