[cfe-commits] r91118 - /cfe/trunk/lib/AST/ExprConstant.cpp

Benjamin Kramer benny.kra at googlemail.com
Fri Dec 11 05:26:33 PST 2009


Author: d0k
Date: Fri Dec 11 07:26:32 2009
New Revision: 91118

URL: http://llvm.org/viewvc/llvm-project?rev=91118&view=rev
Log:
Use StringRef.getAsInteger instead of temporary string + strtol. No intended functionality change.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=91118&r1=91117&r2=91118&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Dec 11 07:26:32 2009
@@ -1548,16 +1548,10 @@
       if (!S->isWide()) {
         const llvm::fltSemantics &Sem =
           Info.Ctx.getFloatTypeSemantics(E->getType());
-        llvm::SmallString<16> s;
-        s.append(S->getStrData(), S->getStrData() + S->getByteLength());
-        s += '\0';
-        long l;
-        char *endp;
-        l = strtol(&s[0], &endp, 0);
-        if (endp != s.end()-1)
+        unsigned Type = 0;
+        if (!S->getString().empty() && S->getString().getAsInteger(0, Type))
           return false;
-        unsigned type = (unsigned int)l;;
-        Result = llvm::APFloat::getNaN(Sem, false, type);
+        Result = llvm::APFloat::getNaN(Sem, false, Type);
         return true;
       }
     }





More information about the cfe-commits mailing list