brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 7b4633b Raw
56 lines · cpp
1//=== unittests/Interpreter/IncrementalCompilerBuilderTest.cpp ------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "clang/Basic/TargetOptions.h"10#include "clang/Frontend/CompilerInstance.h"11#include "clang/Interpreter/Interpreter.h"12#include "clang/Lex/PreprocessorOptions.h"13#include "llvm/Support/Error.h"14#include "gtest/gtest.h"15 16using namespace llvm;17using namespace clang;18 19namespace {20 21// Usually FrontendAction takes the raw pointers and wraps them back into22// unique_ptrs in InitializeFileRemapping()23static void cleanupRemappedFileBuffers(CompilerInstance &CI) {24  for (const auto &RB : CI.getPreprocessorOpts().RemappedFileBuffers) {25    delete RB.second;26  }27  CI.getPreprocessorOpts().clearRemappedFiles();28}29 30TEST(IncrementalCompilerBuilder, SetCompilerArgs) {31  std::vector<const char *> ClangArgv = {"-Xclang", "-ast-dump-all"};32  auto CB = clang::IncrementalCompilerBuilder();33  CB.SetCompilerArgs(ClangArgv);34  auto CI = cantFail(CB.CreateCpp());35  EXPECT_TRUE(CI->getFrontendOpts().ASTDumpAll);36  cleanupRemappedFileBuffers(*CI);37}38 39TEST(IncrementalCompilerBuilder, SetTargetTriple) {40// FIXME : This test doesn't current work for Emscripten builds.41// It should be possible to make it work.For details on how it fails and42// the current progress to enable this test see43// the following Github issue https: //44// github.com/llvm/llvm-project/issues/15346145#ifdef __EMSCRIPTEN__46  GTEST_SKIP() << "Test fails for Emscipten builds";47#endif48  auto CB = clang::IncrementalCompilerBuilder();49  CB.SetTargetTriple("armv6-none-eabi");50  auto CI = cantFail(CB.CreateCpp());51  EXPECT_EQ(CI->getTargetOpts().Triple, "armv6-unknown-none-eabi");52  cleanupRemappedFileBuffers(*CI);53}54 55} // end anonymous namespace56