On 07.06.2012, at 17:31, Dmitri Gribenko wrote: > Hi Benjamin, > > On Thu, Jun 7, 2012 at 8:09 AM, Benjamin Kramer > <[email protected]> wrote: >> Modified: cfe/trunk/lib/AST/TemplateBase.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateBase.cpp?rev=158150&r1=158149&r2=158150&view=diff >> ============================================================================== >> --- cfe/trunk/lib/AST/TemplateBase.cpp (original) >> +++ cfe/trunk/lib/AST/TemplateBase.cpp Thu Jun 7 10:09:51 2012 >> @@ -36,17 +36,17 @@ >> static void printIntegral(const TemplateArgument &TemplArg, >> raw_ostream &Out) { >> const ::clang::Type *T = TemplArg.getIntegralType().getTypePtr(); >> - const llvm::APSInt *Val = TemplArg.getAsIntegral(); >> + const llvm::APSInt &Val = TemplArg.getAsIntegral(); >> >> if (T->isBooleanType()) { >> - Out << (Val->getBoolValue() ? "true" : "false"); >> + Out << (Val.getBoolValue() ? "true" : "false"); >> } else if (T->isCharType()) { >> - const char Ch = Val->getZExtValue(); >> + const char Ch = Val.getZExtValue(); >> Out << ((Ch == '\'') ? "'\\" : "'"); >> Out.write_escaped(StringRef(&Ch, 1), /*UseHexEscapes=*/ true); >> Out << "'"; >> } else { >> - Out << Val->toString(10); >> + Out << Val; >> } >> } >> >> @@ -54,6 +54,24 @@ >> // TemplateArgument Implementation >> >> //===----------------------------------------------------------------------===// >> >> +TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt >> &Value, >> + QualType Type) >> + : Kind(Integral) { >> + // Copy the APSInt value into our decomposed form. >> + 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); > > Shouldn't this be something like: > Ctx.Allocate(Value.getNumWords() * sizeof(uint64_t)); ? > > These two expressions differ when BitWidth is not a multiple of > APINT_BITS_PER_WORD. > > Same thing in other places where expression Integer.BitWidth / 8 is used.
Oops, fixed in r158151. Thanks Dmitri! - Ben _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
