diff options
author | Alp Toker <alp@nuanti.com> | 2014-07-06 05:26:44 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-07-06 05:26:44 +0000 |
commit | 80758084f70dbdaa4ca16661871215bacee0ab18 (patch) | |
tree | 6b8f303b64953d187cb79f3631f1c5a7cb3c6f14 | |
parent | 269d840e40cdff7ff677fe11361af91e759ac1f1 (diff) | |
download | bcm5719-llvm-80758084f70dbdaa4ca16661871215bacee0ab18.tar.gz bcm5719-llvm-80758084f70dbdaa4ca16661871215bacee0ab18.zip |
Use non-intrusive refcounting for TargetOptions
llvm-svn: 212388
-rw-r--r-- | clang/include/clang/Basic/TargetInfo.h | 11 | ||||
-rw-r--r-- | clang/include/clang/Basic/TargetOptions.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Frontend/ASTUnit.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Frontend/CompilerInvocation.h | 2 | ||||
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 39 | ||||
-rw-r--r-- | clang/lib/Frontend/ChainedIncludesSource.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Basic/SourceManagerTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Lex/LexerTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Lex/PPCallbacksTest.cpp | 14 | ||||
-rw-r--r-- | clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp | 4 |
12 files changed, 45 insertions, 53 deletions
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 49fa78a1d59..f4dcc0e5b50 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -47,7 +47,7 @@ namespace Builtin { struct Info; } /// \brief Exposes information about the current target. /// class TargetInfo : public RefCountedBase<TargetInfo> { - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; llvm::Triple Triple; protected: // Target values set by the ctor of the actual target implementation. Default @@ -94,8 +94,9 @@ public: /// \param Opts - The options to use to initialize the target. The target may /// modify the options to canonicalize the target feature information to match /// what the backend expects. - static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags, - TargetOptions *Opts); + static TargetInfo * + CreateTargetInfo(DiagnosticsEngine &Diags, + const std::shared_ptr<TargetOptions> &Opts); virtual ~TargetInfo(); @@ -105,10 +106,6 @@ public: return *TargetOpts; } - void setTargetOpts(TargetOptions *TargetOpts) { - this->TargetOpts = TargetOpts; - } - ///===---- Target Data Type Query Methods -------------------------------===// enum IntType { NoInt = 0, diff --git a/clang/include/clang/Basic/TargetOptions.h b/clang/include/clang/Basic/TargetOptions.h index d8a10a5e0b5..2c86c31c239 100644 --- a/clang/include/clang/Basic/TargetOptions.h +++ b/clang/include/clang/Basic/TargetOptions.h @@ -15,15 +15,13 @@ #ifndef LLVM_CLANG_FRONTEND_TARGETOPTIONS_H #define LLVM_CLANG_FRONTEND_TARGETOPTIONS_H -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/IntrusiveRefCntPtr.h" #include <string> #include <vector> namespace clang { /// \brief Options for controlling the target. -class TargetOptions : public RefCountedBase<TargetOptions> { +class TargetOptions { public: /// If given, the name of the target triple to compile for. If not given the /// target will be selected to match the host. diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index c9ba6d238da..42dc69ab4a1 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -91,7 +91,7 @@ private: IntrusiveRefCntPtr<TargetInfo> Target; IntrusiveRefCntPtr<Preprocessor> PP; IntrusiveRefCntPtr<ASTContext> Ctx; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts; IntrusiveRefCntPtr<ASTReader> Reader; bool HadModuleLoaderFatalFailure; diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index 0305d8a9afb..f05ab80c8d5 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -57,7 +57,7 @@ public: std::shared_ptr<LangOptions> LangOpts; /// Options controlling the target. - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; /// Options controlling the diagnostic engine. IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts; diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index cc20388974e..a28436cfe03 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -6388,8 +6388,9 @@ static TargetInfo *AllocateTarget(const llvm::Triple &Triple) { /// CreateTargetInfo - Return the target info object for the specified target /// triple. -TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, - TargetOptions *Opts) { +TargetInfo * +TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, + const std::shared_ptr<TargetOptions> &Opts) { llvm::Triple Triple(Opts->Triple); // Construct the target @@ -6398,7 +6399,7 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags, Diags.Report(diag::err_target_unknown_triple) << Triple.str(); return nullptr; } - Target->setTargetOpts(Opts); + Target->TargetOpts = Opts; // Set the target CPU if specified. if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) { diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 15f4ca4b0e8..f8c25ca88ad 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -504,20 +504,17 @@ class ASTInfoCollector : public ASTReaderListener { Preprocessor &PP; ASTContext &Context; LangOptions &LangOpt; - IntrusiveRefCntPtr<TargetOptions> &TargetOpts; + std::shared_ptr<TargetOptions> &TargetOpts; IntrusiveRefCntPtr<TargetInfo> &Target; unsigned &Counter; bool InitializedLanguage; public: - ASTInfoCollector(Preprocessor &PP, ASTContext &Context, LangOptions &LangOpt, - IntrusiveRefCntPtr<TargetOptions> &TargetOpts, - IntrusiveRefCntPtr<TargetInfo> &Target, - unsigned &Counter) - : PP(PP), Context(Context), LangOpt(LangOpt), - TargetOpts(TargetOpts), Target(Target), - Counter(Counter), - InitializedLanguage(false) {} + ASTInfoCollector(Preprocessor &PP, ASTContext &Context, LangOptions &LangOpt, + std::shared_ptr<TargetOptions> &TargetOpts, + IntrusiveRefCntPtr<TargetInfo> &Target, unsigned &Counter) + : PP(PP), Context(Context), LangOpt(LangOpt), TargetOpts(TargetOpts), + Target(Target), Counter(Counter), InitializedLanguage(false) {} bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain) override { @@ -536,10 +533,10 @@ public: // If we've already initialized the target, don't do it again. if (Target) return false; - - this->TargetOpts = new TargetOptions(TargetOpts); - Target = TargetInfo::CreateTargetInfo(PP.getDiagnostics(), - &*this->TargetOpts); + + this->TargetOpts = std::make_shared<TargetOptions>(TargetOpts); + Target = + TargetInfo::CreateTargetInfo(PP.getDiagnostics(), this->TargetOpts); updated(); return false; @@ -1066,8 +1063,8 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) { Clang->setDiagnostics(&getDiagnostics()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), - &Clang->getTargetOpts())); + Clang->setTarget(TargetInfo::CreateTargetInfo( + Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); if (!Clang->hasTarget()) { delete OverrideMainBuffer; return true; @@ -1565,8 +1562,8 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble( Clang->setDiagnostics(&getDiagnostics()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), - &Clang->getTargetOpts())); + Clang->setTarget(TargetInfo::CreateTargetInfo( + Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); if (!Clang->hasTarget()) { llvm::sys::fs::remove(FrontendOpts.OutputFile); Preamble.clear(); @@ -1832,8 +1829,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( Clang->setDiagnostics(&AST->getDiagnostics()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), - &Clang->getTargetOpts())); + Clang->setTarget(TargetInfo::CreateTargetInfo( + Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); if (!Clang->hasTarget()) return nullptr; @@ -2409,8 +2406,8 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column, ProcessWarningOptions(Diag, CCInvocation->getDiagnosticOpts()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), - &Clang->getTargetOpts())); + Clang->setTarget(TargetInfo::CreateTargetInfo( + Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); if (!Clang->hasTarget()) { Clang->setInvocation(nullptr); return; diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp index 45851a0d60f..01897cbf2a3 100644 --- a/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -100,8 +100,8 @@ ChainedIncludesSource::create(CompilerInstance &CI) { std::unique_ptr<CompilerInstance> Clang(new CompilerInstance()); Clang->setInvocation(CInvok.release()); Clang->setDiagnostics(Diags.get()); - Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(), - &Clang->getTargetOpts())); + Clang->setTarget(TargetInfo::CreateTargetInfo( + Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); Clang->createFileManager(); Clang->createSourceManager(Clang->getFileManager()); Clang->createPreprocessor(TU_Prefix); diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index da663fe9be2..93799c8c43a 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -712,7 +712,8 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { raw_ostream &OS = llvm::errs(); // Create the target instance. - setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), &getTargetOpts())); + setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), + getInvocation().TargetOpts)); if (!hasTarget()) return false; diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp index 5416ea7ef44..9ea093c6b2b 100644 --- a/clang/unittests/Basic/SourceManagerTest.cpp +++ b/clang/unittests/Basic/SourceManagerTest.cpp @@ -38,7 +38,7 @@ protected: SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions) { TargetOpts->Triple = "x86_64-apple-darwin11.1.0"; - Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts); + Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } FileSystemOptions FileMgrOpts; @@ -47,7 +47,7 @@ protected: DiagnosticsEngine Diags; SourceManager SourceMgr; LangOptions LangOpts; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<TargetInfo> Target; }; diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp index 938ad4d26e9..2d75b52276c 100644 --- a/clang/unittests/Lex/LexerTest.cpp +++ b/clang/unittests/Lex/LexerTest.cpp @@ -57,7 +57,7 @@ protected: TargetOpts(new TargetOptions) { TargetOpts->Triple = "x86_64-apple-darwin11.1.0"; - Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts); + Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } std::vector<Token> CheckLex(StringRef Source, @@ -108,7 +108,7 @@ protected: DiagnosticsEngine Diags; SourceManager SourceMgr; LangOptions LangOpts; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<TargetInfo> Target; }; diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp index c5fd5702ea9..a1af7540363 100644 --- a/clang/unittests/Lex/PPCallbacksTest.cpp +++ b/clang/unittests/Lex/PPCallbacksTest.cpp @@ -116,14 +116,12 @@ public: class PPCallbacksTest : public ::testing::Test { protected: PPCallbacksTest() - : FileMgr(FileMgrOpts), - DiagID(new DiagnosticIDs()), - DiagOpts(new DiagnosticOptions()), - Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()), - SourceMgr(Diags, FileMgr) { - TargetOpts = new TargetOptions(); + : FileMgr(FileMgrOpts), DiagID(new DiagnosticIDs()), + DiagOpts(new DiagnosticOptions()), + Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()), + SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions()) { TargetOpts->Triple = "x86_64-apple-darwin11.1.0"; - Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts); + Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } FileSystemOptions FileMgrOpts; @@ -133,7 +131,7 @@ protected: DiagnosticsEngine Diags; SourceManager SourceMgr; LangOptions LangOpts; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<TargetInfo> Target; // Register a header path as a known file and add its location diff --git a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp index 8659f0fc934..e63106c295a 100644 --- a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp +++ b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp @@ -38,7 +38,7 @@ protected: TargetOpts(new TargetOptions) { TargetOpts->Triple = "x86_64-apple-darwin11.1.0"; - Target = TargetInfo::CreateTargetInfo(Diags, &*TargetOpts); + Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } FileSystemOptions FileMgrOpts; @@ -47,7 +47,7 @@ protected: DiagnosticsEngine Diags; SourceManager SourceMgr; LangOptions LangOpts; - IntrusiveRefCntPtr<TargetOptions> TargetOpts; + std::shared_ptr<TargetOptions> TargetOpts; IntrusiveRefCntPtr<TargetInfo> Target; }; |