const HeaderSearchOptions &,
const DependencyOutputOptions &,
const TargetInfo &,
+ const FrontendOptions &,
SourceManager &, FileManager &);
/// Create the AST context.
class SourceManager;
class Stmt;
class TargetInfo;
+class FrontendOptions;
class MacroBuilder {
llvm::raw_ostream &Out;
/// 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.
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
PP.reset(createPreprocessor(getDiagnostics(), getLangOpts(),
getPreprocessorOpts(), getHeaderSearchOpts(),
getDependencyOutputOpts(), getTarget(),
- getSourceManager(), getFileManager()));
+ getFrontendOpts(), getSourceManager(),
+ getFileManager()));
}
Preprocessor *
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.
PP->setPTHManager(PTHMgr);
}
- InitializePreprocessor(*PP, PPOpts, HSOpts);
+ InitializePreprocessor(*PP, PPOpts, HSOpts, FEOpts);
// Handle generating dependencies, if requested.
if (!DepOpts.OutputFile.empty())
#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"
static void InitializePredefinedMacros(const TargetInfo &TI,
const LangOptions &LangOpts,
+ const FrontendOptions &FEOpts,
MacroBuilder &Builder) {
// Compiler version introspection macros.
Builder.defineMacro("__llvm__"); // LLVM Backend
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);
}
///
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);
// 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.