aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TemplateBase.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-06-07 15:54:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-06-07 15:54:03 +0000
commitb8e54cd26cc71075456a74be054a95fa1f2e28ad (patch)
tree690831b4ba1e70f5dd1883e6af2e735d252fd57a /lib/AST/TemplateBase.cpp
parent855243789cb44799c03f4c7216d3d6308805f549 (diff)
Reuse APInt's getNumWords, which gets rounding right (my ad-hoc solution missed it).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158151 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TemplateBase.cpp')
-rw-r--r--lib/AST/TemplateBase.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp
index 284c1b5baa..f8dd396d92 100644
--- a/lib/AST/TemplateBase.cpp
+++ b/lib/AST/TemplateBase.cpp
@@ -61,9 +61,10 @@ TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
Integer.BitWidth = Value.getBitWidth();
Integer.IsUnsigned = Value.isUnsigned();
// If the value is large, we have to get additional memory from the ASTContext
- if (Integer.BitWidth > 64) {
- void *Mem = Ctx.Allocate(Integer.BitWidth / 8);
- std::memcpy(Mem, Value.getRawData(), Integer.BitWidth / 8);
+ unsigned NumWords = Value.getNumWords();
+ if (NumWords > 1) {
+ void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
+ std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
Integer.pVal = static_cast<uint64_t *>(Mem);
} else {
Integer.VAL = Value.getZExtValue();