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

Method generateValue

lib/inputanalysis/DefMapGenerator.cpp:226–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226ASTValue
227DefMapGenerator::generateValue(ASTDefNode &Node,
228 const ConstAnalyzerReport &ConstReport) const {
229 auto *ValueNode = Node.getAssigned();
230 if (!ValueNode)
231 return ASTValue();
232
233 auto *ValueExpr = const_cast<Expr *>(ValueNode->getNode().get<Expr>());
234 if (!ValueExpr)
235 return ASTValue();
236
237 ASTValue Result(*ValueExpr, ValueNode->getASTUnit().getASTContext());
238 if (Result.isValid())
239 return Result;
240
241 ValueExpr = ValueExpr->IgnoreCasts();
242 if (!ValueExpr || !isa<DeclRefExpr>(ValueExpr))
243 return Result;
244
245 auto &DRE = *dyn_cast<DeclRefExpr>(ValueExpr);
246 auto *D = DRE.getDecl();
247 if (!D)
248 return Result;
249
250 const auto *CV = ConstReport.getConstValue(D->getQualifiedNameAsString());
251 if (!CV)
252 return Result;
253 return *CV;
254}
255
256Definition &DefMapGenerator::getDefinition(unsigned ID) {
257 auto Iter = IDDefMap.find(ID);

Callers

nothing calls this directly

Calls 4

ASTValueClass · 0.85
getAssignedMethod · 0.80
isValidMethod · 0.80
getConstValueMethod · 0.80

Tested by

no test coverage detected