Since CreateTargetInfo is taking ownership of the target options, pass

it as a pointer. 

llvm-svn: 168136
This commit is contained in:
Douglas Gregor 2012-11-16 04:24:59 +00:00
parent 106d7a2704
commit f8715de599
5 changed files with 26 additions and 26 deletions

View File

@ -109,7 +109,7 @@ public:
/// modify the options to canonicalize the target feature information to match
/// what the backend expects.
static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
TargetOptions &Opts);
TargetOptions *Opts);
virtual ~TargetInfo();
@ -119,8 +119,8 @@ public:
return *TargetOpts;
}
void setTargetOpts(TargetOptions &TargetOpts) {
this->TargetOpts = &TargetOpts;
void setTargetOpts(TargetOptions *TargetOpts) {
this->TargetOpts = TargetOpts;
}
///===---- Target Data Type Query Methods -------------------------------===//

View File

@ -4658,8 +4658,8 @@ static TargetInfo *AllocateTarget(const std::string &T) {
/// CreateTargetInfo - Return the target info object for the specified target
/// triple.
TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
TargetOptions &Opts) {
llvm::Triple Triple(Opts.Triple);
TargetOptions *Opts) {
llvm::Triple Triple(Opts->Triple);
// Construct the target
OwningPtr<TargetInfo> Target(AllocateTarget(Triple.str()));
@ -4670,20 +4670,20 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
Target->setTargetOpts(Opts);
// Set the target CPU if specified.
if (!Opts.CPU.empty() && !Target->setCPU(Opts.CPU)) {
Diags.Report(diag::err_target_unknown_cpu) << Opts.CPU;
if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
return 0;
}
// Set the target ABI if specified.
if (!Opts.ABI.empty() && !Target->setABI(Opts.ABI)) {
Diags.Report(diag::err_target_unknown_abi) << Opts.ABI;
if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;
return 0;
}
// Set the target C++ ABI.
if (!Opts.CXXABI.empty() && !Target->setCXXABI(Opts.CXXABI)) {
Diags.Report(diag::err_target_unknown_cxxabi) << Opts.CXXABI;
if (!Opts->CXXABI.empty() && !Target->setCXXABI(Opts->CXXABI)) {
Diags.Report(diag::err_target_unknown_cxxabi) << Opts->CXXABI;
return 0;
}
@ -4695,8 +4695,8 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
// Apply the user specified deltas.
// First the enables.
for (std::vector<std::string>::const_iterator
it = Opts.FeaturesAsWritten.begin(),
ie = Opts.FeaturesAsWritten.end();
it = Opts->FeaturesAsWritten.begin(),
ie = Opts->FeaturesAsWritten.end();
it != ie; ++it) {
const char *Name = it->c_str();
@ -4712,8 +4712,8 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
// Then the disables.
for (std::vector<std::string>::const_iterator
it = Opts.FeaturesAsWritten.begin(),
ie = Opts.FeaturesAsWritten.end();
it = Opts->FeaturesAsWritten.begin(),
ie = Opts->FeaturesAsWritten.end();
it != ie; ++it) {
const char *Name = it->c_str();
@ -4732,11 +4732,11 @@ TargetInfo *TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
//
// FIXME: If we are completely confident that we have the right set, we only
// need to pass the minuses.
Opts.Features.clear();
Opts->Features.clear();
for (llvm::StringMap<bool>::const_iterator it = Features.begin(),
ie = Features.end(); it != ie; ++it)
Opts.Features.push_back((it->second ? "+" : "-") + it->first().str());
Target->HandleTargetFeatures(Opts.Features);
Opts->Features.push_back((it->second ? "+" : "-") + it->first().str());
Target->HandleTargetFeatures(Opts->Features);
return Target.take();
}

View File

@ -542,8 +542,8 @@ public:
return false;
this->TargetOpts = new TargetOptions(TargetOpts);
Target = TargetInfo::CreateTargetInfo(PP.getDiagnostics(),
*this->TargetOpts);
Target = TargetInfo::CreateTargetInfo(PP.getDiagnostics(),
&*this->TargetOpts);
updated();
return false;
@ -1082,7 +1082,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
// Create the target instance.
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
Clang->getTargetOpts()));
&Clang->getTargetOpts()));
if (!Clang->hasTarget()) {
delete OverrideMainBuffer;
return true;
@ -1551,7 +1551,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
// Create the target instance.
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
Clang->getTargetOpts()));
&Clang->getTargetOpts()));
if (!Clang->hasTarget()) {
llvm::sys::Path(FrontendOpts.OutputFile).eraseFromDisk();
Preamble.clear();
@ -1774,7 +1774,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(CompilerInvocation *CI,
// Create the target instance.
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
Clang->getTargetOpts()));
&Clang->getTargetOpts()));
if (!Clang->hasTarget())
return 0;
@ -2370,7 +2370,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
// Create the target instance.
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
Clang->getTargetOpts()));
&Clang->getTargetOpts()));
if (!Clang->hasTarget()) {
Clang->setInvocation(0);
return;

View File

@ -99,7 +99,7 @@ ChainedIncludesSource *ChainedIncludesSource::create(CompilerInstance &CI) {
Clang->setInvocation(CInvok.take());
Clang->setDiagnostics(Diags.getPtr());
Clang->setTarget(TargetInfo::CreateTargetInfo(Clang->getDiagnostics(),
Clang->getTargetOpts()));
&Clang->getTargetOpts()));
Clang->createFileManager();
Clang->createSourceManager(Clang->getFileManager());
Clang->createPreprocessor();

View File

@ -664,7 +664,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
raw_ostream &OS = llvm::errs();
// Create the target instance.
setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), getTargetOpts()));
setTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), &getTargetOpts()));
if (!hasTarget())
return false;