[cfe-commits] r48172 - in /cfe/trunk/Driver: ASTConsumers.h RewriteTest.cpp clang.cpp
Steve Naroff
snaroff at apple.com
Mon Mar 10 13:43:59 PDT 2008
Author: snaroff
Date: Mon Mar 10 15:43:59 2008
New Revision: 48172
URL: http://llvm.org/viewvc/llvm-project?rev=48172&view=rev
Log:
Pass LangOptions to RewriteTest().
Modified:
cfe/trunk/Driver/ASTConsumers.h
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=48172&r1=48171&r2=48172&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Mon Mar 10 15:43:59 2008
@@ -50,7 +50,8 @@
const std::string& FunctionName);
ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
- Diagnostic &Diags);
+ Diagnostic &Diags,
+ const LangOptions &LOpts);
ASTConsumer *CreateSerializationTest(Diagnostic &Diags,
FileManager& FMgr,
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=48172&r1=48171&r2=48172&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Mon Mar 10 15:43:59 2008
@@ -35,6 +35,7 @@
class RewriteTest : public ASTConsumer {
Rewriter Rewrite;
Diagnostic &Diags;
+ const LangOptions &LangOpts;
unsigned RewriteFailedDiag;
ASTContext *Context;
@@ -84,7 +85,8 @@
// 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 @@
}
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 @@
"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 @@
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";
+ }
}
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=48172&r1=48171&r2=48172&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Mar 10 15:43:59 2008
@@ -1032,7 +1032,7 @@
return CreateASTSerializer(InFile, OutputFile, Diag, LangOpts);
case RewriteTest:
- return CreateCodeRewriterTest(InFile, Diag);
+ return CreateCodeRewriterTest(InFile, Diag, LangOpts);
}
}
More information about the cfe-commits
mailing list