diff options
| author | Mike Stump <mrs@apple.com> | 2009-05-30 14:43:18 +0000 |
|---|---|---|
| committer | Mike Stump <mrs@apple.com> | 2009-05-30 14:43:18 +0000 |
| commit | b807c9c6220f7084d96eca1e4854bb44a1ce1bd7 (patch) | |
| tree | b3d5f916a2f9d62daeb6b403108b4e2fad428a74 /clang/lib/AST | |
| parent | 24ad1feb776cd4569356a9548ca0326dbc69d1c7 (diff) | |
| download | bcm5719-llvm-b807c9c6220f7084d96eca1e4854bb44a1ce1bd7.tar.gz bcm5719-llvm-b807c9c6220f7084d96eca1e4854bb44a1ce1bd7.zip | |
Cleqnup ideas from Chris, thanks.
llvm-svn: 72621
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index eac73eaf2f4..4ad2bec53bc 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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 <cstring> @@ -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); |

