clang 8.0.0

Classes | Namespaces | Macros | Enumerations | Functions
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/Lexer.h"`
`#include "clang/Lex/LiteralSupport.h"`
`#include "clang/Lex/Token.h"`
`#include "llvm/ADT/DenseMap.h"`
`#include "llvm/ADT/None.h"`
`#include "llvm/ADT/STLExtras.h"`
`#include "llvm/ADT/SmallPtrSet.h"`
`#include "llvm/ADT/SmallString.h"`
`#include "llvm/ADT/SmallVector.h"`
`#include "llvm/ADT/StringMap.h"`
`#include "llvm/ADT/StringRef.h"`
`#include "llvm/ADT/StringSwitch.h"`
`#include "llvm/Support/Allocator.h"`
`#include "llvm/Support/Compiler.h"`
`#include "llvm/Support/ErrorHandling.h"`
`#include "llvm/Support/MemoryBuffer.h"`
`#include "llvm/Support/Path.h"`
`#include "llvm/Support/VirtualFileSystem.h"`
`#include "llvm/Support/raw_ostream.h"`
`#include <algorithm>`
`#include <cassert>`
`#include <cstdint>`
`#include <cstring>`
`#include <string>`
`#include <system_error>`
`#include <utility>`
`#include "clang/Basic/TokenKinds.def"`
Include dependency graph for ModuleMap.cpp:

Go to the source code of this file.

## Classes
struct | clang::MMToken
| A token in a module map file. More...
class | clang::ModuleMapParser

## Namespaces
| clang
| Dataflow Directional Tag Classes.

## Macros
#define | KEYWORD(Keyword, Conditions) .Case(#Keyword, true)
#define | ALIAS(Keyword, AliasOf, Conditions) .Case(Keyword, true)

## Enumerations
enum | AttributeKind
| Enumerates the known attributes. More...

## 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. More...
static StringRef | sanitizeFilenameAsIdentifier (StringRef Name, SmallVectorImpl< char > &Buffer)
| "Sanitize" a filename so that it can be used as an identifier. More...
static bool | violatesPrivateInclude (Module *RequestingModule, const FileEntry *IncFileEnt, ModuleMap::KnownHeader Header)
static Module * | getTopLevelOrNull (Module *M)
static bool | isBetterKnownHeader (const ModuleMap::KnownHeader &New, const ModuleMap::KnownHeader &Old)
static void | inferFrameworkLink (Module *Mod, const DirectoryEntry *FrameworkDir, FileManager &FileMgr)
| For a framework module, infer the framework against which we should link. More...
static bool | shouldAddRequirement (Module *M, StringRef Feature, bool &IsRequiresExcludedHack)
| Whether to add the requirement `Feature` to the module `M`. More...
static int | compareModuleHeaders (const Module::Header *A, const Module::Header *B)
static std::string | formatModuleId (const ModuleId &Id)
| Format a module-id into a string. More...

## Macro Definition Documentation

## ◆ ALIAS

#define ALIAS | ( |  | Keyword,
|  |  | AliasOf,
|  |  | Conditions
| ) |  | .Case(Keyword, true)

## ◆ KEYWORD

