[cfe-commits] r99442 - /cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp

Ted Kremenek kremenek at apple.com
Wed Mar 24 15:39:47 PDT 2010


Author: kremenek
Date: Wed Mar 24 17:39:47 2010
New Revision: 99442

URL: http://llvm.org/viewvc/llvm-project?rev=99442&view=rev
Log:
Use llvm::SmallString instead of std::string.

Modified:
    cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp

Modified: cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp?rev=99442&r1=99441&r2=99442&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp (original)
+++ cfe/trunk/lib/Checker/CheckSecuritySyntaxOnly.cpp Wed Mar 24 17:39:47 2010
@@ -36,7 +36,7 @@
   IdentifierInfo *II_random;
   enum { num_setids = 6 };
   IdentifierInfo *II_setid[num_setids];
-  
+
   const bool CheckRand;
 
 public:
@@ -214,8 +214,8 @@
   const DeclRefExpr *drCond = vdLHS == drInc->getDecl() ? drLHS : drRHS;
 
   llvm::SmallVector<SourceRange, 2> ranges;
-  std::string sbuf;
-  llvm::raw_string_ostream os(sbuf);
+  llvm::SmallString<256> sbuf;
+  llvm::raw_svector_ostream os(sbuf);
 
   os << "Variable '" << drCond->getDecl()->getNameAsCString()
      << "' with floating point type '" << drCond->getType().getAsString()
@@ -315,7 +315,7 @@
   const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FD->getType());
   if(!FPT)
     return;
-  
+
   // Verify that the funcion takes a single argument.
   if (FPT->getNumArgs() != 1)
     return;
@@ -385,20 +385,18 @@
     return;
 
   // Issue a warning.
-  std::string buf1;
-  llvm::raw_string_ostream os1(buf1);
+  llvm::SmallString<256> buf1;
+  llvm::raw_svector_ostream os1(buf1);
   os1 << "'" << FD->getNameAsString() << "' is a poor random number generator";
 
-  std::string buf2;
-  llvm::raw_string_ostream os2(buf2);
+  llvm::SmallString<256> buf2;
+  llvm::raw_svector_ostream os2(buf2);
   os2 << "Function '" << FD->getNameAsString()
       << "' is obsolete because it implements a poor random number generator."
       << "  Use 'arc4random' instead";
 
   SourceRange R = CE->getCallee()->getSourceRange();
-
-  BR.EmitBasicReport(os1.str(), "Security", os2.str(),
-                     CE->getLocStart(), &R, 1);
+  BR.EmitBasicReport(os1.str(), "Security", os2.str(),CE->getLocStart(), &R, 1);
 }
 
 //===----------------------------------------------------------------------===//
@@ -424,8 +422,7 @@
                      "Security",
                      "The 'random' function produces a sequence of values that "
                      "an adversary may be able to predict.  Use 'arc4random' "
-                     "instead",
-                     CE->getLocStart(), &R, 1);
+                     "instead", CE->getLocStart(), &R, 1);
 }
 
 //===----------------------------------------------------------------------===//
@@ -473,22 +470,20 @@
       return;
 
   // Issue a warning.
-  std::string buf1;
-  llvm::raw_string_ostream os1(buf1);
+  llvm::SmallString<256> buf1;
+  llvm::raw_svector_ostream os1(buf1);
   os1 << "Return value is not checked in call to '" << FD->getNameAsString()
      << "'";
 
-  std::string buf2;
-  llvm::raw_string_ostream os2(buf2);
+  llvm::SmallString<256> buf2;
+  llvm::raw_svector_ostream os2(buf2);
   os2 << "The return value from the call to '" << FD->getNameAsString()
       << "' is not checked.  If an error occurs in '"
       << FD->getNameAsString()
       << "', the following code may execute with unexpected privileges";
 
   SourceRange R = CE->getCallee()->getSourceRange();
-
-  BR.EmitBasicReport(os1.str(), "Security", os2.str(),
-                     CE->getLocStart(), &R, 1);
+  BR.EmitBasicReport(os1.str(), "Security", os2.str(),CE->getLocStart(), &R, 1);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list