Skip to content

Commit 6449d0f

Browse files
committed
Addressed comments
1 parent 8acda5b commit 6449d0f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,12 +2752,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
27522752
}
27532753

27542754
// Handle flatten_depth attribute for depth-based inlining
2755-
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2756-
if (const FlattenDepthAttr *FDA = FD->getAttr<FlattenDepthAttr>()) {
2757-
// Add the flatten_depth attribute with the max depth value as a typed int
2758-
// attribute
2759-
B.addRawIntAttr(llvm::Attribute::FlattenDepth, FDA->getDepthHint());
2760-
}
2755+
if (const FlattenDepthAttr *FDA = D->getAttr<FlattenDepthAttr>()) {
2756+
// Add the flatten_depth attribute with the max depth value as a typed int
2757+
// attribute
2758+
B.addFlattenDepthAttr(FDA->getDepthHint());
27612759
}
27622760

27632761
// Track whether we need to add the optnone LLVM attribute,

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,18 +3699,16 @@ static void handleFlattenDepthAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
36993699
Expr *E = AL.getArgAsExpr(0);
37003700
uint32_t depthHint;
37013701
if (!S.checkUInt32Argument(AL, E, depthHint)) {
3702-
AL.setInvalid();
37033702
return;
37043703
}
37053704

37063705
if (depthHint == 0) {
37073706
S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
37083707
<< AL << E->getSourceRange();
3709-
AL.setInvalid();
37103708
return;
37113709
}
37123710

3713-
D->addAttr(::new (S.Context) FlattenDepthAttr(S.Context, AL, depthHint));
3711+
D->addAttr(FlattenDepthAttr::Create(S.Context, depthHint, AL));
37143712
}
37153713

37163714
ErrorAttr *Sema::mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,

0 commit comments

Comments
 (0)