summaryrefslogtreecommitdiff
path: root/test/Driver
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-12-26 21:04:08 +0000
committerReid Kleckner <rnk@google.com>2018-12-26 21:04:08 +0000
commite2e4a2f49fa200f42a380979c29a04a87605b688 (patch)
tree638139b2b9550eda09d45bc2160d21df4c5e07af /test/Driver
parent12391ef6d41a0afb89a515d47c360578f651f5e3 (diff)
downloadclang-e2e4a2f49fa200f42a380979c29a04a87605b688.tar.gz
[clang-cl] Treat inputs as C++ with /E, like MSVC
midl invokes the compiler on .idl files with /E. Before this change, we would treat unrecognized inputs as object files. Now we pre-process to stdout as expected. I checked that MSVC defines __cplusplus when invoked this way, so treating the input as C++ seems like the right thing to do. After this change, I was able to run midl like this with clang-cl: $ midl -cpp_cmd clang-cl.exe foo.idl Things worked for the example IDL file in the Microsoft documentation, but beyond that, I don't know if this will work well. Fixes PR40140 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Driver')
-rw-r--r--test/Driver/cl-idl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/Driver/cl-idl.cpp b/test/Driver/cl-idl.cpp
new file mode 100644
index 0000000000..7843ab3133
--- /dev/null
+++ b/test/Driver/cl-idl.cpp
@@ -0,0 +1,18 @@
+// Note: %s must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// Test that 'clang-cl /E' treats inputs as C++ if the extension is
+// unrecognized. midl relies on this. See PR40140.
+
+// Use a plain .cpp extension first.
+// RUN: %clang_cl /E -- %s | FileCheck %s
+
+// Copy to use .idl as the extension.
+// RUN: cp %s %t.idl
+// RUN: %clang_cl /E -- %t.idl | FileCheck %s
+
+#ifdef __cplusplus
+struct IsCPlusPlus {};
+#endif
+
+// CHECK: struct IsCPlusPlus {};