| 224 | } |
| 225 | |
| 226 | ASTValue |
| 227 | DefMapGenerator::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 | |
| 256 | Definition &DefMapGenerator::getDefinition(unsigned ID) { |
| 257 | auto Iter = IDDefMap.find(ID); |
nothing calls this directly
no test coverage detected