@@ -302,10 +302,8 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
302
302
303
303
case ExprKind::Call: {
304
304
auto callExpr = cast<CallExpr>(expr);
305
- auto functionKind = callExpr->getFn ()->getKind ();
306
305
307
- if (functionKind == ExprKind::DeclRef) {
308
- auto declRefExpr = cast<DeclRefExpr>(callExpr->getFn ());
306
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(callExpr->getFn ())) {
309
307
auto identifier =
310
308
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
311
309
@@ -314,17 +312,15 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
314
312
return std::make_shared<FunctionCallValue>(identifier, parameters);
315
313
}
316
314
317
- if (functionKind == ExprKind::ConstructorRefCall ) {
315
+ if (auto constructorRefCall = dyn_cast<ConstructorRefCallExpr>(callExpr-> getFn ()) ) {
318
316
std::vector<FunctionParameter> parameters =
319
317
extractFunctionArguments (callExpr->getArgs (), declContext);
320
318
return std::make_shared<InitCallValue>(callExpr->getType (), parameters);
321
319
}
322
320
323
- if (functionKind == ExprKind::DotSyntaxCall) {
324
- auto dotSyntaxCallExpr = cast<DotSyntaxCallExpr>(callExpr->getFn ());
321
+ if (auto dotSyntaxCallExpr = dyn_cast<DotSyntaxCallExpr>(callExpr->getFn ())) {
325
322
auto fn = dotSyntaxCallExpr->getFn ();
326
- if (fn->getKind () == ExprKind::DeclRef) {
327
- auto declRefExpr = cast<DeclRefExpr>(fn);
323
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(fn)) {
328
324
auto baseIdentifierName =
329
325
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
330
326
@@ -355,10 +351,8 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
355
351
}
356
352
}
357
353
358
- if (functionKind == ExprKind::FunctionConversion) {
359
- auto functionConversionExpr = cast<FunctionConversionExpr>(callExpr->getFn ());
360
- if (functionConversionExpr->getSubExpr ()->getKind () == ExprKind::DeclRef) {
361
- auto declRefExpr = cast<DeclRefExpr>(functionConversionExpr->getSubExpr ());
354
+ if (auto functionConversionExpr = dyn_cast<FunctionConversionExpr>(callExpr->getFn ())) {
355
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(functionConversionExpr->getSubExpr ())) {
362
356
auto identifier =
363
357
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
364
358
@@ -374,8 +368,7 @@ extractCompileTimeValue(Expr *expr, const DeclContext *declContext) {
374
368
case ExprKind::DotSyntaxCall: {
375
369
auto dotSyntaxCallExpr = cast<DotSyntaxCallExpr>(expr);
376
370
auto fn = dotSyntaxCallExpr->getFn ();
377
- if (fn->getKind () == ExprKind::DeclRef) {
378
- auto declRefExpr = cast<DeclRefExpr>(fn);
371
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(fn)) {
379
372
auto caseName =
380
373
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
381
374
return std::make_shared<EnumValue>(caseName, std::nullopt );
0 commit comments