oToToT created this revision. oToToT added reviewers: sammccall, rsmith, klimek, dexonsmith. oToToT added a project: clang. oToToT requested review of this revision. Herald added a subscriber: cfe-commits.
As proposed in D97109 <https://reviews.llvm.org/D97109>, I tried to replace all similar target creating logics to a single CompilerInstance::createTarget call introduced in D97493 <https://reviews.llvm.org/D97493>. This improve the consistency while creating Target. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D97561 Files: clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/ChainedIncludesSource.cpp clang/lib/Frontend/PrecompiledPreamble.cpp clang/tools/clang-import-test/clang-import-test.cpp
Index: clang/tools/clang-import-test/clang-import-test.cpp =================================================================== --- clang/tools/clang-import-test/clang-import-test.cpp +++ clang/tools/clang-import-test/clang-import-test.cpp @@ -205,10 +205,7 @@ Ins->setInvocation(std::move(Inv)); - TargetInfo *TI = TargetInfo::CreateTargetInfo( - Ins->getDiagnostics(), Ins->getInvocation().TargetOpts); - Ins->setTarget(TI); - Ins->getTarget().adjust(Ins->getLangOpts()); + Ins->createTarget(); Ins->createFileManager(); Ins->createSourceManager(Ins->getFileManager()); Ins->createPreprocessor(TU_Complete); Index: clang/lib/Frontend/PrecompiledPreamble.cpp =================================================================== --- clang/lib/Frontend/PrecompiledPreamble.cpp +++ clang/lib/Frontend/PrecompiledPreamble.cpp @@ -365,17 +365,9 @@ Clang->setDiagnostics(&Diagnostics); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo( - Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); - if (!Clang->hasTarget()) + if (!Clang->createTarget()) return BuildPreambleError::CouldntCreateTargetInfo; - // Inform the target of the language options. - // - // FIXME: We shouldn't need to do this, the target should be immutable once - // created. This complexity should be lifted elsewhere. - Clang->getTarget().adjust(Clang->getLangOpts()); - if (Clang->getFrontendOpts().Inputs.size() != 1 || Clang->getFrontendOpts().Inputs[0].getKind().getFormat() != InputKind::Source || Index: clang/lib/Frontend/ChainedIncludesSource.cpp =================================================================== --- clang/lib/Frontend/ChainedIncludesSource.cpp +++ clang/lib/Frontend/ChainedIncludesSource.cpp @@ -149,8 +149,7 @@ new CompilerInstance(CI.getPCHContainerOperations())); Clang->setInvocation(std::move(CInvok)); Clang->setDiagnostics(Diags.get()); - Clang->setTarget(TargetInfo::CreateTargetInfo( - Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); + Clang->createTarget(); Clang->createFileManager(); Clang->createSourceManager(Clang->getFileManager()); Clang->createPreprocessor(TU_Prefix); Index: clang/lib/Frontend/ASTUnit.cpp =================================================================== --- clang/lib/Frontend/ASTUnit.cpp +++ clang/lib/Frontend/ASTUnit.cpp @@ -1150,17 +1150,9 @@ Clang->setDiagnostics(&getDiagnostics()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo( - Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); - if (!Clang->hasTarget()) + if (!Clang->createTarget()) return true; - // Inform the target of the language options. - // - // FIXME: We shouldn't need to do this, the target should be immutable once - // created. This complexity should be lifted elsewhere. - Clang->getTarget().adjust(Clang->getLangOpts()); - assert(Clang->getFrontendOpts().Inputs.size() == 1 && "Invocation must have exactly one source file!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() == @@ -1568,17 +1560,9 @@ Clang->setDiagnostics(&AST->getDiagnostics()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo( - Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); - if (!Clang->hasTarget()) + if (!Clang->createTarget()) return nullptr; - // Inform the target of the language options. - // - // FIXME: We shouldn't need to do this, the target should be immutable once - // created. This complexity should be lifted elsewhere. - Clang->getTarget().adjust(Clang->getLangOpts()); - assert(Clang->getFrontendOpts().Inputs.size() == 1 && "Invocation must have exactly one source file!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() == @@ -2194,19 +2178,11 @@ ProcessWarningOptions(Diag, Inv.getDiagnosticOpts()); // Create the target instance. - Clang->setTarget(TargetInfo::CreateTargetInfo( - Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); - if (!Clang->hasTarget()) { + if (!Clang->createTarget()) { Clang->setInvocation(nullptr); return; } - // Inform the target of the language options. - // - // FIXME: We shouldn't need to do this, the target should be immutable once - // created. This complexity should be lifted elsewhere. - Clang->getTarget().adjust(Clang->getLangOpts()); - assert(Clang->getFrontendOpts().Inputs.size() == 1 && "Invocation must have exactly one source file!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getFormat() ==
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits