From: Mike Stump Date: Sat, 30 May 2009 14:43:18 +0000 (+0000) Subject: Cleqnup ideas from Chris, thanks. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7462b39a9bccaf4392687831036713f09f9c0681;p=clang Cleqnup ideas from Chris, thanks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72621 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index eac73eaf2f..4ad2bec53b 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -17,6 +17,7 @@ #include "clang/AST/StmtVisitor.h" #include "clang/AST/ASTDiagnostic.h" #include "clang/Basic/TargetInfo.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/Compiler.h" #include @@ -1320,13 +1321,13 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { if (!S->isWide()) { const llvm::fltSemantics &Sem = Info.Ctx.getFloatTypeSemantics(E->getType()); - char *s = (char *)malloc (S->getByteLength()+1); - memcpy(s, S->getStrData(), S->getByteLength()); - s[S->getByteLength()] = 0; + llvm::SmallString<16> s; + s.append(S->getStrData(), S->getStrData() + S->getByteLength()); + s += '\0'; long l; char *endp; - l = strtol(S->getStrData(), &endp, 0); - if (endp != (S->getStrData() + S->getByteLength())) + l = strtol(&s[0], &endp, 0); + if (endp != s.end()-1) return false; unsigned type = (unsigned int)l;; Result = llvm::APFloat::getNaN(Sem, false, type);