summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-02-09 16:24:47 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-09 17:59:05 (GMT)
commit5cfebb0f904131d1df8e36fcb9c290f12c06e9ba (patch)
tree680825d2eb501d7d4fdd60ed6e841cd02a1a0048 /src
parent1489405912947356574477a3c10fec69e78cb6dc (diff)
downloadCastXML-5cfebb0f904131d1df8e36fcb9c290f12c06e9ba.zip
CastXML-5cfebb0f904131d1df8e36fcb9c290f12c06e9ba.tar.gz
CastXML-5cfebb0f904131d1df8e36fcb9c290f12c06e9ba.tar.bz2
RunClang: Avoid GNU extensions in glibc math headers on i386
On i386 with optimizations enabled, the `bits/mathinline.h` header may use a GNU extension not implemented by Clang. Avoid parsing this code by defining `__NO_MATH_INLINES` so it will be preprocessed out. GitHub-Issue: #47
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 9768a25..0a68698 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -204,6 +204,13 @@ protected:
}
}
+ // Prevent glibc use of a GNU extension not implemented by Clang.
+ if (this->NeedNoMathInlines(this->Opts.Predefines)) {
+ builtins += "\n"
+ "#define __NO_MATH_INLINES 1\n"
+ ;
+ }
+
} else {
builtins += predefines.substr(start, end-start);
}
@@ -229,6 +236,13 @@ protected:
pd.find("#define __ia64__ ") != pd.npos));
}
+ bool NeedNoMathInlines(std::string const& pd) const {
+ return (this->IsActualGNU(pd) &&
+ (pd.find("#define __i386__ ") != pd.npos &&
+ pd.find("#define __OPTIMIZE__ ") != pd.npos &&
+ pd.find("#define __NO_MATH_INLINES ") == pd.npos));
+ }
+
bool BeginSourceFileAction(clang::CompilerInstance& CI,
llvm::StringRef /*Filename*/) {
CI.getPreprocessor().setPredefines(this->UpdatePredefines(CI));