[llvm-commits] llvm-c/Target.h SWIG friendliness

Chris Lattner clattner at apple.com
Sun Dec 20 23:53:04 PST 2009


On Dec 17, 2009, at 3:05 PM, James Y Knight wrote:

> Without this patch, SWIG chokes on llvm-c/Target.h, as, if you don't use #include files, it appears to have duplicate #defines. (SWIG doesn't follow #include when looking for functions/enums/etc to wrap). Since LLVM-C's main purpose is to generate bindings, it seems like a good idea to have it not cause SWIG to barf.
> 
> Of course, even with this patch, SWIG won't notice the LLVMInitialize*Target and LLVMInitialize*TargetInfo functions, but at least it's not completely failing. Perhaps it would be a better idea to pre-expand all these definitions, rather than using fancy #include tricks with llvm/Config/Targets.def at all, but this works well enough for me.

Applied in r91822, thanks!  In the future, please include patches as attachments.  I applied this one manually since it is small and obvious.

-Chris

> 
> --- Target.h~        2009-11-17 13:58:45.000000000 -0500
> +++ Target.h    2009-12-17 17:36:55.675913000 -0500
> @@ -35,9 +35,11 @@
> /* Declare all of the target-initialization functions that are available. */
> #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
> #include "llvm/Config/Targets.def"
> +#undef LLVM_TARGET
> 
> #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
> #include "llvm/Config/Targets.def"
> +#undef LLVM_TARGET
> 
> /** LLVMInitializeAllTargetInfos - The main program should call this function if
>     it wants access to all available targets that LLVM is configured to
> @@ -45,6 +47,7 @@
> static inline void LLVMInitializeAllTargetInfos() {
> #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
> #include "llvm/Config/Targets.def"
> +#undef LLVM_TARGET
> }
> 
> /** LLVMInitializeAllTargets - The main program should call this function if it
> @@ -53,6 +56,7 @@
> static inline void LLVMInitializeAllTargets() {
> #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
> #include "llvm/Config/Targets.def"
> +#undef LLVM_TARGET
> }
> 
> /** LLVMInitializeNativeTarget - The main program should call this function to
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list