forked from OSchip/llvm-project
Teach ASTUnit to save the specified target features, since
TargetInfo::CreateTargetInfo() mangles the target options in a way that is not idempotent. Fixes <rdar://problem/8807535>. llvm-svn: 124382
This commit is contained in:
parent
3b266a2780
commit
ffd6dc432e
|
@ -84,6 +84,13 @@ private:
|
||||||
/// LoadFromCommandLine available.
|
/// LoadFromCommandLine available.
|
||||||
llvm::OwningPtr<CompilerInvocation> Invocation;
|
llvm::OwningPtr<CompilerInvocation> Invocation;
|
||||||
|
|
||||||
|
/// \brief The set of target features.
|
||||||
|
///
|
||||||
|
/// FIXME: each time we reparse, we need to restore the set of target
|
||||||
|
/// features from this vector, because TargetInfo::CreateTargetInfo()
|
||||||
|
/// mangles the target options in place. Yuck!
|
||||||
|
std::vector<std::string> TargetFeatures;
|
||||||
|
|
||||||
// OnlyLocalDecls - when true, walking this AST should only visit declarations
|
// OnlyLocalDecls - when true, walking this AST should only visit declarations
|
||||||
// that come from the AST itself, not from included precompiled headers.
|
// that come from the AST itself, not from included precompiled headers.
|
||||||
// FIXME: This is temporary; eventually, CIndex will always do this.
|
// FIXME: This is temporary; eventually, CIndex will always do this.
|
||||||
|
|
|
@ -740,6 +740,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
|
||||||
Clang.setDiagnostics(&getDiagnostics());
|
Clang.setDiagnostics(&getDiagnostics());
|
||||||
|
|
||||||
// Create the target instance.
|
// Create the target instance.
|
||||||
|
Clang.getTargetOpts().Features = TargetFeatures;
|
||||||
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
||||||
Clang.getTargetOpts()));
|
Clang.getTargetOpts()));
|
||||||
if (!Clang.hasTarget()) {
|
if (!Clang.hasTarget()) {
|
||||||
|
@ -1229,6 +1230,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
|
||||||
Clang.setDiagnostics(&getDiagnostics());
|
Clang.setDiagnostics(&getDiagnostics());
|
||||||
|
|
||||||
// Create the target instance.
|
// Create the target instance.
|
||||||
|
Clang.getTargetOpts().Features = TargetFeatures;
|
||||||
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
||||||
Clang.getTargetOpts()));
|
Clang.getTargetOpts()));
|
||||||
if (!Clang.hasTarget()) {
|
if (!Clang.hasTarget()) {
|
||||||
|
@ -1418,6 +1420,9 @@ bool ASTUnit::LoadFromCompilerInvocation(bool PrecompilePreamble) {
|
||||||
Invocation->getFrontendOpts().DisableFree = false;
|
Invocation->getFrontendOpts().DisableFree = false;
|
||||||
ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
|
ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
|
||||||
|
|
||||||
|
// Save the target features.
|
||||||
|
TargetFeatures = Invocation->getTargetOpts().Features;
|
||||||
|
|
||||||
llvm::MemoryBuffer *OverrideMainBuffer = 0;
|
llvm::MemoryBuffer *OverrideMainBuffer = 0;
|
||||||
if (PrecompilePreamble) {
|
if (PrecompilePreamble) {
|
||||||
PreambleRebuildCounter = 2;
|
PreambleRebuildCounter = 2;
|
||||||
|
@ -1876,6 +1881,7 @@ void ASTUnit::CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column,
|
||||||
StoredDiagnostics);
|
StoredDiagnostics);
|
||||||
|
|
||||||
// Create the target instance.
|
// Create the target instance.
|
||||||
|
Clang.getTargetOpts().Features = TargetFeatures;
|
||||||
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
Clang.setTarget(TargetInfo::CreateTargetInfo(Clang.getDiagnostics(),
|
||||||
Clang.getTargetOpts()));
|
Clang.getTargetOpts()));
|
||||||
if (!Clang.hasTarget()) {
|
if (!Clang.hasTarget()) {
|
||||||
|
|
|
@ -720,7 +720,7 @@ int perform_test_reparse_source(int argc, const char **argv, int trials,
|
||||||
|
|
||||||
Idx = clang_createIndex(/* excludeDeclsFromPCH */
|
Idx = clang_createIndex(/* excludeDeclsFromPCH */
|
||||||
!strcmp(filter, "local") ? 1 : 0,
|
!strcmp(filter, "local") ? 1 : 0,
|
||||||
/* displayDiagnosics=*/1);
|
/* displayDiagnosics=*/0);
|
||||||
|
|
||||||
if (parse_remapped_files(argc, argv, 0, &unsaved_files, &num_unsaved_files)) {
|
if (parse_remapped_files(argc, argv, 0, &unsaved_files, &num_unsaved_files)) {
|
||||||
clang_disposeIndex(Idx);
|
clang_disposeIndex(Idx);
|
||||||
|
|
Loading…
Reference in New Issue