aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-10 19:03:04 +0000
committerChris Lattner <sabre@nondot.org>2009-08-10 19:03:04 +0000
commit797c3c4f5dc4fda735e55c6b5d6270a54cf6d263 (patch)
tree3dc2c7a7c4e6f0a512404fe7449db442d5340a09 /lib/Basic/Targets.cpp
parent2e0110e5fa220eeb3a8a9836f69f6be05bd72f04 (diff)
fix a couple of problems with section attributes:
1. Passing something that isn't a string used to cause: "argument to annotate attribute was not a string literal" make it say "section attribute" instead. 2. Fix the location of the above message to point to the bad argument instead of the section token. 3. Implement rdar://4341926, by diagnosing invalid section specifiers in the frontend rather than letting them slip all the way to the assembler (a QoI win). An example of #3 is that we used to produce something like this: /var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Expected comma after segment-name /var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Rest of line ignored. 1st junk character valued 46 (.). Daniel improved clang to use llvm_report_error, so now we got: $ clang t.c -c fatal error: error in backend: Global variable 'x' has an invalid section specifier 'sadf': mach-o section specifier requires a segment and section separated by a comma. with no loc info. Now we get: $ clang t.c -fsyntax-only t.c:4:30: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma int x __attribute__((section("sadf"))); ^ which is nice :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78586 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Targets.cpp')
-rw-r--r--lib/Basic/Targets.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 51f5c87803..605ee8c8d8 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/MC/MCSectionMachO.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -61,6 +62,7 @@ static void DefineStd(std::vector<char> &Buf, const char *MacroName,
//===----------------------------------------------------------------------===//
// Defines specific to certain operating systems.
//===----------------------------------------------------------------------===//
+
namespace {
template<typename TgtInfo>
class OSTargetInfo : public TgtInfo {
@@ -78,7 +80,7 @@ public:
};
}
-namespace {
+
/// getDarwinNumber - Parse the 'darwin number' out of the specific targe
/// triple. For example, if we have darwin8.5 return 8,5,0. If any entry is
/// not defined, return 0's. Return true if we have -darwin in the string or
@@ -216,6 +218,7 @@ static void GetDarwinLanguageOptions(LangOptions &Opts,
Opts.ObjCNonFragileABI = 1;
}
+namespace {
template<typename Target>
class DarwinTargetInfo : public OSTargetInfo<Target> {
protected:
@@ -245,8 +248,17 @@ public:
virtual const char *getUnicodeStringSection() const {
return "__TEXT,__ustring";
}
+
+ virtual std::string isValidSectionSpecifier(const llvm::StringRef &SR) const {
+ // Let MCSectionMachO validate this.
+ llvm::StringRef Segment, Section;
+ unsigned TAA, StubSize;
+ return llvm::MCSectionMachO::ParseSectionSpecifier(SR, Segment, Section,
+ TAA, StubSize);
+ }
};
+
// DragonFlyBSD Target
template<typename Target>
class DragonFlyBSDTargetInfo : public OSTargetInfo<Target> {