llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: llvmbot <details> <summary>Changes</summary> Backport dc222c2de55988f5359262a0e29fed5c14e824e7 Requested by: @<!-- -->ChuanqiXu9 --- Full diff: https://github.com/llvm/llvm-project/pull/219097.diff 2 Files Affected: - (modified) clang/lib/Serialization/ASTReader.cpp (+9-4) - (modified) clang/test/Modules/merge-target-features.cpp (+22) ``````````diff diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 4d3816d686730..1a437f3ebab98 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -523,13 +523,18 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts, // We compute the set difference in both directions explicitly so that we can // diagnose the differences differently. + auto FeatureLess = [](StringRef A, StringRef B) { + return A.substr(1) < B.substr(1); + }; + SmallVector<StringRef, 4> UnmatchedExistingFeatures, UnmatchedReadFeatures; - std::set_difference( - ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(), - ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures)); + std::set_difference(ExistingFeatures.begin(), ExistingFeatures.end(), + ReadFeatures.begin(), ReadFeatures.end(), + std::back_inserter(UnmatchedExistingFeatures), + FeatureLess); std::set_difference(ReadFeatures.begin(), ReadFeatures.end(), ExistingFeatures.begin(), ExistingFeatures.end(), - std::back_inserter(UnmatchedReadFeatures)); + std::back_inserter(UnmatchedReadFeatures), FeatureLess); // If we are allowing compatible differences and the read feature set is // a strict subset of the existing feature set, there is nothing to diagnose. diff --git a/clang/test/Modules/merge-target-features.cpp b/clang/test/Modules/merge-target-features.cpp index c3678cbea11cb..f008492b7e341 100644 --- a/clang/test/Modules/merge-target-features.cpp +++ b/clang/test/Modules/merge-target-features.cpp @@ -148,6 +148,28 @@ // RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ // RUN: | FileCheck --allow-empty --check-prefix=IGNORED2 %s // IGNORED2-NOT: error: +// +// RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -emit-module -fmodule-name=foo -o %t/foo-order.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature -cx16 -target-feature +sse2 \ +// RUN: Inputs/merge-target-features/module.modulemap +// +// RUN: not %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \ +// RUN: -iquote Inputs/merge-target-features \ +// RUN: -fno-implicit-modules \ +// RUN: -fmodule-map-file-home-is-cwd \ +// RUN: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo-order.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --check-prefix=ORDER --implicit-check-not=error: %s +// ORDER: error: precompiled file '{{.*}}foo-order.pcm' was compiled with the target feature '-cx16' but the current translation unit is not +// ORDER: error: {{.*}} configuration mismatch #include "foo.h" `````````` </details> https://github.com/llvm/llvm-project/pull/219097 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
