33 TaintMapTy TM = State->get<TaintMap>();
36 Out <<
"Tainted symbols:" << NL;
38 for (
const auto &I : TM)
39 Out << I.first <<
" : " << I.second << NL;
49 return addTaint(State, State->getSVal(S, LCtx), Kind);
68 if (std::optional<SVal> binding =
69 State->getStateManager().getStoreManager().getDefaultBinding(
71 if (
SymbolRef Sym = binding->getAsSymbol())
82 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
83 return addTaint(State, SR->getSymbol(), Kind);
91 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
92 Sym = SC->getOperand();
109 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
117 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
118 Sym = SC->getOperand();
136 return addTaint(State, ParentSym, Kind);
138 const TaintedSubRegions *SavedRegs = State->get<DerivedSymTaint>(ParentSym);
139 TaintedSubRegions::Factory &F = State->get_context<TaintedSubRegions>();
140 TaintedSubRegions Regs = SavedRegs ? *SavedRegs : F.getEmptyMap();
143 ProgramStateRef NewState = State->set<DerivedSymTaint>(ParentSym, Regs);
198 bool returnFirstOnly) {
199 SVal val = State->getSVal(S, LCtx);
205 bool returnFirstOnly) {
212 StoreManager &StoreMgr = State->getStateManager().getStoreManager();
224 bool returnFirstOnly) {
225 std::vector<SymbolRef> TaintedSymbols;
227 return TaintedSymbols;
230 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(Reg)) {
231 std::vector<SymbolRef> TaintedIndex =
233 llvm::append_range(TaintedSymbols, TaintedIndex);
234 if (returnFirstOnly && !TaintedSymbols.empty())
235 return TaintedSymbols;
240 std::vector<SymbolRef> TaintedRegions =
242 llvm::append_range(TaintedSymbols, TaintedRegions);
243 if (returnFirstOnly && !TaintedSymbols.empty())
244 return TaintedSymbols;
249 if (
const SubRegion *ER = dyn_cast<SubRegion>(Reg)) {
250 std::vector<SymbolRef> TaintedSubRegions =
252 llvm::append_range(TaintedSymbols, TaintedSubRegions);
253 if (returnFirstOnly && !TaintedSymbols.empty())
254 return TaintedSymbols;
257 return TaintedSymbols;
263 bool returnFirstOnly) {
264 std::vector<SymbolRef> TaintedSymbols;
266 return TaintedSymbols;
269 if (
const auto &Opts = State->getAnalysisManager().getAnalyzerOptions();
276 if (!isa<SymbolData>(SubSym))
279 if (
const TaintTagType *Tag = State->get<TaintMap>(SubSym)) {
281 TaintedSymbols.push_back(SubSym);
283 return TaintedSymbols;
287 if (
const auto *SD = dyn_cast<SymbolDerived>(SubSym)) {
290 State, SD->getParentSymbol(), Kind, returnFirstOnly);
291 llvm::append_range(TaintedSymbols, TaintedParents);
292 if (returnFirstOnly && !TaintedSymbols.empty())
293 return TaintedSymbols;
298 if (
const TaintedSubRegions *Regs =
299 State->get<DerivedSymTaint>(SD->getParentSymbol())) {
301 for (
auto I : *Regs) {
307 TaintedSymbols.push_back(SD->getParentSymbol());
308 if (returnFirstOnly && !TaintedSymbols.empty())
309 return TaintedSymbols;
316 if (
const auto *SRV = dyn_cast<SymbolRegionValue>(SubSym)) {
317 std::vector<SymbolRef> TaintedRegions =
319 llvm::append_range(TaintedSymbols, TaintedRegions);
320 if (returnFirstOnly && !TaintedSymbols.empty())
321 return TaintedSymbols;
325 if (
const auto *SC = dyn_cast<SymbolCast>(SubSym)) {
326 std::vector<SymbolRef> TaintedCasts =
328 llvm::append_range(TaintedSymbols, TaintedCasts);
329 if (returnFirstOnly && !TaintedSymbols.empty())
330 return TaintedSymbols;
333 return TaintedSymbols;
#define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map of type NameTy, suitable for placement into the ProgramState.
#define REGISTER_MAP_FACTORY_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map type Name and registers the factory for such maps in the program state,...
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Stmt - This represents one statement.
ElementRegion is used to represent both array elements and casts.
MemRegion - The root abstract class for all memory regions.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
virtual std::optional< SVal > getDefaultBinding(Store store, const MemRegion *R)=0
Return the default value bound to a region in a given store.
SubRegion - A region that subsets another larger region.
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
llvm::iterator_range< symbol_iterator > symbols() const
virtual unsigned computeComplexity() const =0
Represents a cast expression.
SymbolicRegion - A special, "non-concrete" region.
TypedValueRegion - An abstract class representing regions having a typed value.
While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...
std::vector< SymbolRef > getTaintedSymbolsImpl(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind, bool returnFirstOnly)
ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Create a new state in which the value of the statement is marked as tainted.
std::vector< SymbolRef > getTaintedSymbols(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Returns the tainted Symbols for a given Statement and state.
bool isTainted(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Check if the statement has a tainted value in the given state.
ProgramStateRef removeTaint(ProgramStateRef State, SVal V)
void printTaint(ProgramStateRef State, raw_ostream &Out, const char *nl="\n", const char *sep="")
ProgramStateRef addPartialTaint(ProgramStateRef State, SymbolRef ParentSym, const SubRegion *SubRegion, TaintTagType Kind=TaintTagGeneric)
Create a new state in a which a sub-region of a given symbol is tainted.
LLVM_DUMP_METHOD void dumpTaint(ProgramStateRef State)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T