Skip to content

Commit a960e4f

Browse files
committed
Removed unused parameter and added comment for IsTypeDependent field
1 parent 45be8ae commit a960e4f

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,14 @@ class Attr {
743743
bit StrictEnumParameters = 0;
744744
// Set to true for attributes which have Sema checks which requires the type
745745
// to be deduced.
746+
// When `IsTypeDependent` is set to true, you should add an `ActOn*Attr`
747+
// function to `Sema.h`. The signature of the function must be:
748+
// `void ActOn*Attr(Decl *, const Attr *);` where the `Decl *` is the
749+
// declaration the attribute will be attached to; its type will have already
750+
// been deduced, and the `Attr *` is the attribute being applied to that
751+
// declaration. This function should handle all type-sensitive semantics for
752+
// the attribute. This function will be automatically called by
753+
// `Sema::CheckAttributesOnDeducedType()`.
746754
bit IsTypeDependent = 0;
747755
// Lists language options, one of which is required to be true for the
748756
// attribute to be applicable. If empty, no language options are required.

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4458,7 +4458,7 @@ class Sema final : public SemaBase {
44584458

44594459
/// CheckAttributesOnDeducedType - Calls Sema functions for attributes that
44604460
/// requires the type to be deduced.
4461-
void CheckAttributesOnDeducedType(Expr *E, Decl *D);
4461+
void CheckAttributesOnDeducedType(Decl *D);
44624462

44634463
/// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
44644464
/// same name and scope as a previous declaration 'Old'. Figure out
@@ -15475,7 +15475,7 @@ class Sema final : public SemaBase {
1547515475
std::optional<FunctionEffectMode>
1547615476
ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName);
1547715477

15478-
void ActOnCleanupAttr(Expr *E, Decl *D, const Attr *A);
15478+
void ActOnCleanupAttr(Decl *D, const Attr *A);
1547915479

1548015480
private:
1548115481
/// The implementation of RequireCompleteType

clang/lib/Sema/SemaDecl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,12 +3355,12 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
33553355
if (!foundAny) New->dropAttrs();
33563356
}
33573357

3358-
void Sema::CheckAttributesOnDeducedType(Expr *E, Decl *D) {
3358+
void Sema::CheckAttributesOnDeducedType(Decl *D) {
33593359
if (!D->hasAttrs())
33603360
return;
33613361

33623362
for (const Attr *A : D->getAttrs()) {
3363-
checkAttrIsTypeDependent(E, D, A);
3363+
checkAttrIsTypeDependent(D, A);
33643364
}
33653365
}
33663366

@@ -13818,7 +13818,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
1381813818
return;
1381913819
}
1382013820

13821-
this->CheckAttributesOnDeducedType(Init, RealDecl);
13821+
this->CheckAttributesOnDeducedType(RealDecl);
1382213822

1382313823
// dllimport cannot be used on variable definitions.
1382413824
if (VDecl->hasAttr<DLLImportAttr>() && !VDecl->isStaticDataMember()) {
@@ -14311,6 +14311,8 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
1431114311
DeduceVariableDeclarationType(Var, false, nullptr))
1431214312
return;
1431314313

14314+
this->CheckAttributesOnDeducedType(RealDecl);
14315+
1431414316
// C++11 [class.static.data]p3: A static data member can be declared with
1431514317
// the constexpr specifier; if so, its declaration shall specify
1431614318
// a brace-or-equal-initializer.
@@ -14610,7 +14612,6 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
1461014612
Var->setInit(RecoveryExpr.get());
1461114613
}
1461214614

14613-
this->CheckAttributesOnDeducedType(Init.get(), RealDecl);
1461414615
CheckCompleteVariableDeclaration(Var);
1461514616
}
1461614617
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8302,7 +8302,7 @@ void Sema::redelayDiagnostics(DelayedDiagnosticPool &pool) {
83028302
curPool->steal(pool);
83038303
}
83048304

8305-
void Sema::ActOnCleanupAttr(Expr *E, Decl *D, const Attr *A) {
8305+
void Sema::ActOnCleanupAttr(Decl *D, const Attr *A) {
83068306
// Obtains the FunctionDecl that was found when handling the attribute
83078307
// earlier.
83088308
CleanupAttr *Attr = D->getAttr<CleanupAttr>();

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5050,12 +5050,12 @@ void EmitClangAttrIsTypeDependent(const RecordKeeper &Records,
50505050
raw_ostream &OS) {
50515051
emitSourceFileHeader("Attribute is type dependent", OS, Records);
50525052

5053-
OS << "void checkAttrIsTypeDependent(Expr *E, Decl *D, const Attr *A) {\n";
5053+
OS << "void checkAttrIsTypeDependent(Decl *D, const Attr *A) {\n";
50545054
OS << " switch (A->getKind()) {\n";
50555055
for (const auto *A : Records.getAllDerivedDefinitions("Attr")) {
50565056
if (A->getValueAsBit("IsTypeDependent")) {
50575057
OS << " case attr::" << A->getName() << ":\n";
5058-
OS << " ActOn" << A->getName() << "Attr(E, D, A);\n";
5058+
OS << " ActOn" << A->getName() << "Attr(D, A);\n";
50595059
OS << " break;\n";
50605060
}
50615061
}

0 commit comments

Comments
 (0)