[PATCH] D64748: Refactor threshold checking
Endre Fülöp via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 08:55:22 PDT 2019
gamesh411 created this revision.
Herald added subscribers: cfe-commits, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a project: clang.
Herald added a subscriber: rnkovacs.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64748
Files:
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/lib/CrossTU/CrossTranslationUnit.cpp
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -340,6 +340,14 @@
}
}
+bool CrossTranslationUnitContext::checkThresholdReached() const {
+ if (NumASTLoaded >= CTULoadThreshold) {
+ ++NumASTLoadThresholdReached;
+ return true;
+ }
+ return false;
+}
+
llvm::Expected<ASTUnit *> CrossTranslationUnitContext::loadExternalAST(
StringRef LookupName, StringRef CrossTUDir, StringRef IndexName,
bool DisplayCTUProgress) {
@@ -348,11 +356,10 @@
// translation units contains decls with the same lookup name an
// error will be returned.
- if (NumASTLoaded >= CTULoadThreshold) {
- ++NumASTLoadThresholdReached;
+ // If import threshold is reached, don't import anything.
+ if (checkThresholdReached())
return llvm::make_error<IndexError>(
index_error_code::load_threshold_reached);
- }
ASTUnit *Unit = nullptr;
auto NameUnitCacheEntry = NameASTUnitMap.find(LookupName);
Index: clang/include/clang/CrossTU/CrossTranslationUnit.h
===================================================================
--- clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -163,6 +163,7 @@
void emitCrossTUDiagnostics(const IndexError &IE);
private:
+ bool checkThresholdReached() const;
void lazyInitImporterSharedSt(TranslationUnitDecl *ToTU);
ASTImporter &getOrCreateASTImporter(ASTContext &From);
template <typename T>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64748.209874.patch
Type: text/x-patch
Size: 1611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190715/75fdab87/attachment-0001.bin>
More information about the cfe-commits
mailing list