11#include "llvm/ADT/StringRef.h"
12#include "gmock/gmock.h"
13#include "gtest/gtest.h"
22TEST(Modules, TextualIncludeInPreamble) {
28 TU.ExtraArgs.push_back("-fmodule-name=M");
29 TU.ExtraArgs.push_back(
"-fmodule-map-file=" +
testPath(
"m.modulemap"));
30 TU.AdditionalFiles[
"Textual.h"] =
"void foo();";
31 TU.AdditionalFiles[
"m.modulemap"] = R
"modulemap(
34 textual header "Textual.h"
44TEST(Modules, PreambleBuildVisibility) {
50 TU.OverlayRealFileSystemForModules = true;
51 TU.ExtraArgs.push_back(
"-fmodules");
52 TU.ExtraArgs.push_back(
"-fmodules-strict-decluse");
53 TU.ExtraArgs.push_back(
"-Xclang");
54 TU.ExtraArgs.push_back(
"-fmodules-local-submodule-visibility");
55 TU.ExtraArgs.push_back(
"-fmodule-map-file=" +
testPath(
"m.modulemap"));
56 TU.AdditionalFiles[
"module.h"] = R
"cpp(
59 TU.AdditionalFiles["m.modulemap"] = R
"modulemap(
64 EXPECT_TRUE(TU.build().getDiagnostics().empty());
67TEST(Modules, Diagnostic) {
76 TU.OverlayRealFileSystemForModules = true;
77 TU.ExtraArgs.push_back(
"-fmodule-map-file=" +
testPath(
"m.modulemap"));
78 TU.ExtraArgs.push_back(
"-fmodules");
79 TU.ExtraArgs.push_back(
"-fimplicit-modules");
80 TU.ExtraArgs.push_back(
"-fmodules-strict-decluse");
81 TU.AdditionalFiles[
"modular.h"] = R
"cpp(
82 #include "non-modular.h"
84 TU.AdditionalFiles["non-modular.h"] =
"";
85 TU.AdditionalFiles[
"m.modulemap"] = R
"modulemap(
96TEST(Modules, UnknownFormat) {
98 TU.OverlayRealFileSystemForModules = true;
99 TU.ExtraArgs.push_back(
"-Xclang");
100 TU.ExtraArgs.push_back(
"-fmodule-format=obj");
101 TU.ExtraArgs.push_back(
"-fmodule-map-file=" +
testPath(
"m.modulemap"));
102 TU.ExtraArgs.push_back(
"-fmodules");
103 TU.ExtraArgs.push_back(
"-fimplicit-modules");
104 TU.AdditionalFiles[
"modular.h"] =
"";
105 TU.AdditionalFiles[
"m.modulemap"] = R
"modulemap(
115TEST(Modules, ModulePreamble) {
118 #define PREAMBLE_MACRO 1
120 #define MODULE_MACRO 2
122 #define PRIVATE_MACRO 3
124 TU.ExtraArgs.push_back("-std=c++20");
125 TU.ExtraArgs.push_back(
"--precompile");
127 auto AST = TU.build();
128 auto &SM =
AST.getSourceManager();
129 auto GetMacroFile = [&](llvm::StringRef
Name) -> FileID {
130 if (
auto *MI =
AST.getPreprocessor().getMacroInfo(
131 &
AST.getASTContext().Idents.get(
Name)))
132 return SM.getFileID(MI->getDefinitionLoc());
136 EXPECT_EQ(GetMacroFile(
"PREAMBLE_MACRO"), SM.getPreambleFileID());
137 EXPECT_EQ(GetMacroFile(
"MODULE_MACRO"), SM.getMainFileID());
138 EXPECT_EQ(GetMacroFile(
"PRIVATE_MACRO"), SM.getMainFileID());
llvm::SmallString< 256U > Name
std::string testPath(PathRef File, llvm::sys::path::Style Style)
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static TestTU withCode(llvm::StringRef Code)