clang 22.0.0git
ModuleMap.cpp File Reference
#include "clang/Lex/ModuleMap.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/ModuleMapFile.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cstring>
#include <optional>
#include <string>
#include <system_error>
#include <utility>
#include "clang/Basic/TokenKinds.def"

Go to the source code of this file.

Classes

class  clang::ModuleMapLoader

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.

Macros

#define KEYWORD(Keyword, Conditions)
#define ALIAS(Keyword, AliasOf, Conditions)

Functions

static void appendSubframeworkPaths (Module *Mod, SmallVectorImpl< char > &Path)
 Append to Paths the set of paths needed to get to the subframework in which the given module lives.
static bool isBuiltinHeaderName (StringRef FileName)
 Determine whether the given file name is the name of a builtin header, supplied by Clang to replace, override, or augment existing system headers.
static bool isBuiltInModuleName (StringRef ModuleName)
 Determine whether the given module name is the name of a builtin module that is cyclic with a system module on some platforms.
static StringRef sanitizeFilenameAsIdentifier (StringRef Name, SmallVectorImpl< char > &Buffer)
 "Sanitize" a filename so that it can be used as an identifier.
static bool violatesPrivateInclude (Module *RequestingModule, const FileEntry *IncFileEnt, ModuleMap::KnownHeader Header)
static ModulegetTopLevelOrNull (Module *M)
static bool isBetterKnownHeader (const ModuleMap::KnownHeader &New, const ModuleMap::KnownHeader &Old)
static void inferFrameworkLink (Module *Mod)
 For a framework module, infer the framework against which we should link.
static bool shouldAddRequirement (Module *M, StringRef Feature, bool &IsRequiresExcludedHack)
 Whether to add the requirement Feature to the module M.
static bool compareModuleHeaders (const Module::Header &A, const Module::Header &B)

Macro Definition Documentation

◆ ALIAS

#define ALIAS ( Keyword,
AliasOf,
Conditions )
Value:
.Case(Keyword, true)
@ Keyword
The name has been typo-corrected to a keyword.
Definition Sema.h:560

◆ KEYWORD

#define KEYWORD ( Keyword,
Conditions )
Value:
.Case(#Keyword, true)

Function Documentation

◆ appendSubframeworkPaths()

void appendSubframeworkPaths ( Module * Mod,
SmallVectorImpl< char > & Path )
static

Append to Paths the set of paths needed to get to the subframework in which the given module lives.

Definition at line 156 of file ModuleMap.cpp.

References clang::Module::IsFramework, clang::Module::Name, and clang::Module::Parent.

◆ compareModuleHeaders()

bool compareModuleHeaders ( const Module::Header & A,
const Module::Header & B )
static

Definition at line 1968 of file ModuleMap.cpp.

References clang::Module::Header::NameAsWritten.

◆ getTopLevelOrNull()

Module * getTopLevelOrNull ( Module * M)
static

◆ inferFrameworkLink()

void inferFrameworkLink ( Module * Mod)
static

For a framework module, infer the framework against which we should link.

Definition at line 993 of file ModuleMap.cpp.

References clang::Module::IsFramework, clang::Module::isSubFramework(), clang::Module::LinkLibraries, and clang::Module::Name.

◆ isBetterKnownHeader()

◆ isBuiltinHeaderName()

bool isBuiltinHeaderName ( StringRef FileName)
static

Determine whether the given file name is the name of a builtin header, supplied by Clang to replace, override, or augment existing system headers.

Definition at line 252 of file ModuleMap.cpp.

References clang::FileName.

Referenced by clang::ModuleMap::isBuiltinHeader(), and clang::ModuleMap::shouldImportRelativeToBuiltinIncludeDir().

◆ isBuiltInModuleName()

bool isBuiltInModuleName ( StringRef ModuleName)
static

Determine whether the given module name is the name of a builtin module that is cyclic with a system module on some platforms.

Definition at line 271 of file ModuleMap.cpp.

◆ sanitizeFilenameAsIdentifier()

StringRef sanitizeFilenameAsIdentifier ( StringRef Name,
SmallVectorImpl< char > & Buffer )
static

"Sanitize" a filename so that it can be used as an identifier.

Definition at line 367 of file ModuleMap.cpp.

References ALIAS, clang::Default, clang::isAsciiIdentifierContinue(), clang::isDigit(), clang::isValidAsciiIdentifier(), KEYWORD, and clang::Keyword.

Referenced by clang::ModuleMap::isHeaderUnavailableInModule().

◆ shouldAddRequirement()

bool shouldAddRequirement ( Module * M,
StringRef Feature,
bool & IsRequiresExcludedHack )
static

Whether to add the requirement Feature to the module M.

This preserves backwards compatibility for two hacks in the Darwin system module map files:

  1. The use of 'requires excluded' to make headers non-modular, which should really be mapped to 'textual' now that we have this feature. We drop the 'excluded' requirement, and set IsRequiresExcludedHack to true. Later, this bit will be used to map all the headers inside this module to 'textual'.

    This affects Darwin.C.excluded (for assert.h) and Tcl.Private.

  2. Removes a bogus cplusplus requirement from IOKit.avc. This requirement was never correct and causes issues now that we check it, so drop it.

Definition at line 1882 of file ModuleMap.cpp.

References Feature, and clang::Module::fullModuleNameIs().

◆ violatesPrivateInclude()