MCPcopy Create free account
hub / github.com/R-Fuzz/symsan / buildArgMap

Function buildArgMap

instrumentation/LoopOutlinePass.cpp:163–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161 std::string ctype;
162};
163static std::vector<ArgInfo> buildArgMap(Function *Out, Function *F) {
164 DenseMap<const Value *, DILocalVariable *> Dbg;
165 for (BasicBlock &BB : *F)
166 for (Instruction &I : BB)
167 if (auto *DDI = dyn_cast<DbgDeclareInst>(&I))
168 if (DDI->getAddress() && DDI->getVariable())
169 Dbg[DDI->getAddress()] = DDI->getVariable();
170
171 CallBase *CB = nullptr;
172 for (User *U : Out->users())
173 if ((CB = dyn_cast<CallBase>(U)))
174 break;
175 std::vector<ArgInfo> Out2;
176 if (!CB)
177 return Out2;
178 for (unsigned i = 0, e = CB->arg_size(); i < e; ++i) {
179 const Value *A = CB->getArgOperand(i)->stripPointerCasts();
180 ArgInfo AI{i, "", ""};
181 auto It = Dbg.find(A);
182 if (It != Dbg.end()) {
183 AI.var = It->second->getName().str();
184 AI.ctype = diArgCType(It->second->getType());
185 }
186 Out2.push_back(std::move(AI));
187 }
188 return Out2;
189}
190
191// C declarator for a global the harness must `extern`-declare (arrays keep
192// `[]`, since `int a[]` and `int *a` are different symbols at link).

Callers 1

runMethod · 0.85

Calls 4

diArgCTypeFunction · 0.85
findMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected