Set __PIC__ (more) correctly.
- Add -pic-level clang-cc option to specify the value for the define,
updated driver to pass this.
- Added __pic__
- Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68584 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 139f310..d3d5b8c 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -497,8 +497,10 @@
if (PP.getLangOptions().ObjC1) {
DefineBuiltinMacro(Buf, "__OBJC__=1");
- if (PP.getLangOptions().ObjCNonFragileABI)
+ if (PP.getLangOptions().ObjCNonFragileABI) {
DefineBuiltinMacro(Buf, "__OBJC2__=1");
+ DefineBuiltinMacro(Buf, "OBJC_ZEROCOST_EXCEPTIONS=1");
+ }
if (PP.getLangOptions().getGCMode() != LangOptions::NonGC)
DefineBuiltinMacro(Buf, "__OBJC_GC__=1");
@@ -629,7 +631,14 @@
DefineBuiltinMacro(Buf, "__DYNAMIC__=1");
DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");
DefineBuiltinMacro(Buf, "__NO_INLINE__=1");
- DefineBuiltinMacro(Buf, "__PIC__=1");
+
+ if (unsigned PICLevel = PP.getLangOptions().PICLevel) {
+ sprintf(MacroBuf, "__PIC__=%d", PICLevel);
+ DefineBuiltinMacro(Buf, MacroBuf);
+
+ sprintf(MacroBuf, "__pic__=%d", PICLevel);
+ DefineBuiltinMacro(Buf, MacroBuf);
+ }
// Macros to control C99 numerics and <float.h>
DefineBuiltinMacro(Buf, "__FLT_EVAL_METHOD__=0");