Skip to content

Commit 3aec298

Browse files
committed
Revert "[WebAssembly] Improve clang diagnostics for wasm attributes"
It broke clang-check. This reverts commit 931fcd3.
1 parent 72e4da4 commit 3aec298

File tree

7 files changed

+19
-159
lines changed

7 files changed

+19
-159
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10770,12 +10770,6 @@ def err_matrix_separate_incomplete_index: Error<
1077010770
def err_matrix_subscript_comma: Error<
1077110771
"comma expressions are not allowed as indices in matrix subscript expressions">;
1077210772

10773-
def warn_mismatched_import : Warning<
10774-
"import %select{module|name}0 (%1) does not match the import %select{module|name}0 (%2) of the "
10775-
"previous declaration">;
10776-
def warn_import_on_definition : Warning<
10777-
"import %select{module|name}0 cannot be applied to a function with a definition">;
10778-
1077910773
def err_preserve_field_info_not_field : Error<
1078010774
"__builtin_preserve_field_info argument %0 not a field access">;
1078110775
def err_preserve_field_info_not_const: Error<

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,10 +2999,6 @@ class Sema final {
29992999
const InternalLinkageAttr &AL);
30003000
CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
30013001
CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
3002-
WebAssemblyImportNameAttr *mergeImportNameAttr(
3003-
Decl *D, const WebAssemblyImportNameAttr &AL);
3004-
WebAssemblyImportModuleAttr *mergeImportModuleAttr(
3005-
Decl *D, const WebAssemblyImportModuleAttr &AL);
30063002

30073003
void mergeDeclAttributes(NamedDecl *New, Decl *Old,
30083004
AvailabilityMergeKind AMK = AMK_Redeclaration);

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,10 +2598,6 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
25982598
NewAttr = S.mergeSpeculativeLoadHardeningAttr(D, *SLHA);
25992599
else if (const auto *SLHA = dyn_cast<NoSpeculativeLoadHardeningAttr>(Attr))
26002600
NewAttr = S.mergeNoSpeculativeLoadHardeningAttr(D, *SLHA);
2601-
else if (const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(Attr))
2602-
NewAttr = S.mergeImportModuleAttr(D, *IMA);
2603-
else if (const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(Attr))
2604-
NewAttr = S.mergeImportNameAttr(D, *INA);
26052601
else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
26062602
NewAttr = cast<InheritableAttr>(Attr->clone(S.Context));
26072603

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5892,75 +5892,45 @@ static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &
58925892
D->addAttr(UsedAttr::CreateImplicit(S.Context));
58935893
}
58945894

5895-
WebAssemblyImportModuleAttr *
5896-
Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) {
5897-
auto *FD = cast<FunctionDecl>(D);
5898-
5899-
if (const auto *ExistingAttr = FD->getAttr<WebAssemblyImportModuleAttr>()) {
5900-
if (ExistingAttr->getImportModule() == AL.getImportModule())
5901-
return nullptr;
5902-
Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
5903-
<< ExistingAttr->getImportModule() << AL.getImportModule();
5904-
Diag(AL.getLoc(), diag::note_previous_attribute);
5905-
return nullptr;
5906-
}
5907-
if (FD->hasBody()) {
5908-
Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
5909-
return nullptr;
5895+
static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5896+
if (!isFunctionOrMethod(D)) {
5897+
S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
5898+
<< "'import_module'" << ExpectedFunction;
5899+
return;
59105900
}
5911-
return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
5912-
AL.getImportModule());
5913-
}
59145901

5915-
WebAssemblyImportNameAttr *
5916-
Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL) {
59175902
auto *FD = cast<FunctionDecl>(D);
5918-
5919-
if (const auto *ExistingAttr = FD->getAttr<WebAssemblyImportNameAttr>()) {
5920-
if (ExistingAttr->getImportName() == AL.getImportName())
5921-
return nullptr;
5922-
Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
5923-
<< ExistingAttr->getImportName() << AL.getImportName();
5924-
Diag(AL.getLoc(), diag::note_previous_attribute);
5925-
return nullptr;
5926-
}
5927-
if (FD->hasBody()) {
5928-
Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
5929-
return nullptr;
5903+
if (FD->isThisDeclarationADefinition()) {
5904+
S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
5905+
return;
59305906
}
5931-
return ::new (Context) WebAssemblyImportNameAttr(Context, AL,
5932-
AL.getImportName());
5933-
}
5934-
5935-
static void
5936-
handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5937-
auto *FD = cast<FunctionDecl>(D);
59385907

59395908
StringRef Str;
59405909
SourceLocation ArgLoc;
59415910
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
59425911
return;
5943-
if (FD->hasBody()) {
5944-
S.Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
5945-
return;
5946-
}
59475912

59485913
FD->addAttr(::new (S.Context)
59495914
WebAssemblyImportModuleAttr(S.Context, AL, Str));
59505915
}
59515916

5952-
static void
5953-
handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5917+
static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5918+
if (!isFunctionOrMethod(D)) {
5919+
S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
5920+
<< "'import_name'" << ExpectedFunction;
5921+
return;
5922+
}
5923+
59545924
auto *FD = cast<FunctionDecl>(D);
5925+
if (FD->isThisDeclarationADefinition()) {
5926+
S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0;
5927+
return;
5928+
}
59555929

59565930
StringRef Str;
59575931
SourceLocation ArgLoc;
59585932
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
59595933
return;
5960-
if (FD->hasBody()) {
5961-
S.Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
5962-
return;
5963-
}
59645934

59655935
FD->addAttr(::new (S.Context) WebAssemblyImportNameAttr(S.Context, AL, Str));
59665936
}

clang/test/AST/ast-dump-wasm-attr-export.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

clang/test/AST/ast-dump-wasm-attr-import.c

Lines changed: 0 additions & 36 deletions
This file was deleted.

clang/test/Sema/attr-wasm.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)