clang-tools 17.0.0git
Public Member Functions | List of all members
clang::clangd::CanonicalIncludes Class Reference

Maps a definition location onto an #include file, based on a set of filename rules. More...

#include <CanonicalIncludes.h>

Public Member Functions

void addMapping (FileEntryRef Header, llvm::StringRef CanonicalPath)
 Adds a file-to-string mapping from ID to CanonicalPath.
 
llvm::StringRef mapSymbol (llvm::StringRef Scope, llvm::StringRef Name, const LangOptions &L) const
 Returns the overridden include for a qualified symbol with, or "".
 
llvm::StringRef mapHeader (FileEntryRef Header) const
 Returns the overridden include for files in Header, or "".
 
void addSystemHeadersMapping (const LangOptions &Language)
 Adds mapping for system headers and some special symbols (e.g.
 

Detailed Description

Maps a definition location onto an #include file, based on a set of filename rules.

Only const methods (i.e. mapHeader) in this class are thread safe.

Definition at line 37 of file CanonicalIncludes.h.

Member Function Documentation

◆ addMapping()

void clang::clangd::CanonicalIncludes::addMapping ( FileEntryRef  Header,
llvm::StringRef  CanonicalPath 
)

Adds a file-to-string mapping from ID to CanonicalPath.

Definition at line 672 of file CanonicalIncludes.cpp.

◆ addSystemHeadersMapping()

void clang::clangd::CanonicalIncludes::addSystemHeadersMapping ( const LangOptions &  Language)

Adds mapping for system headers and some special symbols (e.g.

STL symbols in <iosfwd> need to be mapped individually). Approximately, the following system headers are handled:

  • C++ standard library e.g. bits/basic_string.h$ -> <string>
  • Posix library e.g. bits/pthreadtypes.h$ -> <pthread.h>
  • Compiler extensions, e.g. include/avx512bwintrin.h$ -> <immintrin.h> The mapping is hardcoded and hand-maintained, so it might not cover all headers.

Definition at line 752 of file CanonicalIncludes.cpp.

◆ mapHeader()

llvm::StringRef clang::clangd::CanonicalIncludes::mapHeader ( FileEntryRef  Header) const

Returns the overridden include for files in Header, or "".

Definition at line 681 of file CanonicalIncludes.cpp.

References Filename, and clang::clangd::MaxSuffixComponents.

◆ mapSymbol()

llvm::StringRef clang::clangd::CanonicalIncludes::mapSymbol ( llvm::StringRef  Scope,
llvm::StringRef  Name,
const LangOptions &  L 
) const

Returns the overridden include for a qualified symbol with, or "".

Scope and Name concatenation forms the fully qualified name. Scope is the qualifier with the trailing "::" (e.g. "std::") or empty (for global namespace).

Definition at line 704 of file CanonicalIncludes.cpp.

References Name.

Referenced by clang::clangd::SymbolCollector::finish().


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