13#include "clang/Frontend/DependencyOutputOptions.h"
14#include "clang/Frontend/FrontendOptions.h"
15#include "clang/Lex/PreprocessorOptions.h"
16#include "gmock/gmock.h"
17#include "gtest/gtest.h"
23using testing::IsEmpty;
25TEST(BuildCompilerInvocation, DropsPCH) {
31 TU.ExtraArgs = {
"-include-pch",
"test.h.pch"};
33 ->getPreprocessorOpts()
38 TU.ExtraArgs = {
"-include",
"test.h"};
40 ->getPreprocessorOpts()
45 TU.AdditionalFiles[
"test.pch"] =
"";
46 TU.ExtraArgs = {
"--driver-mode=cl"};
47 TU.ExtraArgs.push_back(
"/Yutest.h");
49 ->getPreprocessorOpts()
53 ->getPreprocessorOpts()
58TEST(BuildCompilerInvocation, PragmaDebugCrash) {
63TEST(BuildCompilerInvocation, DropsShowIncludes) {
68 TU.
ExtraArgs = {
"-Xclang",
"--show-includes"};
70 ->getDependencyOutputOpts()
72 ShowIncludesDestination::None);
74 TU.ExtraArgs = {
"/showIncludes",
"--driver-mode=cl"};
76 ->getDependencyOutputOpts()
78 ShowIncludesDestination::None);
80 TU.ExtraArgs = {
"/showIncludes:user",
"--driver-mode=cl"};
82 ->getDependencyOutputOpts()
84 ShowIncludesDestination::None);
87TEST(BuildCompilerInvocation, DropsPlugins) {
93 "-Xclang",
"plugins.so",
95 "-Xclang",
"my_plugin",
96 "-Xclang",
"-plugin-arg-my_plugin",
98 "-Xclang",
"-add-plugin",
99 "-Xclang",
"my_plugin2"};
101 EXPECT_THAT(Opts.Plugins, IsEmpty());
102 EXPECT_THAT(Opts.PluginArgs, IsEmpty());
103 EXPECT_THAT(Opts.AddPluginActions, IsEmpty());
104 EXPECT_EQ(Opts.ProgramAction, frontend::ActionKind::ParseSyntaxOnly);
105 EXPECT_TRUE(Opts.ActionName.empty());
108TEST(BuildCompilerInvocation, EmptyArgs) {
112 auto Inputs = TU.
inputs(FS);
118TEST(BuildCompilerInvocation, SuppressDiags) {
123 auto Inputs = TU.inputs(FS);
129 EXPECT_THAT(Diags.take(), IsEmpty());
StoreDiags collects the diagnostics that can later be reported by clangd.
WithContextValue extends Context::current() with a single value.
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
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.
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Settings that express user/project preferences and control clangd behavior.
static clangd::Key< Config > Key
Context key which can be used to set the current Config.
struct clang::clangd::Config::@224206046260313204212274150166346126315121140114 Diagnostics
Controls warnings and errors when parsing code.
std::vector< std::string > ExtraArgs
ParseInputs inputs(MockFS &FS) const
static TestTU withCode(llvm::StringRef Code)
llvm::StringMap< std::string > AdditionalFiles