MCPcopy Create free account
hub / github.com/Samsung/UTopia / getConstVarDecl

Method getConstVarDecl

lib/astirmap/DebugInfoMap.cpp:217–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217VarDecl *DebugInfoMap::getConstVarDecl(ASTDefNode &Node) const {
218 auto *Assigned = Node.getAssigned();
219 if (!Assigned)
220 return nullptr;
221
222 const auto *E = Assigned->getNode().get<Expr>();
223 if (!E)
224 return nullptr;
225
226 auto &Ctx = Assigned->getASTUnit().getASTContext();
227 const VarDecl *Result = nullptr;
228 do {
229 if (E->IgnoreCasts())
230 E = E->IgnoreCasts();
231
232 const auto *DRE = dyn_cast<DeclRefExpr>(E);
233 if (!DRE)
234 break;
235
236 const auto *VD = DRE->getDecl();
237 if (!VD)
238 break;
239 if (!VD->getType().isConstant(Ctx))
240 return nullptr;
241
242 Result = dyn_cast<VarDecl>(VD);
243 if (!Result)
244 return nullptr;
245 if (!Result->hasInit())
246 return nullptr;
247
248 E = Result->getInit();
249 } while (E);
250
251 return const_cast<VarDecl *>(Result);
252}
253
254bool DebugInfoMap::isArgsInMacro(const ASTDefNode &Node, Expr &E,
255 unsigned ArgNo, ASTUnit &U) const {

Callers

nothing calls this directly

Calls 2

getAssignedMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected