Author: Juan Manuel Martinez CaamaƱo
Date: 2025-05-12T09:50:15+02:00
New Revision: fbf08a68b8b292bef0823a401e4e22b60d859d51

URL: 
https://github.com/llvm/llvm-project/commit/fbf08a68b8b292bef0823a401e4e22b60d859d51
DIFF: 
https://github.com/llvm/llvm-project/commit/fbf08a68b8b292bef0823a401e4e22b60d859d51.diff

LOG: [ObjectiveC] -rewrite-objc was treating inputs as preprocessed files 
(#137623)

`-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++`.

Added: 
    clang/test/Driver/rewrite-objc-preproc.m

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a08ff044add95..a08bdba99bfe0 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++"


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to