Skip to content

Commit 3721c29

Browse files
committed
Address PR comments.
1 parent f376279 commit 3721c29

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,12 +2168,12 @@ static ExprResult sharedGetConstructorDestructorAttrExpr(Sema &S,
21682168
if (!E->isTypeDependent() && !E->getType()->isIntegerType()) {
21692169
S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
21702170
<< AL << AANT_ArgumentIntegerConstant << E->getSourceRange();
2171-
return ExprResult(/*Invalid=*/true);
2171+
return ExprError();
21722172
}
21732173
} else {
21742174
uint32_t priority;
21752175
if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) {
2176-
return ExprResult(/*Invalid=*/true);
2176+
return ExprError();
21772177
}
21782178
return ConstantExpr::Create(S.Context, E,
21792179
APValue(llvm::APSInt::getUnsigned(priority)));
@@ -2188,7 +2188,7 @@ static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21882188
return;
21892189
}
21902190
ExprResult E = sharedGetConstructorDestructorAttrExpr(S, AL);
2191-
if (!E.isUsable())
2191+
if (E.isInvalid())
21922192
return;
21932193
S.Diag(D->getLocation(), diag::warn_global_constructor)
21942194
<< D->getSourceRange();
@@ -2197,7 +2197,7 @@ static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21972197

21982198
static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
21992199
ExprResult E = sharedGetConstructorDestructorAttrExpr(S, AL);
2200-
if (!E.isUsable())
2200+
if (E.isInvalid())
22012201
return;
22022202
S.Diag(D->getLocation(), diag::warn_global_destructor) << D->getSourceRange();
22032203
D->addAttr(::new (S.Context) DestructorAttr(S.Context, AL, E.get()));

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ static void sharedInstantiateConstructorDestructorAttr(
256256
}
257257
}
258258
}
259-
Attr *NewAttr = new (C) Attr(C, *A, tempInstPriority);
260-
if (NewAttr)
261-
New->addAttr(NewAttr);
259+
New->addAttr(new (C) Attr(C, *A, tempInstPriority));
262260
}
263261

264262
static Expr *instantiateDependentFunctionAttrCondition(

clang/test/AST/ast-dump-attr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ __attribute__((pointer_with_type_tag(unsigned1,1,2)));
8989
void TestInt(void) __attribute__((constructor(123)));
9090
// CHECK: FunctionDecl{{.*}}TestInt
9191
// CHECK-NEXT: ConstructorAttr
92+
// CHECK-NEXT: ConstantExpr
93+
// CHECK-NEXT: value: Int 123
9294
// CHECK-NEXT: IntegerLiteral{{.*}} 123
9395

9496
static int TestString __attribute__((alias("alias1")));

0 commit comments

Comments
 (0)