-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Undefine noinline macro if conflicts with AST dump
In kernel sourcecode there is a definition of a macro: ``` ``` This seems harmless, but when clang-extract decides to dump the AST of a Decl, this conflicts with its attr: ``` __attribute__((noinline)) ``` which results in the resulting code being broken. Hence, undefine this macro for the AST dump and define it later. Signed-off-by: Giuliano Belinassi <[email protected]>
- Loading branch information
1 parent
dd25987
commit 173069a
Showing
3 changed files
with
79 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* { dg-options "-DCE_EXTRACT_FUNCTIONS=func_f -DCE_NO_EXTERNALIZATION" }*/ | ||
#define MACRO 0 | ||
|
||
/* Do this sort of blurry definition to confuse out clang-extract into dumping | ||
the AST of the function. */ | ||
#define DEFINE_FUNCTION(name) __attribute__((noinline)) int func_##name(void) { return MACRO; } | ||
#define DEFINE_VARIABLE(name) int var_##name; | ||
#define DEFINE(f) DEFINE_VARIABLE(f) DEFINE_FUNCTION(f) | ||
|
||
DEFINE(f) | ||
|
||
/* { dg-final { scan-tree-dump "__attribute__\(\(noinline\)\)" } } */ | ||
/* { dg-final { scan-tree-dump-not "#define noinline" } } */ |
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 @@ | ||
/* { dg-options "-DCE_EXTRACT_FUNCTIONS=func_f,g,h -DCE_NO_EXTERNALIZATION" }*/ | ||
|
||
|
||
#define noinline SHOULD_NOT_BE_IN_THE_FINAL_OUTPUT | ||
|
||
#undef noinline | ||
#define noinline __attribute__((__noinline__)) | ||
|
||
/* Do this sort of blurry definition to confuse out clang-extract into dumping | ||
the AST of the function. */ | ||
#define DEFINE_FUNCTION(name) noinline int func_##name(void) { return 0; } | ||
#define DEFINE_VARIABLE(name) int var_##name; | ||
#define DEFINE(f) DEFINE_VARIABLE(f) DEFINE_FUNCTION(f) | ||
|
||
noinline int g() | ||
{ | ||
return 1; | ||
} | ||
|
||
DEFINE(f); | ||
|
||
noinline int h() | ||
{ | ||
return 2; | ||
} | ||
|
||
|
||
#undef noinline | ||
#define noinline SHOULD_NOT_BE_IN_THE_FINAL_OUTPUT | ||
|
||
/* { dg-final { scan-tree-dump "__attribute__\(\(noinline\)\) int func_f" } } */ | ||
/* { dg-final { scan-tree-dump "#undef noinline" } } */ | ||
/* { dg-final { scan-tree-dump-not "SHOULD_NOT_BE_IN_THE_FINAL_OUTPUT" } } */ |