[clang] [ObjectiveC] -rewrite-objc was treating inputs as preprocessed files (PR #137623)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 28 05:42:32 PDT 2025
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/137623 at github.com>
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Juan Manuel Martinez Caamaño (jmmartinez)
<details>
<summary>Changes</summary>
`-rewrite-objc` passes `-x objective-c++-cpp-output` as input type to the preprocessor job. This is not correct since we would be preprocessing a preprocessed file. The correct input type is `objective-c++`.
---
Full diff: https://github.com/llvm/llvm-project/pull/137623.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1)
- (added) clang/test/Driver/rewrite-objc-preproc.m (+5)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index f98cd389509cd..4c3d55a62f66d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,7 @@ static void addDashXForInput(const ArgList &Args, const InputInfo &Input,
CmdArgs.push_back("-x");
if (Args.hasArg(options::OPT_rewrite_objc))
- CmdArgs.push_back(types::getTypeName(types::TY_PP_ObjCXX));
+ CmdArgs.push_back(types::getTypeName(types::TY_ObjCXX));
else {
// Map the driver type to the frontend type. This is mostly an identity
// mapping, except that the distinction between module interface units
diff --git a/clang/test/Driver/rewrite-objc-preproc.m b/clang/test/Driver/rewrite-objc-preproc.m
new file mode 100644
index 0000000000000..f32d09c5a15f3
--- /dev/null
+++ b/clang/test/Driver/rewrite-objc-preproc.m
@@ -0,0 +1,5 @@
+// RUN: %clang --target=x86_64-apple-macosx10.7.0 -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck %s
+//
+// Check that we're running a preprocessing stage passing a not-preprocessed objective-c++ file as input
+// CHECK: "-E"{{.*}}"-x" "objective-c++"
``````````
</details>
https://github.com/llvm/llvm-project/pull/137623
More information about the cfe-commits
mailing list