Skip to content

Commit

Permalink
[NFC] Doc and style fixes for #filePath implementation
Browse files Browse the repository at this point in the history
This addresses some late-breaking review comments left by @hamishknight on swiftlang#29412.
  • Loading branch information
beccadax committed Mar 13, 2020
1 parent 000572d commit b65a9c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ class SourceFile final : public FileUnit {
/// forwarded on to IRGen.
ASTStage_t ASTStage = Unprocessed;

/// Virtual filenames declared by #sourceLocation(file:) directives in this
/// file.
llvm::SmallVector<Located<StringRef>, 0> VirtualFilenames;
/// Virtual file paths declared by \c #sourceLocation(file:) declarations in
/// this source file.
llvm::SmallVector<Located<StringRef>, 0> VirtualFilePaths;

/// Returns information about the file paths used for diagnostics and magic
/// identifiers in this source file, including virtual filenames introduced by
/// \c #sourceLocation(file:) declarations.
llvm::StringMap<SourceFilePathInfo> getInfoForUsedFilePaths() const;

SourceFile(ModuleDecl &M, SourceFileKind K, Optional<unsigned> bufferID,
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ SourceFile::getInfoForUsedFilePaths() const {
getASTContext().SourceMgr.getLocForBufferStart(BufferID);
}

for (auto &vpath : VirtualFilenames) {
for (auto &vpath : VirtualFilePaths) {
result[vpath.Item].virtualFileLocs.insert(vpath.Loc);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4827,7 +4827,7 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
if (!Filename.hasValue())
return makeParserError();
SourceLoc filenameLoc = consumeToken(tok::string_literal);
SF.VirtualFilenames.emplace_back(*Filename, filenameLoc);
SF.VirtualFilePaths.emplace_back(*Filename, filenameLoc);

if (parseToken(tok::comma, diag::sourceLocation_expected, ",") ||
parseSpecificIdentifier("line", diag::sourceLocation_expected,
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
ASTContext &getASTContext() { return M.getASTContext(); }

llvm::StringMap<std::pair<std::string, /*isWinner=*/bool>>
MagicFileStringsByFilePath;
MagicFileStringsByFilePath;

static DeclName getMagicFunctionName(SILDeclRef ref);
static DeclName getMagicFunctionName(DeclContext *dc);
Expand Down

0 comments on commit b65a9c6

Please sign in to comment.