-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebAssembly] Improve clang diagnostics for wasm attributes
This patch addresses the review comments on r352930: - Removes redundant diagnostic checking code - Removes errnoneous use of diag::err_alias_is_definition, which turned out to be ineffective anyway since functions can be defined later in the translation unit and avoid detection. - Adds a test for various invalid cases for import_name and import_module. This reapplies D59520, with the addition of adding `InGroup<IgnoredAttributes>` to the new warnings, to fix the Misc/warning-flags.c failure. Differential Revision: https://reviews.llvm.org/D59520
- Loading branch information
1 parent
8b05b6d
commit 0d4e243
Showing
7 changed files
with
161 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s | ||
|
||
// Test that functions can be redeclared and they retain their attributes. | ||
|
||
__attribute__((export_name("export_red"))) void red(void) {} | ||
__attribute__((export_name("export_orange"))) void orange(void) {} | ||
__attribute__((export_name("export_yellow"))) void yellow(void) {} | ||
|
||
void red(void); | ||
void orange(void); | ||
void yellow(void); | ||
|
||
// CHECK: |-FunctionDecl {{.+}} used red 'void (void)' | ||
// CHECK: | |-CompoundStmt {{.+}} | ||
// CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_red" | ||
// CHECK: | `-UsedAttr {{.+}} Implicit | ||
// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' | ||
// CHECK: | |-CompoundStmt {{.+}} | ||
// CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_orange" | ||
// CHECK: | `-UsedAttr {{.+}} Implicit | ||
// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)' | ||
// CHECK: | |-CompoundStmt {{.+}} | ||
// CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_yellow" | ||
// CHECK: | `-UsedAttr {{.+}} Implicit | ||
// CHECK: |-FunctionDecl {{.+}} used red 'void (void)' | ||
// CHECK: | |-UsedAttr {{.+}} Inherited Implicit | ||
// CHECK: | `-WebAssemblyExportNameAttr {{.+}} Inherited "export_red" | ||
// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' | ||
// CHECK: | |-UsedAttr {{.+}} Inherited Implicit | ||
// CHECK: | `-WebAssemblyExportNameAttr {{.+}} Inherited "export_orange" | ||
// CHECK: `-FunctionDecl {{.+}} used yellow 'void (void)' | ||
// CHECK: |-UsedAttr {{.+}} Inherited Implicit | ||
// CHECK: `-WebAssemblyExportNameAttr {{.+}} Inherited "export_yellow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -ast-dump %s | FileCheck --strict-whitespace %s | ||
|
||
// Test that functions can be redeclared and they retain their attributes. | ||
|
||
__attribute__((import_name("import_red"), import_module("mod"))) void red(void); | ||
__attribute__((import_name("import_orange"), import_module("mod"))) void orange(void); | ||
__attribute__((import_name("import_yellow"), import_module("mod"))) void yellow(void); | ||
|
||
void red(void); | ||
void orange(void); | ||
void yellow(void); | ||
|
||
void calls(void) { | ||
red(); | ||
orange(); | ||
yellow(); | ||
} | ||
|
||
// CHECK: |-FunctionDecl {{.+}} used red 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_red" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" | ||
// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_orange" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" | ||
// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} "import_yellow" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} "mod" | ||
// CHECK: |-FunctionDecl {{.+}} used red 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_red" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" | ||
// CHECK: |-FunctionDecl {{.+}} used orange 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_orange" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" | ||
// CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)' | ||
// CHECK: | |-WebAssemblyImportNameAttr {{.+}} Inherited "import_yellow" | ||
// CHECK: | `-WebAssemblyImportModuleAttr {{.+}} Inherited "mod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s | ||
|
||
void name_a() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}} | ||
|
||
int name_b __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}} | ||
|
||
void name_c() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}} | ||
|
||
void name_d() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}} | ||
|
||
void name_z() __attribute__((import_name("foo"))); //expected-note {{previous attribute is here}} | ||
|
||
void name_z() __attribute__((import_name("bar"))); //expected-warning {{import name (bar) does not match the import name (foo) of the previous declaration}} | ||
|
||
void module_a() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}} | ||
|
||
int module_b __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}} | ||
|
||
void module_c() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}} | ||
|
||
void module_d() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}} | ||
|
||
void module_z() __attribute__((import_module("foo"))); //expected-note {{previous attribute is here}} | ||
|
||
void module_z() __attribute__((import_module("bar"))); //expected-warning {{import module (bar) does not match the import module (foo) of the previous declaration}} | ||
|
||
void both() __attribute__((import_name("foo"), import_module("bar"))); |