Use Optional for SourceFile::getImportBufferID, instead of a sentinel.

No functionality change.

Swift SVN r9082
This commit is contained in:
Jordan Rose
2013-10-09 18:45:10 +00:00
parent ccce45b981
commit e83d0d608a
3 changed files with 12 additions and 9 deletions

View File

@@ -412,8 +412,8 @@ public:
/// purposes.
ASTStage_t ASTStage = Parsing;
SourceFile(TranslationUnit &tu, SourceKind K,
int ImportID = -1) : ImportBufferID(ImportID), TU(tu), Kind(K) {}
SourceFile(TranslationUnit &tu, SourceKind K, Optional<int> ImportID = {})
: ImportBufferID(ImportID ? *ImportID : -1), TU(tu), Kind(K) {}
ArrayRef<std::pair<Module::ImportedModule, bool>> getImports() const {
assert(ASTStage >= Parsed || Kind == SIL);
@@ -423,9 +423,13 @@ public:
Imports = IM;
}
/// \brief The buffer ID for the file that was imported as this TU, or -1
/// \brief The buffer ID for the file that was imported as this TU, or Nothing
/// if this is not an imported TU.
int getImportBufferID() const { return ImportBufferID; }
Optional<int> getImportBufferID() const {
if (ImportBufferID == -1)
return Nothing;
return ImportBufferID;
}
private:
// Make placement new and vanilla new/delete illegal for SourceFiles.