summaryrefslogtreecommitdiff
path: root/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/ModuleMap.cpp')
-rw-r--r--lib/Lex/ModuleMap.cpp178
1 files changed, 89 insertions, 89 deletions
diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp
index f048a73a8ccc2..87749f74734c9 100644
--- a/lib/Lex/ModuleMap.cpp
+++ b/lib/Lex/ModuleMap.cpp
@@ -103,8 +103,8 @@ ModuleMap::headerKindToRole(Module::HeaderKind Kind) {
llvm_unreachable("unknown header kind");
}
-Module::ExportDecl
-ModuleMap::resolveExport(Module *Mod,
+Module::ExportDecl
+ModuleMap::resolveExport(Module *Mod,
const Module::UnresolvedExportDecl &Unresolved,
bool Complain) const {
// We may have just a wildcard.
@@ -112,7 +112,7 @@ ModuleMap::resolveExport(Module *Mod,
assert(Unresolved.Wildcard && "Invalid unresolved export");
return Module::ExportDecl(nullptr, true);
}
-
+
// Resolve the module-id.
Module *Context = resolveModuleId(Unresolved.Id, Mod, Complain);
if (!Context)
@@ -151,7 +151,7 @@ Module *ModuleMap::resolveModuleId(const ModuleId &Id, Module *Mod,
return Context;
}
-/// Append to \p Paths the set of paths needed to get to the
+/// Append to \p Paths the set of paths needed to get to the
/// subframework in which the given module lives.
static void appendSubframeworkPaths(Module *Mod,
SmallVectorImpl<char> &Path) {
@@ -161,10 +161,10 @@ static void appendSubframeworkPaths(Module *Mod,
if (Mod->IsFramework)
Paths.push_back(Mod->Name);
}
-
+
if (Paths.empty())
return;
-
+
// Add Frameworks/Name.framework for each subframework.
for (unsigned I = Paths.size() - 1; I != 0; --I)
llvm::sys::path::append(Path, "Frameworks", Paths[I-1] + ".framework");
@@ -325,7 +325,7 @@ ModuleMap::~ModuleMap() {
}
void ModuleMap::setTarget(const TargetInfo &Target) {
- assert((!this->Target || this->Target == &Target) &&
+ assert((!this->Target || this->Target == &Target) &&
"Improper target override");
this->Target = &Target;
}
@@ -528,7 +528,7 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
<< RequestingModule->getTopLevelModule()->Name << Filename;
} else if (RequestingModule && RequestingModuleIsModuleInterface &&
LangOpts.isCompilingModule()) {
- // Do not diagnose when we are not compiling a module.
+ // Do not diagnose when we are not compiling a module.
diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
diag::warn_non_modular_include_in_framework_module :
diag::warn_non_modular_include_in_module;
@@ -732,7 +732,7 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
if (IsUnavailable(Found))
return true;
}
-
+
// Infer a submodule with the same name as this header file.
SmallString<32> NameBuf;
StringRef Name = sanitizeFilenameAsIdentifier(
@@ -745,18 +745,18 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
return IsUnavailable(Found);
}
-
+
SkippedDirs.push_back(Dir);
-
+
// Retrieve our parent path.
DirName = llvm::sys::path::parent_path(DirName);
if (DirName.empty())
break;
-
+
// Resolve the parent path to a directory entry.
Dir = SourceMgr.getFileManager().getDirectory(DirName);
} while (Dir);
-
+
return false;
}
@@ -774,14 +774,14 @@ Module *ModuleMap::lookupModuleUnqualified(StringRef Name,
if (Module *Sub = lookupModuleQualified(Name, Context))
return Sub;
}
-
+
return findModule(Name);
}
Module *ModuleMap::lookupModuleQualified(StringRef Name, Module *Context) const{
if (!Context)
return findModule(Name);
-
+
return Context->findSubmodule(Name);
}
@@ -892,7 +892,7 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
// Check whether we've already found this module.
if (Module *Mod = lookupModuleQualified(ModuleName, Parent))
return Mod;
-
+
FileManager &FileMgr = SourceMgr.getFileManager();
// If the framework has a parent path from which we're allowed to infer
@@ -953,7 +953,7 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName());
llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h");
const FileEntry *UmbrellaHeader = FileMgr.getFile(UmbrellaName);
-
+
// FIXME: If there's no umbrella header, we could probably scan the
// framework to load *everything*. But, it's not clear that this is a good
// idea.
@@ -983,14 +983,14 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
// The "Headers/" component of the name is implied because this is
// a framework module.
setUmbrellaHeader(Result, UmbrellaHeader, ModuleName + ".h");
-
+
// export *
Result->Exports.push_back(Module::ExportDecl(nullptr, true));
// module * { export * }
Result->InferSubmodules = true;
Result->InferExportWildcard = true;
-
+
// Look for subframeworks.
std::error_code EC;
SmallString<128> SubframeworksDirName
@@ -1200,11 +1200,11 @@ void ModuleMap::setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap) {
LLVM_DUMP_METHOD void ModuleMap::dump() {
llvm::errs() << "Modules:";
- for (llvm::StringMap<Module *>::iterator M = Modules.begin(),
- MEnd = Modules.end();
+ for (llvm::StringMap<Module *>::iterator M = Modules.begin(),
+ MEnd = Modules.end();
M != MEnd; ++M)
M->getValue()->print(llvm::errs(), 2);
-
+
llvm::errs() << "Headers:";
for (HeadersMap::iterator H = Headers.begin(), HEnd = Headers.end();
H != HEnd; ++H) {
@@ -1299,7 +1299,7 @@ namespace clang {
LSquare,
RSquare
} Kind;
-
+
unsigned Location;
unsigned StringLength;
union {
@@ -1309,16 +1309,16 @@ namespace clang {
// If Kind == IntegerLiteral.
uint64_t IntegerValue;
};
-
+
void clear() {
Kind = EndOfFile;
Location = 0;
StringLength = 0;
StringData = nullptr;
}
-
+
bool is(TokenKind K) const { return Kind == K; }
-
+
SourceLocation getLocation() const {
return SourceLocation::getFromRawEncoding(Location);
}
@@ -1326,7 +1326,7 @@ namespace clang {
uint64_t getInteger() const {
return Kind == IntegerLiteral ? IntegerValue : 0;
}
-
+
StringRef getString() const {
return Kind == IntegerLiteral ? StringRef()
: StringRef(StringData, StringLength);
@@ -1356,17 +1356,17 @@ namespace clang {
/// Whether this module map is in a system header directory.
bool IsSystem;
-
+
/// Whether an error occurred.
bool HadError = false;
-
+
/// Stores string data for the various string literals referenced
/// during parsing.
llvm::BumpPtrAllocator StringData;
-
+
/// The current token.
MMToken Tok;
-
+
/// The active module.
Module *ActiveModule = nullptr;
@@ -1413,7 +1413,7 @@ namespace clang {
using Attributes = ModuleMap::Attributes;
bool parseOptionalAttributes(Attributes &Attrs);
-
+
public:
explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
const TargetInfo *Target, DiagnosticsEngine &Diags,
@@ -1475,7 +1475,7 @@ retry:
case tok::eof:
Tok.Kind = MMToken::EndOfFile;
break;
-
+
case tok::l_brace:
Tok.Kind = MMToken::LBrace;
break;
@@ -1483,27 +1483,27 @@ retry:
case tok::l_square:
Tok.Kind = MMToken::LSquare;
break;
-
+
case tok::period:
Tok.Kind = MMToken::Period;
break;
-
+
case tok::r_brace:
Tok.Kind = MMToken::RBrace;
break;
-
+
case tok::r_square:
Tok.Kind = MMToken::RSquare;
break;
-
+
case tok::star:
Tok.Kind = MMToken::Star;
break;
-
+
case tok::exclaim:
Tok.Kind = MMToken::Exclaim;
break;
-
+
case tok::string_literal: {
if (LToken.hasUDSuffix()) {
Diags.Report(LToken.getLocation(), diag::err_invalid_string_udl);
@@ -1516,13 +1516,13 @@ retry:
StringLiteralParser StringLiteral(LToken, SourceMgr, LangOpts, *Target);
if (StringLiteral.hadError)
goto retry;
-
+
// Copy the string literal into our string data allocator.
unsigned Length = StringLiteral.GetStringLength();
char *Saved = StringData.Allocate<char>(Length + 1);
memcpy(Saved, StringLiteral.GetString().data(), Length);
Saved[Length] = 0;
-
+
// Form the token.
Tok.Kind = MMToken::StringLiteral;
Tok.StringData = Saved;
@@ -1548,7 +1548,7 @@ retry:
Tok.IntegerValue = Value;
break;
}
-
+
case tok::comment:
goto retry;
@@ -1576,7 +1576,7 @@ retry:
HadError = true;
goto retry;
}
-
+
return Result;
}
@@ -1591,14 +1591,14 @@ void ModuleMapParser::skipUntil(MMToken::TokenKind K) {
case MMToken::LBrace:
if (Tok.is(K) && braceDepth == 0 && squareDepth == 0)
return;
-
+
++braceDepth;
break;
case MMToken::LSquare:
if (Tok.is(K) && braceDepth == 0 && squareDepth == 0)
return;
-
+
++squareDepth;
break;
@@ -1621,7 +1621,7 @@ void ModuleMapParser::skipUntil(MMToken::TokenKind K) {
return;
break;
}
-
+
consumeToken();
} while (true);
}
@@ -1643,13 +1643,13 @@ bool ModuleMapParser::parseModuleId(ModuleId &Id) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_module_name);
return true;
}
-
+
if (!Tok.is(MMToken::Period))
break;
-
+
consumeToken();
} while (true);
-
+
return false;
}
@@ -1740,7 +1740,7 @@ void ModuleMapParser::diagnosePrivateModules(SourceLocation ExplicitLoc,
///
/// module-declaration:
/// 'extern' 'module' module-id string-literal
-/// 'explicit'[opt] 'framework'[opt] 'module' module-id attributes[opt]
+/// 'explicit'[opt] 'framework'[opt] 'module' module-id attributes[opt]
/// { module-member* }
///
/// module-member:
@@ -1778,8 +1778,8 @@ void ModuleMapParser::parseModuleDecl() {
if (Tok.is(MMToken::FrameworkKeyword)) {
FrameworkLoc = consumeToken();
Framework = true;
- }
-
+ }
+
// Parse 'module' keyword.
if (!Tok.is(MMToken::ModuleKeyword)) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_module);
@@ -1790,10 +1790,10 @@ void ModuleMapParser::parseModuleDecl() {
CurrModuleDeclLoc = consumeToken(); // 'module' keyword
// If we have a wildcard for the module name, this is an inferred submodule.
- // Parse it.
+ // Parse it.
if (Tok.is(MMToken::Star))
return parseInferredModuleDecl(Framework, Explicit);
-
+
// Parse the module name.
ModuleId Id;
if (parseModuleId(Id)) {
@@ -1805,7 +1805,7 @@ void ModuleMapParser::parseModuleDecl() {
if (Id.size() > 1) {
Diags.Report(Id.front().second, diag::err_mmap_nested_submodule_id)
<< SourceRange(Id.front().second, Id.back().second);
-
+
HadError = true;
return;
}
@@ -1816,8 +1816,8 @@ void ModuleMapParser::parseModuleDecl() {
ExplicitLoc = SourceLocation();
HadError = true;
}
-
- Module *PreviousActiveModule = ActiveModule;
+
+ Module *PreviousActiveModule = ActiveModule;
if (Id.size() > 1) {
// This module map defines a submodule. Go find the module of which it
// is a submodule.
@@ -1830,7 +1830,7 @@ void ModuleMapParser::parseModuleDecl() {
ActiveModule = Next;
continue;
}
-
+
if (ActiveModule) {
Diags.Report(Id[I].second, diag::err_mmap_missing_module_qualified)
<< Id[I].first
@@ -1849,10 +1849,10 @@ void ModuleMapParser::parseModuleDecl() {
Map.addAdditionalModuleMapFile(TopLevelModule, ModuleMapFile);
}
}
-
+
StringRef ModuleName = Id.back().first;
SourceLocation ModuleNameLoc = Id.back().second;
-
+
// Parse the optional attribute list.
Attributes Attrs;
if (parseOptionalAttributes(Attrs))
@@ -1864,9 +1864,9 @@ void ModuleMapParser::parseModuleDecl() {
<< ModuleName;
HadError = true;
return;
- }
+ }
SourceLocation LBraceLoc = consumeToken();
-
+
// Determine whether this (sub)module has already been defined.
Module *ShadowingModule = nullptr;
if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) {
@@ -1890,7 +1890,7 @@ void ModuleMapParser::parseModuleDecl() {
else {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_rbrace);
Diags.Report(LBraceLoc, diag::note_mmap_lbrace_match);
- HadError = true;
+ HadError = true;
}
return;
}
@@ -1986,7 +1986,7 @@ void ModuleMapParser::parseModuleDecl() {
case MMToken::UseKeyword:
parseUseDecl();
break;
-
+
case MMToken::RequiresKeyword:
parseRequiresDecl();
break;
@@ -2023,7 +2023,7 @@ void ModuleMapParser::parseModuleDecl() {
default:
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_member);
consumeToken();
- break;
+ break;
}
} while (!Done);
@@ -2233,7 +2233,7 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
// Parse the header name.
if (!Tok.is(MMToken::StringLiteral)) {
- Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
+ Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
<< "header";
HadError = true;
return;
@@ -2330,7 +2330,7 @@ static int compareModuleHeaders(const Module::Header *A,
void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
// Parse the directory name.
if (!Tok.is(MMToken::StringLiteral)) {
- Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
+ Diags.Report(Tok.getLocation(), diag::err_mmap_expected_header)
<< "umbrella";
HadError = true;
return;
@@ -2338,7 +2338,7 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
std::string DirName = Tok.getString();
SourceLocation DirNameLoc = consumeToken();
-
+
// Check whether we already have an umbrella.
if (ActiveModule->Umbrella) {
Diags.Report(DirNameLoc, diag::err_mmap_umbrella_clash)
@@ -2357,7 +2357,7 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
llvm::sys::path::append(PathName, DirName);
Dir = SourceMgr.getFileManager().getDirectory(PathName);
}
-
+
if (!Dir) {
Diags.Report(DirNameLoc, diag::warn_mmap_umbrella_dir_not_found)
<< DirName;
@@ -2413,38 +2413,38 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) {
void ModuleMapParser::parseExportDecl() {
assert(Tok.is(MMToken::ExportKeyword));
SourceLocation ExportLoc = consumeToken();
-
+
// Parse the module-id with an optional wildcard at the end.
ModuleId ParsedModuleId;
bool Wildcard = false;
do {
// FIXME: Support string-literal module names here.
if (Tok.is(MMToken::Identifier)) {
- ParsedModuleId.push_back(std::make_pair(Tok.getString(),
+ ParsedModuleId.push_back(std::make_pair(Tok.getString(),
Tok.getLocation()));
consumeToken();
-
+
if (Tok.is(MMToken::Period)) {
consumeToken();
continue;
- }
-
+ }
+
break;
}
-
+
if(Tok.is(MMToken::Star)) {
Wildcard = true;
consumeToken();
break;
}
-
+
Diags.Report(Tok.getLocation(), diag::err_mmap_module_id);
HadError = true;
return;
} while (true);
-
- Module::UnresolvedExportDecl Unresolved = {
- ExportLoc, ParsedModuleId, Wildcard
+
+ Module::UnresolvedExportDecl Unresolved = {
+ ExportLoc, ParsedModuleId, Wildcard
};
ActiveModule->UnresolvedExports.push_back(Unresolved);
}
@@ -2468,7 +2468,7 @@ void ModuleMapParser::parseExportAsDecl() {
consumeToken();
return;
}
-
+
if (!ActiveModule->ExportAsModule.empty()) {
if (ActiveModule->ExportAsModule == Tok.getString()) {
Diags.Report(Tok.getLocation(), diag::warn_mmap_redundant_export_as)
@@ -2479,7 +2479,7 @@ void ModuleMapParser::parseExportAsDecl() {
<< Tok.getString();
}
}
-
+
ActiveModule->ExportAsModule = Tok.getString();
Map.addLinkAsDependency(ActiveModule);
@@ -2666,7 +2666,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
Diags.Report(StarLoc, diag::err_mmap_inferred_no_umbrella);
Failed = true;
}
-
+
// Check for redefinition of an inferred module.
if (!Failed && ActiveModule->InferSubmodules) {
Diags.Report(StarLoc, diag::err_mmap_inferred_redef);
@@ -2721,7 +2721,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_lbrace_wildcard);
HadError = true;
return;
- }
+ }
SourceLocation LBraceLoc = consumeToken();
// Parse the body of the inferred submodule.
@@ -2762,10 +2762,10 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
}
consumeToken();
- if (Tok.is(MMToken::Star))
+ if (Tok.is(MMToken::Star))
ActiveModule->InferExportWildcard = true;
else
- Diags.Report(Tok.getLocation(),
+ Diags.Report(Tok.getLocation(),
diag::err_mmap_expected_export_wildcard);
consumeToken();
break;
@@ -2779,10 +2779,10 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
Diags.Report(Tok.getLocation(), diag::err_mmap_expected_inferred_member)
<< (ActiveModule != nullptr);
consumeToken();
- break;
+ break;
}
} while (!Done);
-
+
if (Tok.is(MMToken::RBrace))
consumeToken();
else {
@@ -2806,7 +2806,7 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
/// \returns true if an error occurred, false otherwise.
bool ModuleMapParser::parseOptionalAttributes(Attributes &Attrs) {
bool HadError = false;
-
+
while (Tok.is(MMToken::LSquare)) {
// Consume the '['.
SourceLocation LSquareLoc = consumeToken();
@@ -2876,7 +2876,7 @@ bool ModuleMapParser::parseModuleMapFile() {
switch (Tok.Kind) {
case MMToken::EndOfFile:
return HadError;
-
+
case MMToken::ExplicitKeyword:
case MMToken::ExternKeyword:
case MMToken::ModuleKeyword: