aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/TargetInfo.h10
-rw-r--r--lib/Basic/TargetInfo.cpp1
-rw-r--r--lib/Lex/Preprocessor.cpp7
3 files changed, 17 insertions, 1 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index a8edf47041..cb585679d9 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -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
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index 8a11925e06..20692ba5b1 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -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.
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 458eca640a..12f63d6444 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -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);