-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland [clang-repl] Expose setter for triple in IncrementalCompilerBu…
…ilder (#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. Relanding this with cleanup-fixes in the unittest.
- Loading branch information
1 parent
f78129e
commit 2a4a852
Showing
4 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//=== 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 "clang/Lex/PreprocessorOptions.h" | ||
#include "llvm/Support/Error.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace llvm; | ||
using namespace clang; | ||
|
||
namespace { | ||
|
||
// Usually FrontendAction takes the raw pointers and wraps them back into | ||
// unique_ptrs in InitializeFileRemapping() | ||
static void cleanupRemappedFileBuffers(CompilerInstance &CI) { | ||
for (const auto &RB : CI.getPreprocessorOpts().RemappedFileBuffers) { | ||
delete RB.second; | ||
} | ||
CI.getPreprocessorOpts().clearRemappedFiles(); | ||
} | ||
|
||
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); | ||
cleanupRemappedFileBuffers(*CI); | ||
} | ||
|
||
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"); | ||
cleanupRemappedFileBuffers(*CI); | ||
} | ||
|
||
} // end anonymous namespace |