summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-01 19:18:58 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-01 19:42:59 (GMT)
commit1489405912947356574477a3c10fec69e78cb6dc (patch)
tree67e55f52d058ac0a6ed15e783f8d5caa759649fa /src
parent15e8fdb8dee7b22609fe0e0c6a9dc0b977f43db4 (diff)
downloadCastXML-1489405912947356574477a3c10fec69e78cb6dc.zip
CastXML-1489405912947356574477a3c10fec69e78cb6dc.tar.gz
CastXML-1489405912947356574477a3c10fec69e78cb6dc.tar.bz2
RunClang: Tolerate __builtin_va_arg_pack during parsing
When simulating preprocessing by a GNU compiler code (in the standard library) may try to use this builtin, but Clang does not support it. Provide a fake instance of the builtin using a preprocessor macro good enough to get through parsing references to it in function bodies. GitHub-Issue: #46
Diffstat (limited to 'src')
-rw-r--r--src/RunClang.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/RunClang.cxx b/src/RunClang.cxx
index 1259628..9768a25 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -180,6 +180,16 @@ protected:
if (this->Opts.HaveCC) {
builtins += this->Opts.Predefines;
+ // Provide __builtin_va_arg_pack if simulating the actual GNU compiler.
+ if (this->NeedBuiltinVarArgPack(this->Opts.Predefines)) {
+ // Clang does not support this builtin, so fake it to tolerate
+ // uses in function bodies while parsing.
+ builtins += "\n"
+ "#define __builtin_va_arg_pack() 0\n"
+ "#define __builtin_va_arg_pack_len() 1\n"
+ ;
+ }
+
// Provide __float128 if simulating the actual GNU compiler.
if (this->NeedFloat128(this->Opts.Predefines)) {
// Clang provides its own (fake) builtin in gnu++11 mode.
@@ -208,6 +218,10 @@ protected:
pd.find("#define __PGI ") == pd.npos);
}
+ bool NeedBuiltinVarArgPack(std::string const& pd) {
+ return this->IsActualGNU(pd);
+ }
+
bool NeedFloat128(std::string const& pd) const {
return (this->IsActualGNU(pd) &&
(pd.find("#define __i386__ ") != pd.npos ||