]> granicus.if.org Git - clang/commitdiff
Implement PR2773, support for __USER_LABEL_PREFIX__
authorChris Lattner <sabre@nondot.org>
Sun, 5 Oct 2008 19:22:37 +0000 (19:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 5 Oct 2008 19:22:37 +0000 (19:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57127 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/TargetInfo.h
lib/Basic/TargetInfo.cpp
lib/Lex/Preprocessor.cpp

index a8edf47041db42b5dd117258212401108c9e747d..cb585679d978f396ca489952cbbd1e09deca75b5 100644 (file)
@@ -44,7 +44,7 @@ protected:
   unsigned char LongWidth, LongAlign;
   unsigned char LongLongWidth, LongLongAlign;
   const char *DescriptionString;
-  
+  const char *UserLabelPrefix;
   const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
 
   // TargetInfo Constructor.  Default initializes all fields.
@@ -141,6 +141,14 @@ public:
     return 64;
   }
   
+  /// getUserLabelPrefix - This returns the default value of the
+  /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
+  /// default.  On most platforms this is "_", but it is "" on some, and "." on
+  /// others.
+  const char *getUserLabelPrefix() const {
+    return UserLabelPrefix;
+  }
+  
   ///===---- Other target property query methods --------------------------===//
   
   /// getTargetDefines - Appends the target-specific #define values for this
index 8a11925e06b52f4da59cc85b63fa8a2516a9bb91..20692ba5b13dab3c191ffadc8b7ccb9e7aaee695 100644 (file)
@@ -39,6 +39,7 @@ TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
   LongDoubleFormat = &llvm::APFloat::IEEEdouble;
   DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
                       "i64:64:64-f32:32:32-f64:64:64";
+  UserLabelPrefix = "_";
 }
 
 // Out of line virtual dtor for TargetInfo.
index 458eca640afe3a17d035866ae7bf1d7ff614c7be..12f63d6444c118c5222901f481bddcef7f6610bf 100644 (file)
@@ -425,6 +425,13 @@ static void InitializePredefinedMacros(Preprocessor &PP,
     Buf.push_back('\n');
   }
   
+  if (const char *Prefix = PP.getTargetInfo().getUserLabelPrefix()) {
+    llvm::SmallString<20> TmpStr;
+    TmpStr += "__USER_LABEL_PREFIX__=";
+    TmpStr += Prefix;
+    DefineBuiltinMacro(Buf, TmpStr.c_str());
+  }
+  
   // Get the target #defines.
   PP.getTargetInfo().getTargetDefines(Buf);