Skip to content

Commit

Permalink
[TEST] add implicit include directories
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Dec 1, 2023
1 parent 1a1b510 commit 147428b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
24 changes: 20 additions & 4 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3122,9 +3122,11 @@ struct ASTAction
: public clang::ASTFrontendAction
{
ASTAction(
std::string_view argv0,
ExecutionContext& ex,
ConfigImpl const& config) noexcept
: ex_(ex)
: argv0_(argv0)
, ex_(ex)
, config_(config)
{
}
Expand All @@ -3150,11 +3152,20 @@ struct ASTAction
clang::CompilerInstance& Compiler,
llvm::StringRef InFile) override
{
if(Compiler.getHeaderSearchOpts().UseBuiltinIncludes &&
Compiler.getHeaderSearchOpts().ResourceDir.empty())
{
Compiler.getHeaderSearchOpts().ResourceDir =
CompilerInvocation::GetResourcesPath(
argv0_.data(), nullptr);
}

return std::make_unique<ASTVisitorConsumer>(
config_, ex_, Compiler);
}

private:
std::string_view argv0_;
ExecutionContext& ex_;
ConfigImpl const& config_;
};
Expand All @@ -3165,20 +3176,24 @@ struct ASTActionFactory :
tooling::FrontendActionFactory
{
ASTActionFactory(
std::string_view argv0,
ExecutionContext& ex,
ConfigImpl const& config) noexcept
: ex_(ex)
: argv0_(argv0)
, ex_(ex)
, config_(config)
{
}

std::unique_ptr<FrontendAction>
create() override
{
return std::make_unique<ASTAction>(ex_, config_);
return std::make_unique<ASTAction>(
argv0_, ex_, config_);
}

private:
std::string_view argv0_;
ExecutionContext& ex_;
ConfigImpl const& config_;
};
Expand All @@ -3189,10 +3204,11 @@ struct ASTActionFactory :

std::unique_ptr<tooling::FrontendActionFactory>
makeFrontendActionFactory(
std::string_view argv0,
ExecutionContext& ex,
ConfigImpl const& config)
{
return std::make_unique<ASTActionFactory>(ex, config);
return std::make_unique<ASTActionFactory>(argv0, ex, config);
}

} // mrdocs
Expand Down
1 change: 1 addition & 0 deletions src/lib/AST/ASTVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace mrdocs {
*/
std::unique_ptr<tooling::FrontendActionFactory>
makeFrontendActionFactory(
std::string_view argv0,
ExecutionContext& ex,
ConfigImpl const& config);

Expand Down
10 changes: 7 additions & 3 deletions src/lib/Lib/CorpusImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ build(
#else
InfoExecutionContext context(*config);
#endif
std::unique_ptr<tooling::FrontendActionFactory> action =
makeFrontendActionFactory(context, *config);
MRDOCS_ASSERT(action);

// Get a copy of the filename strings
std::vector<std::string> files =
Expand All @@ -127,6 +124,13 @@ build(
auto const processFile =
[&](std::string path)
{
auto args = compilations.getCompileCommands(path);

std::unique_ptr<tooling::FrontendActionFactory> action =
makeFrontendActionFactory(
args.front().CommandLine.front(), context, *config);
MRDOCS_ASSERT(action);

// Each thread gets an independent copy of a VFS to allow different
// concurrent working directories.
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
Expand Down

0 comments on commit 147428b

Please sign in to comment.