diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-03-24 22:39:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-03-24 22:39:47 +0000 |
commit | 2c01676f4f613d884b174e8e19d6da0a3c45a23c (patch) | |
tree | 98a3bb12de08e7380bb8817154ed2966d0c1d499 /lib/Checker/CheckSecuritySyntaxOnly.cpp | |
parent | 431a2cb703af68b4c2cc2b6df08999fce7b0b689 (diff) |
Use llvm::SmallString instead of std::string.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/CheckSecuritySyntaxOnly.cpp')
-rw-r--r-- | lib/Checker/CheckSecuritySyntaxOnly.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/Checker/CheckSecuritySyntaxOnly.cpp b/lib/Checker/CheckSecuritySyntaxOnly.cpp index 98a739b07d..efbce61261 100644 --- a/lib/Checker/CheckSecuritySyntaxOnly.cpp +++ b/lib/Checker/CheckSecuritySyntaxOnly.cpp @@ -36,7 +36,7 @@ class WalkAST : public StmtVisitor<WalkAST> { IdentifierInfo *II_random; enum { num_setids = 6 }; IdentifierInfo *II_setid[num_setids]; - + const bool CheckRand; public: @@ -214,8 +214,8 @@ void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) { 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 @@ void WalkAST::CheckCall_mktemp(const CallExpr *CE, const FunctionDecl *FD) { 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 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) { 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 @@ void WalkAST::CheckCall_random(const CallExpr *CE, const FunctionDecl *FD) { "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 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) { 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); } //===----------------------------------------------------------------------===// |