Author: Arthur Eubanks Date: 2023-10-16T09:34:03-07:00 New Revision: e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51
URL: https://github.com/llvm/llvm-project/commit/e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51 DIFF: https://github.com/llvm/llvm-project/commit/e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51.diff LOG: [clang] Use IgnoreParensSingleStep in more places Addresses a post-commit comment on D146764. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D151479 Added: Modified: clang/lib/Sema/SemaInit.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index fd95b16b84b6e3a..8f945bc764befa9 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -15,6 +15,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" +#include "clang/AST/IgnoreExpr.h" #include "clang/AST/TypeLoc.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/SourceManager.h" @@ -170,22 +171,9 @@ static void updateStringLiteralType(Expr *E, QualType Ty) { while (true) { E->setType(Ty); E->setValueKind(VK_PRValue); - if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E)) { - break; - } else if (ParenExpr *PE = dyn_cast<ParenExpr>(E)) { - E = PE->getSubExpr(); - } else if (UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) { - assert(UO->getOpcode() == UO_Extension); - E = UO->getSubExpr(); - } else if (GenericSelectionExpr *GSE = dyn_cast<GenericSelectionExpr>(E)) { - E = GSE->getResultExpr(); - } else if (ChooseExpr *CE = dyn_cast<ChooseExpr>(E)) { - E = CE->getChosenSubExpr(); - } else if (PredefinedExpr *PE = dyn_cast<PredefinedExpr>(E)) { - E = PE->getFunctionName(); - } else { - llvm_unreachable("unexpected expr in string literal init"); - } + if (isa<StringLiteral>(E) || isa<ObjCEncodeExpr>(E)) + break; + E = IgnoreParensSingleStep(E); } } @@ -194,20 +182,9 @@ static void updateStringLiteralType(Expr *E, QualType Ty) { static void updateGNUCompoundLiteralRValue(Expr *E) { while (true) { E->setValueKind(VK_PRValue); - if (isa<CompoundLiteralExpr>(E)) { - break; - } else if (ParenExpr *PE = dyn_cast<ParenExpr>(E)) { - E = PE->getSubExpr(); - } else if (UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) { - assert(UO->getOpcode() == UO_Extension); - E = UO->getSubExpr(); - } else if (GenericSelectionExpr *GSE = dyn_cast<GenericSelectionExpr>(E)) { - E = GSE->getResultExpr(); - } else if (ChooseExpr *CE = dyn_cast<ChooseExpr>(E)) { - E = CE->getChosenSubExpr(); - } else { - llvm_unreachable("unexpected expr in array compound literal init"); - } + if (isa<CompoundLiteralExpr>(E)) + break; + E = IgnoreParensSingleStep(E); } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits