clang-tools 19.0.0git
Public Types | Public Member Functions | List of all members
clang::clangd::OverlayCDB Class Reference

Wraps another compilation database, and supports overriding the commands using an in-memory mapping. More...

#include <GlobalCompilationDatabase.h>

Inheritance diagram for clang::clangd::OverlayCDB:
Inheritance graph
[legend]

Public Types

using CommandMangler = llvm::unique_function< void(tooling::CompileCommand &, StringRef File) const >
 
- Public Types inherited from clang::clangd::GlobalCompilationDatabase
using CommandChanged = Event< std::vector< std::string > >
 

Public Member Functions

 OverlayCDB (const GlobalCompilationDatabase *Base, std::vector< std::string > FallbackFlags={}, CommandMangler Mangler=nullptr)
 
std::optional< tooling::CompileCommand > getCompileCommand (PathRef File) const override
 If there are any known-good commands for building this file, returns one.
 
tooling::CompileCommand getFallbackCommand (PathRef File) const override
 Makes a guess at how to build a file.
 
void setCompileCommand (PathRef File, std::optional< tooling::CompileCommand > CompilationCommand)
 Sets or clears the compilation command for a particular file.
 
- Public Member Functions inherited from clang::clangd::DelegatingCDB
 DelegatingCDB (const GlobalCompilationDatabase *Base)
 
 DelegatingCDB (std::unique_ptr< GlobalCompilationDatabase > Base)
 
std::optional< tooling::CompileCommand > getCompileCommand (PathRef File) const override
 If there are any known-good commands for building this file, returns one.
 
std::optional< ProjectInfogetProjectInfo (PathRef File) const override
 Finds the closest project to File.
 
tooling::CompileCommand getFallbackCommand (PathRef File) const override
 Makes a guess at how to build a file.
 
bool blockUntilIdle (Deadline D) const override
 If the CDB does any asynchronous work, wait for it to complete.
 
- Public Member Functions inherited from clang::clangd::GlobalCompilationDatabase
virtual ~GlobalCompilationDatabase ()=default
 
virtual std::optional< tooling::CompileCommand > getCompileCommand (PathRef File) const =0
 If there are any known-good commands for building this file, returns one.
 
virtual std::optional< ProjectInfogetProjectInfo (PathRef File) const
 Finds the closest project to File.
 
virtual tooling::CompileCommand getFallbackCommand (PathRef File) const
 Makes a guess at how to build a file.
 
virtual bool blockUntilIdle (Deadline D) const
 If the CDB does any asynchronous work, wait for it to complete.
 
CommandChanged::Subscription watch (CommandChanged::Listener L) const
 The callback is notified when files may have new compile commands.
 

Additional Inherited Members

- Protected Attributes inherited from clang::clangd::GlobalCompilationDatabase
CommandChanged OnCommandChanged
 

Detailed Description

Wraps another compilation database, and supports overriding the commands using an in-memory mapping.

Definition at line 174 of file GlobalCompilationDatabase.h.

Member Typedef Documentation

◆ CommandMangler

using clang::clangd::OverlayCDB::CommandMangler = llvm::unique_function<void(tooling::CompileCommand &, StringRef File) const>

Definition at line 178 of file GlobalCompilationDatabase.h.

Constructor & Destructor Documentation

◆ OverlayCDB()

clang::clangd::OverlayCDB::OverlayCDB ( const GlobalCompilationDatabase Base,
std::vector< std::string >  FallbackFlags = {},
CommandMangler  Mangler = nullptr 
)

Definition at line 743 of file GlobalCompilationDatabase.cpp.

Member Function Documentation

◆ getCompileCommand()

std::optional< tooling::CompileCommand > clang::clangd::OverlayCDB::getCompileCommand ( PathRef  File) const
overridevirtual

If there are any known-good commands for building this file, returns one.

Reimplemented from clang::clangd::DelegatingCDB.

Definition at line 750 of file GlobalCompilationDatabase.cpp.

References clang::clangd::File, clang::clangd::DelegatingCDB::getCompileCommand(), and clang::clangd::removeDots().

◆ getFallbackCommand()

tooling::CompileCommand clang::clangd::OverlayCDB::getFallbackCommand ( PathRef  File) const
overridevirtual

Makes a guess at how to build a file.

The default implementation just runs clang on the file. Clangd should treat the results as unreliable.

Reimplemented from clang::clangd::DelegatingCDB.

Definition at line 783 of file GlobalCompilationDatabase.cpp.

References clang::clangd::File, and clang::clangd::DelegatingCDB::getFallbackCommand().

◆ setCompileCommand()

void clang::clangd::OverlayCDB::setCompileCommand ( PathRef  File,
std::optional< tooling::CompileCommand >  CompilationCommand 
)

Sets or clears the compilation command for a particular file.

Definition at line 793 of file GlobalCompilationDatabase.cpp.

References clang::clangd::Event< T >::broadcast(), clang::clangd::File, clang::clangd::GlobalCompilationDatabase::OnCommandChanged, and clang::clangd::removeDots().


The documentation for this class was generated from the following files: