diff options
author | Stefan Gränitz <stefan.graenitz@gmail.com> | 2024-03-06 20:23:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 20:23:09 +0100 |
commit | 6494f9bb8ac1e6f7526b72ee07f71527b8e66066 (patch) | |
tree | ccda3b721e69ff3ae7bdfd25c51c8c15414c66d5 /clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp | |
parent | 04bbbba271ebe4c2421f34a4fbf34c328df9f111 (diff) | |
download | llvm-6494f9bb8ac1e6f7526b72ee07f71527b8e66066.zip llvm-6494f9bb8ac1e6f7526b72ee07f71527b8e66066.tar.gz llvm-6494f9bb8ac1e6f7526b72ee07f71527b8e66066.tar.bz2 |
[clang-repl] Expose setter for triple in IncrementalCompilerBuilder (#84174)
With out-of-process execution the target triple can be different from
the one on the host. We need an interface to configure it.
Diffstat (limited to 'clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp')
-rw-r--r-- | clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp b/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp new file mode 100644 index 0000000..1cc0223 --- /dev/null +++ b/clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp @@ -0,0 +1,35 @@ +//=== unittests/Interpreter/IncrementalCompilerBuilderTest.cpp ------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang/Basic/TargetOptions.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Interpreter/Interpreter.h" +#include "llvm/Support/Error.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +TEST(IncrementalCompilerBuilder, SetCompilerArgs) { + std::vector<const char *> ClangArgv = {"-Xclang", "-ast-dump-all"}; + auto CB = clang::IncrementalCompilerBuilder(); + CB.SetCompilerArgs(ClangArgv); + auto CI = cantFail(CB.CreateCpp()); + EXPECT_TRUE(CI->getFrontendOpts().ASTDumpAll); +} + +TEST(IncrementalCompilerBuilder, SetTargetTriple) { + auto CB = clang::IncrementalCompilerBuilder(); + CB.SetTargetTriple("armv6-none-eabi"); + auto CI = cantFail(CB.CreateCpp()); + EXPECT_EQ(CI->getTargetOpts().Triple, "armv6-none-unknown-eabi"); +} + +} // end anonymous namespace |