[cfe-commits] r93331 - in /cfe/trunk: include/clang/Frontend/CompilerInstance.h include/clang/Frontend/Utils.h lib/Basic/Targets.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/InitPreprocessor.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Jan 13 10:51:17 PST 2010
Author: fjahanian
Date: Wed Jan 13 12:51:17 2010
New Revision: 93331
URL: http://llvm.org/viewvc/llvm-project?rev=93331&view=rev
Log:
Predefine __weak attribute when doing objective-c
rewriting for any target. (refixes radar 7530235).
Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=93331&r1=93330&r2=93331&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Wed Jan 13 12:51:17 2010
@@ -488,6 +488,7 @@
const HeaderSearchOptions &,
const DependencyOutputOptions &,
const TargetInfo &,
+ const FrontendOptions &,
SourceManager &, FileManager &);
/// Create the AST context.
Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=93331&r1=93330&r2=93331&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Jan 13 12:51:17 2010
@@ -39,6 +39,7 @@
class SourceManager;
class Stmt;
class TargetInfo;
+class FrontendOptions;
class MacroBuilder {
llvm::raw_ostream &Out;
@@ -76,7 +77,8 @@
/// environment ready to process a single file.
void InitializePreprocessor(Preprocessor &PP,
const PreprocessorOptions &PPOpts,
- const HeaderSearchOptions &HSOpts);
+ const HeaderSearchOptions &HSOpts,
+ const FrontendOptions &FEOpts);
/// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=93331&r1=93330&r2=93331&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jan 13 12:51:17 2010
@@ -994,10 +994,6 @@
DefineStd(Builder, "WIN32", Opts);
DefineStd(Builder, "WINNT", Opts);
Builder.defineMacro("_X86_");
- if (Opts.ObjC1)
- // __weak is always defined, for use in blocks and with objc pointers,
- // even for i686-pc-win32 targets.
- Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
}
};
} // end anonymous namespace
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=93331&r1=93330&r2=93331&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Jan 13 12:51:17 2010
@@ -158,7 +158,8 @@
PP.reset(createPreprocessor(getDiagnostics(), getLangOpts(),
getPreprocessorOpts(), getHeaderSearchOpts(),
getDependencyOutputOpts(), getTarget(),
- getSourceManager(), getFileManager()));
+ getFrontendOpts(), getSourceManager(),
+ getFileManager()));
}
Preprocessor *
@@ -168,6 +169,7 @@
const HeaderSearchOptions &HSOpts,
const DependencyOutputOptions &DepOpts,
const TargetInfo &Target,
+ const FrontendOptions &FEOpts,
SourceManager &SourceMgr,
FileManager &FileMgr) {
// Create a PTH manager if we are using some form of a token cache.
@@ -189,7 +191,7 @@
PP->setPTHManager(PTHMgr);
}
- InitializePreprocessor(*PP, PPOpts, HSOpts);
+ InitializePreprocessor(*PP, PPOpts, HSOpts, FEOpts);
// Handle generating dependencies, if requested.
if (!DepOpts.OutputFile.empty())
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=93331&r1=93330&r2=93331&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Jan 13 12:51:17 2010
@@ -14,6 +14,7 @@
#include "clang/Frontend/Utils.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/PreprocessorOptions.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/FileManager.h"
@@ -202,6 +203,7 @@
static void InitializePredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
+ const FrontendOptions &FEOpts,
MacroBuilder &Builder) {
// Compiler version introspection macros.
Builder.defineMacro("__llvm__"); // LLVM Backend
@@ -406,6 +408,8 @@
else if (LangOpts.getStackProtectorMode() == LangOptions::SSPReq)
Builder.defineMacro("__SSP_ALL__", "2");
+ if (FEOpts.ProgramAction == frontend::RewriteObjC)
+ Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
// Get other target #defines.
TI.getTargetDefines(LangOpts, Builder);
}
@@ -461,7 +465,8 @@
///
void clang::InitializePreprocessor(Preprocessor &PP,
const PreprocessorOptions &InitOpts,
- const HeaderSearchOptions &HSOpts) {
+ const HeaderSearchOptions &HSOpts,
+ const FrontendOptions &FEOpts) {
std::string PredefineBuffer;
PredefineBuffer.reserve(4080);
llvm::raw_string_ostream Predefines(PredefineBuffer);
@@ -475,7 +480,7 @@
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
if (InitOpts.UsePredefines)
InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
- Builder);
+ FEOpts, Builder);
// Add on the predefines from the driver. Wrap in a #line directive to report
// that they come from the command line.
More information about the cfe-commits
mailing list