aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2023-05-25 11:32:38 -0700
committerArthur Eubanks <aeubanks@google.com>2023-10-16 09:34:03 -0700
commite32cde6f41cd93b7a20b64a1abc8d5c488c8fe51 (patch)
treea05fb19e454e30572dfc00f80211732df89a6fdf /clang/lib/Sema/SemaInit.cpp
parent9cc6f492f20ffc7bd1b7c9e5ef696aa921bcdef9 (diff)
downloadllvm-e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51.zip
llvm-e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51.tar.gz
llvm-e32cde6f41cd93b7a20b64a1abc8d5c488c8fe51.tar.bz2
[clang] Use IgnoreParensSingleStep in more places
Addresses a post-commit comment on D146764. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D151479
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp37
1 files changed, 7 insertions, 30 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index fd95b16..8f945bc 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);
}
}