From 2aba2f1d8bfad031ae59ea5dfec8b65978f908a0 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Thu, 19 Mar 2026 17:28:48 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.7 --- clang/lib/Serialization/ASTReader.cpp | 3 +++ clang/test/Modules/merge-target-features.cpp | 21 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 03b1b02859b81..db4fa68f6db08 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -495,7 +495,10 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts, SmallVector ReadFeatures(TargetOpts.FeaturesAsWritten.begin(), TargetOpts.FeaturesAsWritten.end()); llvm::sort(ExistingFeatures); + ExistingFeatures.erase(llvm::unique(ExistingFeatures), + ExistingFeatures.end()); llvm::sort(ReadFeatures); + ReadFeatures.erase(llvm::unique(ReadFeatures), ReadFeatures.end()); // We compute the set difference in both directions explicitly so that we can // diagnose the differences differently. diff --git a/clang/test/Modules/merge-target-features.cpp b/clang/test/Modules/merge-target-features.cpp index 73474e1388fb6..01d38a1eb0d13 100644 --- a/clang/test/Modules/merge-target-features.cpp +++ b/clang/test/Modules/merge-target-features.cpp @@ -10,6 +10,15 @@ // RUN: -target-cpu i386 -target-feature +sse2 \ // RUN: Inputs/merge-target-features/module.modulemap // +// 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-double.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 -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 \ @@ -60,6 +69,18 @@ // MISMATCH: error: precompiled file '{{.*}}foo.pcm' was compiled with the target feature '+sse2' but the current translation unit is not // MISMATCH: error: current translation unit is compiled with the target feature '+cx16' but the precompiled file '{{.*}}foo.pcm' was not // MISMATCH: error: {{.*}} configuration mismatch +// +// 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: -fmodule-map-file=Inputs/merge-target-features/module.modulemap \ +// RUN: -fmodule-file=%t/foo-double.pcm \ +// RUN: -triple i386-unknown-unknown \ +// RUN: -target-cpu i386 -target-feature +sse2 \ +// RUN: -fsyntax-only merge-target-features.cpp 2>&1 \ +// RUN: | FileCheck --allow-empty --check-prefix=DOUBLE %s +// DOUBLE-NOT: error: #include "foo.h"