32 TaintMapTy TM = State->get<TaintMap>();
35 Out <<
"Tainted symbols:" << NL;
37 for (
const auto &I : TM)
38 Out << I.first <<
" : " << I.second << NL;
48 return addTaint(State, State->getSVal(S, LCtx), Kind);
67 if (std::optional<SVal> binding =
68 State->getStateManager().getStoreManager().getDefaultBinding(
70 if (
SymbolRef Sym = binding->getAsSymbol())
81 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
82 return addTaint(State, SR->getSymbol(), Kind);
90 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
91 Sym = SC->getOperand();
108 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
116 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
117 Sym = SC->getOperand();
135 return addTaint(State, ParentSym, Kind);
137 const TaintedSubRegions *SavedRegs = State->get<DerivedSymTaint>(ParentSym);
138 TaintedSubRegions::Factory &F = State->get_context<TaintedSubRegions>();
139 TaintedSubRegions Regs = SavedRegs ? *SavedRegs : F.getEmptyMap();
142 ProgramStateRef NewState = State->set<DerivedSymTaint>(ParentSym, Regs);
197 bool returnFirstOnly) {
198 SVal val = State->getSVal(S, LCtx);
204 bool returnFirstOnly) {
215 bool returnFirstOnly) {
216 std::vector<SymbolRef> TaintedSymbols;
218 return TaintedSymbols;
221 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(Reg)) {
222 std::vector<SymbolRef> TaintedIndex =
224 llvm::append_range(TaintedSymbols, TaintedIndex);
225 if (returnFirstOnly && !TaintedSymbols.empty())
226 return TaintedSymbols;
231 std::vector<SymbolRef> TaintedRegions =
233 llvm::append_range(TaintedSymbols, TaintedRegions);
234 if (returnFirstOnly && !TaintedSymbols.empty())
235 return TaintedSymbols;
240 if (
const SubRegion *ER = dyn_cast<SubRegion>(Reg)) {
241 std::vector<SymbolRef> TaintedSubRegions =
243 llvm::append_range(TaintedSymbols, TaintedSubRegions);
244 if (returnFirstOnly && !TaintedSymbols.empty())
245 return TaintedSymbols;
248 return TaintedSymbols;
254 bool returnFirstOnly) {
255 std::vector<SymbolRef> TaintedSymbols;
257 return TaintedSymbols;
261 if (!isa<SymbolData>(SubSym))
264 if (
const TaintTagType *Tag = State->get<TaintMap>(SubSym)) {
266 TaintedSymbols.push_back(SubSym);
268 return TaintedSymbols;
272 if (
const auto *SD = dyn_cast<SymbolDerived>(SubSym)) {
275 State, SD->getParentSymbol(), Kind, returnFirstOnly);
276 llvm::append_range(TaintedSymbols, TaintedParents);
277 if (returnFirstOnly && !TaintedSymbols.empty())
278 return TaintedSymbols;
283 if (
const TaintedSubRegions *Regs =
284 State->get<DerivedSymTaint>(SD->getParentSymbol())) {
286 for (
auto I : *Regs) {
292 TaintedSymbols.push_back(SD->getParentSymbol());
293 if (returnFirstOnly && !TaintedSymbols.empty())
294 return TaintedSymbols;
301 if (
const auto *SRV = dyn_cast<SymbolRegionValue>(SubSym)) {
302 std::vector<SymbolRef> TaintedRegions =
304 llvm::append_range(TaintedSymbols, TaintedRegions);
305 if (returnFirstOnly && !TaintedSymbols.empty())
306 return TaintedSymbols;
310 if (
const auto *SC = dyn_cast<SymbolCast>(SubSym)) {
311 std::vector<SymbolRef> TaintedCasts =
313 llvm::append_range(TaintedSymbols, TaintedCasts);
314 if (returnFirstOnly && !TaintedSymbols.empty())
315 return TaintedSymbols;
318 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.
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
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