clang-tools
11.0.0
clang-tools-extra
clangd
unittests
CompilerTests.cpp
Go to the documentation of this file.
1
//===-- CompilerTests.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-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "
Compiler.h
"
10
#include "
TestTU.h
"
11
#include "clang/Lex/PreprocessorOptions.h"
12
#include "gmock/gmock.h"
13
#include "gtest/gtest.h"
14
15
namespace
clang
{
16
namespace
clangd {
17
namespace
{
18
19
using
testing::IsEmpty;
20
21
TEST
(BuildCompilerInvocation, DropsPCH) {
22
MockFS
FS
;
23
IgnoreDiagnostics
Diags
;
24
TestTU TU;
25
TU.AdditionalFiles[
"test.h.pch"
] =
""
;
26
27
TU.ExtraArgs = {
"-include-pch"
,
"test.h.pch"
};
28
EXPECT_THAT(
buildCompilerInvocation
(TU.inputs(
FS
),
Diags
)
29
->getPreprocessorOpts()
30
.ImplicitPCHInclude,
31
IsEmpty());
32
33
// Transparent include translation
34
TU.ExtraArgs = {
"-include"
,
"test.h"
};
35
EXPECT_THAT(
buildCompilerInvocation
(TU.inputs(
FS
),
Diags
)
36
->getPreprocessorOpts()
37
.ImplicitPCHInclude,
38
IsEmpty());
39
40
// CL mode parsing.
41
TU.AdditionalFiles[
"test.pch"
] =
""
;
42
TU.ExtraArgs = {
"--driver-mode=cl"
};
43
TU.ExtraArgs.push_back(
"/Yutest.h"
);
44
EXPECT_THAT(
buildCompilerInvocation
(TU.inputs(
FS
),
Diags
)
45
->getPreprocessorOpts()
46
.ImplicitPCHInclude,
47
IsEmpty());
48
EXPECT_THAT(
buildCompilerInvocation
(TU.inputs(
FS
),
Diags
)
49
->getPreprocessorOpts()
50
.PCHThroughHeader,
51
IsEmpty());
52
}
53
54
}
// namespace
55
}
// namespace clangd
56
}
// namespace clang
clang::clangd::TEST
TEST(BackgroundQueueTest, Priority)
Definition:
BackgroundIndexTests.cpp:704
TestTU.h
FS
MockFS FS
Definition:
ClangdLSPServerTests.cpp:66
clang::clangd::buildCompilerInvocation
std::unique_ptr< CompilerInvocation > buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D, std::vector< std::string > *CC1Args)
Builds compiler invocation that could be used to build AST or preamble.
Definition:
Compiler.cpp:45
Compiler.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
Diags
CapturedDiags Diags
Definition:
ConfigCompileTests.cpp:26
Generated on Tue Jul 28 2020 16:14:01 for clang-tools by
1.8.16