[clang] [clang] test should not depend on system header (PR #119903)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 13 09:16:19 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Yuxuan Chen (yuxuanchen1997)

<details>
<summary>Changes</summary>

https://github.com/llvm/llvm-project/commit/30ad53b92cec0cff9679d559edcc5b933312ba0c introduced a new test that includes <vector> from the system include path without honoring environment variables that may provide the path to C++ standard library. This is not supported in some CI systems because we don't always have a <vector> in standard location. 

The conventional way of doing includes in the test is through `Inputs` directory and pass it as an include path. 

The `vector` file included in this patch has been shortened, but I have verified that it works with this test. i.e. the clang repl crashes on this test in the same way if the fix in https://github.com/llvm/llvm-project/pull/117475 is reverted.

---
Full diff: https://github.com/llvm/llvm-project/pull/119903.diff


2 Files Affected:

- (added) clang/test/Interpreter/Inputs/vector (+8) 
- (modified) clang/test/Interpreter/crash.cpp (+1-1) 


``````````diff
diff --git a/clang/test/Interpreter/Inputs/vector b/clang/test/Interpreter/Inputs/vector
new file mode 100644
index 00000000000000..2add83c58e0d17
--- /dev/null
+++ b/clang/test/Interpreter/Inputs/vector
@@ -0,0 +1,8 @@
+#ifndef VECTOR
+#define VECTOR
+template <typename>
+class vector {
+public:
+  vector();
+};
+#endif // VECTOR
diff --git a/clang/test/Interpreter/crash.cpp b/clang/test/Interpreter/crash.cpp
index 1ab24b0febfa15..9a606983524d82 100644
--- a/clang/test/Interpreter/crash.cpp
+++ b/clang/test/Interpreter/crash.cpp
@@ -5,7 +5,7 @@
 //
 // RUN: split-file %s %t
 //
-// RUN: %clang++ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
+// RUN: %clang++ -Xclang -nostdsysteminc -I%S/Inputs/ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o
 // RUN: %clang++ -shared %t/vec.o -o %t/vec.so
 //
 // RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl

``````````

</details>


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


More information about the cfe-commits mailing list