diff options
author | Steve Naroff <snaroff@apple.com> | 2008-03-10 20:43:59 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-03-10 20:43:59 +0000 |
commit | 4f943c23a47d042c3275e78f2d6015daa650f105 (patch) | |
tree | 6e71f101700d35a76c22f75dd9ad287de2c07fe7 /Driver/RewriteTest.cpp | |
parent | 15bd799214ece987cc7eb8351a1a3bca6addfc7e (diff) |
Pass LangOptions to RewriteTest().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48172 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r-- | Driver/RewriteTest.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 097aa1b3a5..2b48a63587 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -35,6 +35,7 @@ namespace { class RewriteTest : public ASTConsumer { Rewriter Rewrite; Diagnostic &Diags; + const LangOptions &LangOpts; unsigned RewriteFailedDiag; ASTContext *Context; @@ -84,7 +85,8 @@ namespace { // Top Level Driver code. virtual void HandleTopLevelDecl(Decl *D); void HandleDeclInMainFile(Decl *D); - RewriteTest(bool isHeader, Diagnostic &D) : Diags(D) { + RewriteTest(bool isHeader, Diagnostic &D, const LangOptions &LOpts) : + Diags(D), LangOpts(LOpts) { IsHeader = isHeader; RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning, "rewriting sub-expression within a macro (may not be correct)"); @@ -224,8 +226,9 @@ static bool IsHeaderFile(const std::string &Filename) { } ASTConsumer *clang::CreateCodeRewriterTest(const std::string& InFile, - Diagnostic &Diags) { - return new RewriteTest(IsHeaderFile(InFile), Diags); + Diagnostic &Diags, + const LangOptions &LOpts) { + return new RewriteTest(IsHeaderFile(InFile), Diags, LOpts); } void RewriteTest::Initialize(ASTContext &context) { @@ -298,6 +301,11 @@ void RewriteTest::Initialize(ASTContext &context) { "unsigned long extra[5];\n};\n" "#define __FASTENUMERATIONSTATE\n" "#endif\n"; + if (LangOpts.Microsoft) { + std::string S = s; + S += "#define __attribute__(X)\n"; + s = S.c_str(); + } if (IsHeader) { // insert the whole string when rewriting a header file InsertText(SourceLocation::getFileLoc(MainFileID, 0), s, strlen(s)); @@ -2852,6 +2860,13 @@ void RewriteTest::RewriteImplementations(std::string &Result) { Result += "\t" + utostr(OBJC_ABI_VERSION) + ", sizeof(struct _objc_module), \"\", &_OBJC_SYMBOLS\n"; Result += "};\n\n"; - + + if (LangOpts.Microsoft) { + Result += "#pragma section(\".objc_module_info$B\",long,read,write)\n"; + Result += "#pragma data_seq(push, \".objc_module_info$B\")\n"; + Result += "static struct _objc_module *_POINTER_OBJC_MODULES = "; + Result += "&_OBJC_MODULES;\n"; + Result += "#pragma data_seg(pop)\n\n"; + } } |