Skip to content

Commit 12069f8

Browse files
committed
Initialize MCs so target machine construction works when targets are present
1 parent 3059cfa commit 12069f8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/unittests/Frontend/OutputStreamTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "clang/FrontendTool/Utils.h"
1515
#include "clang/Lex/PreprocessorOptions.h"
1616
#include "llvm/Support/VirtualFileSystem.h"
17+
#include "llvm/Support/TargetSelect.h"
1718
#include "gtest/gtest.h"
1819

1920
using namespace llvm;
@@ -23,6 +24,7 @@ using namespace clang::frontend;
2324
namespace {
2425

2526
TEST(FrontendOutputTests, TestOutputStream) {
27+
llvm::InitializeAllTargetMCs();
2628
auto Invocation = std::make_shared<CompilerInvocation>();
2729
Invocation->getPreprocessorOpts().addRemappedFile(
2830
"test.cc", MemoryBuffer::getMemBuffer("").release());
@@ -47,6 +49,7 @@ TEST(FrontendOutputTests, TestOutputStream) {
4749
}
4850

4951
TEST(FrontendOutputTests, TestVerboseOutputStreamShared) {
52+
llvm::InitializeAllTargetMCs();
5053
auto Invocation = std::make_shared<CompilerInvocation>();
5154
Invocation->getPreprocessorOpts().addRemappedFile(
5255
"test.cc", MemoryBuffer::getMemBuffer("invalid").release());
@@ -77,6 +80,7 @@ TEST(FrontendOutputTests, TestVerboseOutputStreamOwned) {
7780
std::string VerboseBuffer;
7881
bool Success;
7982
{
83+
llvm::InitializeAllTargetMCs();
8084
auto Invocation = std::make_shared<CompilerInvocation>();
8185
Invocation->getPreprocessorOpts().addRemappedFile(
8286
"test.cc", MemoryBuffer::getMemBuffer("invalid").release());

0 commit comments

Comments
 (0)