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

Method getDataForArray

lib/constantanalysis/ASTValue.cpp:248–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248std::vector<ASTValueData>
249ASTValue::getDataForArray(const clang::Expr &E,
250 const clang::ASTContext &Ctx) const {
251
252 std::vector<ASTValueData> Result;
253
254 auto *ICE = E.IgnoreCasts();
255 if (!ICE)
256 return Result;
257
258 auto *ILE = dyn_cast_or_null<InitListExpr>(ICE);
259 if (!ILE)
260 return Result;
261
262 for (auto *Init : ILE->inits()) {
263 if (!Init)
264 break;
265
266 auto Data = getData(*Init, Ctx);
267 // Only consider one dimensional array
268 if (Data.first == true)
269 break;
270 if (Data.second.size() == 0)
271 break;
272
273 Result.push_back(Data.second[0]);
274 }
275
276 if (Result.size() != ILE->getNumInits())
277 Result.clear();
278
279 return Result;
280}
281
282const Expr *ASTValue::getValueExpr(const DeclRefExpr &E,
283 const ASTContext &Ctx) const {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected