[BPF] do not generate predefined macro bpf
"DefineStd(Builder, "bpf", Opts)" generates the following three macros: bpf __bpf __bpf__ and the macro "bpf" is due to the fact that the target language is C which allows GNU extensions. The name "bpf" could be easily used as variable name or type field name. For example, in current linux kernel, there are four places where bpf is used as a field name. If the corresponding types are included in bpf program, the compilation error will occur. This patch removed predefined macro "bpf" as well as "__bpf" which is rarely used if used at all. Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D61173 llvm-svn: 359310
This commit is contained in:
parent
6ee3fef9a4
commit
51a4a0d68f
@ -20,7 +20,7 @@ using namespace clang::targets;
|
||||
|
||||
void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||
MacroBuilder &Builder) const {
|
||||
DefineStd(Builder, "bpf", Opts);
|
||||
Builder.defineMacro("__bpf__");
|
||||
Builder.defineMacro("__BPF__");
|
||||
}
|
||||
|
||||
|
16
clang/test/Preprocessor/bpf-predefined-macros.c
Normal file
16
clang/test/Preprocessor/bpf-predefined-macros.c
Normal file
@ -0,0 +1,16 @@
|
||||
// RUN: %clang -E -target bpfel -x c -o - %s | FileCheck %s
|
||||
// RUN: %clang -E -target bpfeb -x c -o - %s | FileCheck %s
|
||||
|
||||
#ifdef __bpf__
|
||||
int b;
|
||||
#endif
|
||||
#ifdef __BPF__
|
||||
int c;
|
||||
#endif
|
||||
#ifdef bpf
|
||||
int d;
|
||||
#endif
|
||||
|
||||
// CHECK: int b;
|
||||
// CHECK: int c;
|
||||
// CHECK-NOT: int d;
|
Loading…
x
Reference in New Issue
Block a user