summaryrefslogtreecommitdiffstats
path: root/clang/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
commit5d4cff72b4c0e2c3cbb3f784c869d5b68427208f (patch)
treeaec5241c003b9cb5d61db334dc7544b18a31086a /clang/lib/AST/TemplateBase.cpp
parent6003ad584890456e7a3b3a970413a9f2e1d921f2 (diff)
downloadbcm5719-llvm-5d4cff72b4c0e2c3cbb3f784c869d5b68427208f.tar.gz
bcm5719-llvm-5d4cff72b4c0e2c3cbb3f784c869d5b68427208f.zip
Reuse APInt's getNumWords, which gets rounding right (my ad-hoc solution missed it).
llvm-svn: 158151
Diffstat (limited to 'clang/lib/AST/TemplateBase.cpp')
-rw-r--r--clang/lib/AST/TemplateBase.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index 284c1b5baae..f8dd396d92d 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud