clang 19.0.0git
Macros | Functions
HeaderSearch.cpp File Reference
#include "clang/Lex/HeaderSearch.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/DirectoryLookup.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Lex/HeaderMap.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Capacity.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <string>
#include <system_error>
#include <utility>

Go to the source code of this file.


#define DEBUG_TYPE   "file-search"


 ALWAYS_ENABLED_STATISTIC (NumIncluded, "Number of attempted #includes.")
 ALWAYS_ENABLED_STATISTIC (NumMultiIncludeFileOptzn, "Number of #includes skipped due to the multi-include optimization.")
 ALWAYS_ENABLED_STATISTIC (NumFrameworkLookups, "Number of framework lookups.")
 ALWAYS_ENABLED_STATISTIC (NumSubFrameworkLookups, "Number of subframework lookups.")
static OptionalDirectoryEntryRef getTopFrameworkDir (FileManager &FileMgr, StringRef DirName, SmallVectorImpl< std::string > &SubmodulePath)
 Given a framework directory, find the top-most framework directory.
static bool needModuleLookup (Module *RequestingModule, bool HasSuggestedModule)
static bool checkMSVCHeaderSearch (DiagnosticsEngine &Diags, OptionalFileEntryRef MSFE, const FileEntry *FE, SourceLocation IncludeLoc)
 Return true with a diagnostic if the file that MSVC would have found fails to match the one that Clang would have found with MSVC header search disabled.
static const char * copyString (StringRef Str, llvm::BumpPtrAllocator &Alloc)
static bool isFrameworkStylePath (StringRef Path, bool &IsPrivateHeader, SmallVectorImpl< char > &FrameworkName, SmallVectorImpl< char > &IncludeSpelling)
static void diagnoseFrameworkInclude (DiagnosticsEngine &Diags, SourceLocation IncludeLoc, StringRef Includer, StringRef IncludeFilename, FileEntryRef IncludeFE, bool isAngled=false, bool FoundByHeaderMap=false)
static void mergeHeaderFileInfoModuleBits (HeaderFileInfo &HFI, bool isModuleHeader, bool isTextualModuleHeader)
static void mergeHeaderFileInfo (HeaderFileInfo &HFI, const HeaderFileInfo &OtherHFI)
 Merge the header file info provided by OtherHFI into the current header file info (HFI)
static bool suggestModule (HeaderSearch &HS, FileEntryRef File, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule)
static OptionalFileEntryRef getPrivateModuleMap (FileEntryRef File, FileManager &FileMgr, DiagnosticsEngine &Diags)

Macro Definition Documentation


#define DEBUG_TYPE   "file-search"

Definition at line 51 of file HeaderSearch.cpp.

Function Documentation


"Number of framework lookups."   


"Number of attempted #includes."   


ALWAYS_ENABLED_STATISTIC ( NumMultiIncludeFileOptzn  ,
"Number of #includes skipped due to the multi-include optimization."   


ALWAYS_ENABLED_STATISTIC ( NumSubFrameworkLookups  ,
"Number of subframework lookups."   

◆ checkMSVCHeaderSearch()

static bool checkMSVCHeaderSearch ( DiagnosticsEngine Diags,
OptionalFileEntryRef  MSFE,
const FileEntry FE,
SourceLocation  IncludeLoc 

Return true with a diagnostic if the file that MSVC would have found fails to match the one that Clang would have found with MSVC header search disabled.

Definition at line 778 of file HeaderSearch.cpp.

References clang::FileEntryRef::getName(), and clang::DiagnosticsEngine::Report().

Referenced by clang::HeaderSearch::LookupFile().

◆ copyString()

static const char * copyString ( StringRef  Str,
llvm::BumpPtrAllocator &  Alloc 

Definition at line 789 of file HeaderSearch.cpp.

Referenced by clang::HeaderSearch::LookupFile().

◆ diagnoseFrameworkInclude()

static void diagnoseFrameworkInclude ( DiagnosticsEngine Diags,
SourceLocation  IncludeLoc,
StringRef  Includer,
StringRef  IncludeFilename,
FileEntryRef  IncludeFE,
bool  isAngled = false,
bool  FoundByHeaderMap = false 

◆ getPrivateModuleMap()

static OptionalFileEntryRef getPrivateModuleMap ( FileEntryRef  File,
FileManager FileMgr,
DiagnosticsEngine Diags 

◆ getTopFrameworkDir()

static OptionalDirectoryEntryRef getTopFrameworkDir ( FileManager FileMgr,
StringRef  DirName,
SmallVectorImpl< std::string > &  SubmodulePath 

Given a framework directory, find the top-most framework directory.

FileMgrThe file manager to use for directory lookups.
DirNameThe name of the framework directory.
SubmodulePathWill be populated with the submodule path from the returned top-level module to the originally named framework.

Definition at line 560 of file HeaderSearch.cpp.

References clang::FileManager::getCanonicalName(), and clang::FileManager::getOptionalDirectoryRef().

◆ isFrameworkStylePath()

static bool isFrameworkStylePath ( StringRef  Path,
bool IsPrivateHeader,
SmallVectorImpl< char > &  FrameworkName,
SmallVectorImpl< char > &  IncludeSpelling 

◆ mergeHeaderFileInfo()

static void mergeHeaderFileInfo ( HeaderFileInfo HFI,
const HeaderFileInfo OtherHFI 

◆ mergeHeaderFileInfoModuleBits()

static void mergeHeaderFileInfoModuleBits ( HeaderFileInfo HFI,
bool  isModuleHeader,
bool  isTextualModuleHeader 

◆ needModuleLookup()

static bool needModuleLookup ( Module RequestingModule,
bool  HasSuggestedModule 

Definition at line 605 of file HeaderSearch.cpp.

References clang::Module::NoUndeclaredIncludes.

◆ suggestModule()

static bool suggestModule ( HeaderSearch HS,
FileEntryRef  File,
Module RequestingModule,
ModuleMap::KnownHeader SuggestedModule