unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
/// and target specific predefines.
+ /// The implicit PCH included at the start of the translation unit, or empty.
+ std::string ImplicitPCHInclude;
+
+ /// The implicit PTH input included at the start of the translation unit, or
+ /// empty.
+ std::string ImplicitPTHInclude;
+
public:
PreprocessorOptions() : UsePredefines(true) {}
UsePredefines = Value;
}
+ const std::string &getImplicitPCHInclude() const {
+ return ImplicitPCHInclude;
+ }
+ void setImplicitPCHInclude(llvm::StringRef Value) {
+ assert((Value.empty() || ImplicitPTHInclude.empty()) &&
+ "Cannot both implicit PCH and PTH includes!");
+ ImplicitPCHInclude = Value;
+ }
+
+ const std::string &getImplicitPTHInclude() const {
+ return ImplicitPTHInclude;
+ }
+ void setImplicitPTHInclude(llvm::StringRef Value) {
+ assert((ImplicitPCHInclude.empty() || Value.empty()) &&
+ "Cannot both implicit PCH and PTH includes!");
+ ImplicitPTHInclude = Value;
+ }
+
void addMacroDef(const std::string &Name) {
Macros.push_back(std::make_pair(Name, false));
}
}
static void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
+ InitOpts.setImplicitPCHInclude(ImplicitIncludePCH);
+ InitOpts.setImplicitPTHInclude(ImplicitIncludePTH);
+
// Use predefines?
InitOpts.setUsePredefines(!UndefMacros);
std::string OriginalFile = PCHReader::getOriginalSourceFile(*Ptr);
if (!OriginalFile.empty()) {
InitOpts.addInclude(OriginalFile, false);
- ImplicitIncludePCH.clear();
+ InitOpts.setImplicitPCHInclude("");
}
}
}
const PreprocessorOptions &PPOpts, TargetInfo &Target,
SourceManager &SourceMgr, HeaderSearch &HeaderInfo) {
PTHManager *PTHMgr = 0;
- if (!TokenCache.empty() && !ImplicitIncludePTH.empty()) {
+ if (!TokenCache.empty() && !PPOpts.getImplicitPTHInclude().empty()) {
fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
"options\n");
exit(1);
}
// Use PTH?
- if (!TokenCache.empty() || !ImplicitIncludePTH.empty()) {
- const std::string& x = TokenCache.empty() ? ImplicitIncludePTH:TokenCache;
+ if (!TokenCache.empty() || !PPOpts.getImplicitPTHInclude().empty()) {
+ const std::string& x = TokenCache.empty() ?
+ PPOpts.getImplicitPTHInclude() : TokenCache;
PTHMgr = PTHManager::Create(x, &Diags,
TokenCache.empty() ? Diagnostic::Error
: Diagnostic::Warning);
llvm::OwningPtr<PCHReader> Reader;
llvm::OwningPtr<ExternalASTSource> Source;
- if (!ImplicitIncludePCH.empty()) {
+ const std::string &ImplicitPCHInclude =
+ CompOpts.getPreprocessorOpts().getImplicitPCHInclude();
+ if (!ImplicitPCHInclude.empty()) {
// If the user specified -isysroot, it will be used for relocatable PCH
// files.
const char *isysrootPCH = 0;
// The user has asked us to include a precompiled header. Load
// the precompiled header into the AST context.
- switch (Reader->ReadPCH(ImplicitIncludePCH)) {
+ switch (Reader->ReadPCH(ImplicitPCHInclude)) {
case PCHReader::Success: {
// Set the predefines buffer as suggested by the PCH
// reader. Typically, the predefines buffer will be empty.
PhonyDependencyTarget);
}
- if (ImplicitIncludePCH.empty()) {
+ if (CompOpts.getPreprocessorOpts().getImplicitPCHInclude().empty()) {
if (InitializeSourceManager(*PP.get(), InFile))
continue;