#define KEYWORD | ( |  | Keyword,
|  |  | Conditions
| ) |  | .Case(#Keyword, true)

## Enumeration Type Documentation

## ◆ AttributeKind

enum AttributeKind

Enumerates the known attributes.

Definition at line 1685 of file ModuleMap.cpp.

## Function Documentation

## ◆ appendSubframeworkPaths()

static 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 158 of file ModuleMap.cpp.

## ◆ compareModuleHeaders()

static int compareModuleHeaders | ( | const Module::Header * | A,
|  | const Module::Header * | B
| ) |  |
| static

Definition at line 2347 of file ModuleMap.cpp.

References clang::MMToken::Comma, clang::MMToken::ConfigMacros, clang::MMToken::ExportAsKeyword, clang::MMToken::ExportKeyword, clang::MMToken::FrameworkKeyword, clang::DirectoryEntry::getName(), clang::MMToken::Identifier, clang::format::FormatToken::is(), clang::MMToken::LinkKeyword, clang::Module::Header::NameAsWritten, clang::MMToken::Period, clang::MMToken::Star, clang::MMToken::StringLiteral, clang::ModuleMap::TextualHeader, clang::format::Tok, and clang::MMToken::UseKeyword.

## ◆ formatModuleId()

static std::string formatModuleId | ( | const ModuleId & | Id | ) |
| static

Format a module-id into a string.

Definition at line 2619 of file ModuleMap.cpp.

References clang::MMToken::Comma, clang::MMToken::Conflict, clang::MMToken::EndOfFile, clang::MMToken::ExcludeKeyword, clang::MMToken::ExplicitKeyword, clang::MMToken::ExportKeyword, clang::MMToken::HeaderKeyword, clang::Module::UnresolvedConflict::Id, clang::MMToken::Identifier, clang::format::FormatToken::is(), clang::MMToken::LBrace, clang::MMToken::LSquare, clang::Module::UnresolvedConflict::Message, clang::MMToken::ModuleKeyword, clang::MMToken::PrivateKeyword, clang::MMToken::RBrace, clang::MMToken::RSquare, clang::MMToken::Star, clang::MMToken::StringLiteral, clang::format::Tok, and clang::MMToken::UmbrellaKeyword.

## ◆ getTopLevelOrNull()

static Module* getTopLevelOrNull | ( | Module * | M | ) |
| static

Definition at line 462 of file ModuleMap.cpp.

References clang::Module::getTopLevelModule().

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

## ◆ inferFrameworkLink()

static void inferFrameworkLink | ( | Module * | Mod,
|  | const DirectoryEntry * | FrameworkDir,
|  | FileManager & | FileMgr
| ) |  |
| static

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

Definition at line 871 of file ModuleMap.cpp.

References clang::FileManager::getFile(), clang::DirectoryEntry::getName(), clang::Module::IsFramework, clang::Module::isSubFramework(), clang::Module::LinkLibraries, and clang::Module::Name.

## ◆ isBetterKnownHeader()

static bool isBetterKnownHeader | ( | const ModuleMap::KnownHeader & | New,
|  | const ModuleMap::KnownHeader & | Old
| ) |  |
| static

Definition at line 542 of file ModuleMap.cpp.

References clang::ModuleMap::KnownHeader::getModule(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::isAvailable(), clang::ModuleMap::PrivateHeader, and clang::ModuleMap::TextualHeader.

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

## ◆ sanitizeFilenameAsIdentifier()

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

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

Definition at line 336 of file ModuleMap.cpp.

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

## ◆ shouldAddRequirement()

static 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 2148 of file ModuleMap.cpp.

References clang::MMToken::Comma, clang::FixItHint::CreateReplacement(), clang::Default, clang::MMToken::EndOfFile, clang::MMToken::Exclaim, clang::MMToken::ExcludeKeyword, clang::Module::UnresolvedHeaderDirective::FileName, clang::Module::UnresolvedHeaderDirective::FileNameLoc, clang::Module::fullModuleNameIs(), clang::MMToken::HeaderKeyword, clang::Module::HK_Excluded, clang::MMToken::Identifier, clang::MMToken::IntegerLiteral, clang::format::FormatToken::is(), clang::Module::UnresolvedHeaderDirective::IsUmbrella, clang::Module::UnresolvedHeaderDirective::Kind, clang::MMToken::LBrace, clang::Module::UnresolvedHeaderDirective::ModTime, clang::ModuleMap::NormalHeader, clang::ModuleMap::PrivateHeader, clang::MMToken::PrivateKeyword, clang::MMToken::RBrace, clang::MMToken::RequiresKeyword, clang::Module::UnresolvedHeaderDirective::Size, clang::MMToken::StringLiteral, clang::ModuleMap::TextualHeader, clang::MMToken::TextualKeyword, clang::format::Tok, and clang::MMToken::UmbrellaKeyword.

## ◆ violatesPrivateInclude()

static bool violatesPrivateInclude | ( | Module * | RequestingModule,
|  | const FileEntry * | IncFileEnt,
|  | ModuleMap::KnownHeader | Header
| ) |  |
| static

Definition at line 439 of file ModuleMap.cpp.

References clang::ModuleMap::KnownHeader::getModule(), clang::ModuleMap::KnownHeader::getRole(), clang::Module::Headers, clang::Module::HK_Private, clang::Module::HK_PrivateTextual, clang::ModuleMap::KnownHeader::isAccessibleFrom(), and clang::ModuleMap::PrivateHeader.

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