[cfe-commits] r86940 - in /cfe/trunk: include/clang/Frontend/PreprocessorOptions.h tools/clang-cc/Options.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 11 18:53:59 PST 2009
Author: ddunbar
Date: Wed Nov 11 20:53:59 2009
New Revision: 86940
URL: http://llvm.org/viewvc/llvm-project?rev=86940&view=rev
Log:
Move TokenCache option to PreprocessorOptions.
Modified:
cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PreprocessorOptions.h?rev=86940&r1=86939&r2=86940&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOptions.h Wed Nov 11 20:53:59 2009
@@ -37,6 +37,9 @@
/// empty.
std::string ImplicitPTHInclude;
+ /// If given, a PTH cache file to use for speeding up header parsing.
+ std::string TokenCache;
+
public:
PreprocessorOptions() : UsePredefines(true) {}
@@ -63,6 +66,13 @@
ImplicitPTHInclude = Value;
}
+ const std::string &getTokenCache() const {
+ return TokenCache;
+ }
+ void setTokenCache(llvm::StringRef Value) {
+ TokenCache = Value;
+ }
+
void addMacroDef(llvm::StringRef Name) {
Macros.push_back(std::make_pair(Name, false));
}
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=86940&r1=86939&r2=86940&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Wed Nov 11 20:53:59 2009
@@ -491,6 +491,10 @@
ImplicitIncludePTH("include-pth", llvm::cl::value_desc("file"),
llvm::cl::desc("Include file before parsing"));
+static llvm::cl::opt<std::string>
+TokenCache("token-cache", llvm::cl::value_desc("path"),
+ llvm::cl::desc("Use specified token cache file"));
+
static llvm::cl::list<std::string>
U_macros("U", llvm::cl::value_desc("macro"), llvm::cl::Prefix,
llvm::cl::desc("Undefine the specified macro"));
@@ -776,6 +780,19 @@
Opts.setImplicitPCHInclude(ImplicitIncludePCH);
Opts.setImplicitPTHInclude(ImplicitIncludePTH);
+ // Select the token cache file, we don't support more than one currently so we
+ // can't have both an implicit-pth and a token cache file.
+ if (TokenCache.getPosition() && ImplicitIncludePTH.getPosition()) {
+ // FIXME: Don't fail like this.
+ fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
+ "options\n");
+ exit(1);
+ }
+ if (TokenCache.getPosition())
+ Opts.setTokenCache(TokenCache);
+ else
+ Opts.setTokenCache(ImplicitIncludePTH);
+
// Use predefines?
Opts.setUsePredefines(!UndefMacros);
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86940&r1=86939&r2=86940&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Nov 11 20:53:59 2009
@@ -254,10 +254,6 @@
llvm::cl::desc("Print the amount of time each "
"phase of compilation takes"));
-static llvm::cl::opt<std::string>
-TokenCache("token-cache", llvm::cl::value_desc("path"),
- llvm::cl::desc("Use specified token cache file"));
-
static llvm::cl::opt<bool>
VerifyDiagnostics("verify",
llvm::cl::desc("Verify emitted diagnostics and warnings"));
@@ -381,20 +377,12 @@
const DependencyOutputOptions &DepOpts,
TargetInfo &Target, SourceManager &SourceMgr,
FileManager &FileMgr) {
+ // Create a PTH manager if we are using some form of a token cache.
PTHManager *PTHMgr = 0;
- 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() || !PPOpts.getImplicitPTHInclude().empty()) {
- const std::string& x = TokenCache.empty() ?
- PPOpts.getImplicitPTHInclude() : TokenCache;
- PTHMgr = PTHManager::Create(x, Diags);
- }
+ if (!PPOpts.getTokenCache().empty())
+ PTHMgr = PTHManager::Create(PPOpts.getTokenCache(), Diags);
+ // FIXME: Don't fail like this.
if (Diags.hasErrorOccurred())
exit(1);
More information about the cfe-commits
mailing list