[clang] [clang][Tooling] Preserve -std flag when transferring compile commands across same-family language (PR #184560)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 22 18:35:43 PDT 2026


================
@@ -847,6 +847,20 @@ TEST_F(InterpolateTest, Language) {
             "clang -D dir/aux.cpp -x objective-c++-header -std=c++17");
 }
 
+TEST_F(InterpolateTest, StdTransferSameFamily) {
+  // ObjC++ → C++ header: same standard family, -std should survive.
+  add("dir/foo.mm", "-std=c++20");
+  EXPECT_EQ(getCommand("dir/foo.hh"), "clang -D dir/foo.mm -std=c++20");
+
+  // Explicit -x objective-c++ on .cpp → C++ header: same family.
+  add("dir/bar.cpp", "-x objective-c++ -std=c++20");
+  EXPECT_EQ(getCommand("dir/bar.hh"), "clang -D dir/bar.cpp -std=c++20");
----------------
HighCommander4 wrote:

It's pretty common for C++ code to use just a plain `.h` extension, could we add a test case for that as well?

https://github.com/llvm/llvm-project/pull/184560


More information about the cfe-commits mailing list