[cfe-commits] r146535 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h lib/StaticAnalyzer/Core/ProgramState.cpp

Anna Zaks ganna at apple.com
Tue Dec 13 16:56:15 PST 2011


Author: zaks
Date: Tue Dec 13 18:56:15 2011
New Revision: 146535

URL: http://llvm.org/viewvc/llvm-project?rev=146535&view=rev
Log:
[analyzer] Minor refactor to addTaint.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
    cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=146535&r1=146534&r2=146535&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h Tue Dec 13 18:56:15 2011
@@ -297,6 +297,10 @@
   const ProgramState* addTaint(SymbolRef S,
                                TaintTagType Kind = TaintTagGeneric) const;
 
+  /// Create a new state in which the region symbol is marked as tainted.
+  const ProgramState* addTaint(const MemRegion *R,
+                               TaintTagType Kind = TaintTagGeneric) const;
+
   /// Check if the statement is tainted in the current state.
   bool isTainted(const Stmt *S, TaintTagType Kind = TaintTagGeneric) const;
   bool isTainted(SVal V, TaintTagType Kind = TaintTagGeneric) const;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=146535&r1=146534&r2=146535&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Tue Dec 13 18:56:15 2011
@@ -658,13 +658,19 @@
     return addTaint(Sym, Kind);
 
   const MemRegion *R = getSVal(S).getAsRegion();
-  if (const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
-    return addTaint(SR->getSymbol(), Kind);
+  addTaint(R, Kind);
 
   // Cannot add taint, so just return the state.
   return this;
 }
 
+const ProgramState* ProgramState::addTaint(const MemRegion *R,
+                                           TaintTagType Kind) const {
+  if (const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
+    return addTaint(SR->getSymbol(), Kind);
+  return this;
+}
+
 const ProgramState* ProgramState::addTaint(SymbolRef Sym,
                                            TaintTagType Kind) const {
   const ProgramState *NewState = set<TaintMap>(Sym, Kind);





More information about the cfe-commits mailing list