mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Simplify some code in SourceFile, NFC
This commit is contained in:
@@ -1073,23 +1073,22 @@ public:
|
||||
}
|
||||
|
||||
std::vector<Token> &getTokenVector() {
|
||||
assert(EnabledAndAllCorrectedTokens.first && "Disabled");
|
||||
return EnabledAndAllCorrectedTokens.second;
|
||||
assert(pAllCorrectedTokens && "Disabled");
|
||||
return *pAllCorrectedTokens;
|
||||
}
|
||||
|
||||
ArrayRef<Token> getAllTokens() const {
|
||||
assert(EnabledAndAllCorrectedTokens.first && "Disabled");
|
||||
return EnabledAndAllCorrectedTokens.second;
|
||||
assert(pAllCorrectedTokens && "Disabled");
|
||||
return *pAllCorrectedTokens;
|
||||
}
|
||||
|
||||
bool shouldKeepTokens() const {
|
||||
return EnabledAndAllCorrectedTokens.first;
|
||||
return (bool)pAllCorrectedTokens;
|
||||
}
|
||||
|
||||
private:
|
||||
/// Whether the SourceFile instance opts to collect underlying tokens and
|
||||
/// the vector containing these tokens if so.
|
||||
std::pair<bool, std::vector<Token>> EnabledAndAllCorrectedTokens;
|
||||
/// If not null, the pointee vector should contain tokens of this source file.
|
||||
std::unique_ptr<std::vector<Token>> pAllCorrectedTokens;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1325,8 +1325,7 @@ SourceFile::SourceFile(ModuleDecl &M, SourceFileKind K,
|
||||
bool KeepTokens)
|
||||
: FileUnit(FileUnitKind::Source, M),
|
||||
BufferID(bufferID ? *bufferID : -1),
|
||||
Kind(K),
|
||||
EnabledAndAllCorrectedTokens(KeepTokens, std::vector<Token>()) {
|
||||
Kind(K) {
|
||||
M.getASTContext().addDestructorCleanup(*this);
|
||||
performAutoImport(*this, ModImpKind);
|
||||
|
||||
@@ -1335,6 +1334,9 @@ SourceFile::SourceFile(ModuleDecl &M, SourceFileKind K,
|
||||
assert(!problem && "multiple main files?");
|
||||
(void)problem;
|
||||
}
|
||||
if (KeepTokens) {
|
||||
pAllCorrectedTokens.reset(new std::vector<Token>());
|
||||
}
|
||||
}
|
||||
|
||||
SourceFile::~SourceFile() {}
|
||||
|
||||
Reference in New Issue
Block a user