================
@@ -1848,18 +1848,13 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S,
     Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext()));
 
   // Emit debuginfo for the case value if it is an enum value.
-  const ConstantExpr *CE;
-  if (auto ICE = dyn_cast<ImplicitCastExpr>(S.getLHS()))
-    CE = dyn_cast<ConstantExpr>(ICE->getSubExpr());
-  else
-    CE = dyn_cast<ConstantExpr>(S.getLHS());
-  if (CE) {
-    if (auto DE = dyn_cast<DeclRefExpr>(CE->getSubExpr()))
-      if (CGDebugInfo *Dbg = getDebugInfo())
-        if (CGM.getCodeGenOpts().hasReducedDebugInfo())
-          Dbg->EmitGlobalVariable(DE->getDecl(),
-              APValue(llvm::APSInt(CaseVal->getValue())));
-  }
+  const auto *CE = dyn_cast<ConstantExpr>(S.getLHS()->IgnoreImpCasts());
----------------
tbaederr wrote:

The previous code checked if the LHS was a `ConstantExpr`, optionally looking 
through an `ImpliciCastExpr`. In the new scheme, there might not be such a 
`ConstantExpr` (in particular, it's never there in C), so we look through both 
the `ImplicitCastExpr` and the `ConstantExpr`, always.

The difference, AFAICS, is just that the ConstantExpr in the middle is now 
optional:

[ImplicitCastExpr] -> [ConstantExpr] -> DeclRefExpr

while before we had:

[ImplicitCastExpr] -> ConstantExpr -> DeclRefExpr



https://github.com/llvm/llvm-project/pull/229761
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to