[PATCH] D55280: [CTU] Remove redundant error check
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 4 09:40:13 PST 2018
martong created this revision.
martong added reviewers: xazax.hun, a_sidorin, Szelethus, balazske.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, rnkovacs.
In loadExternalAST we normally return with either an error or with a valid
ASTUnit pointer which should not be a nullptr.
However, in the call site we did a superfluous check for being a nullptr.
Repository:
rC Clang
https://reviews.llvm.org/D55280
Files:
include/clang/CrossTU/CrossTranslationUnit.h
lib/CrossTU/CrossTranslationUnit.cpp
Index: lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -51,8 +51,6 @@
return "Missing definition from the index file.";
case index_error_code::failed_import:
return "Failed to import the definition.";
- case index_error_code::failed_to_get_external_ast:
- return "Failed to load external AST source.";
case index_error_code::failed_to_generate_usr:
return "Failed to generate USR.";
}
@@ -160,9 +158,6 @@
if (!ASTUnitOrError)
return ASTUnitOrError.takeError();
ASTUnit *Unit = *ASTUnitOrError;
- if (!Unit)
- return llvm::make_error<IndexError>(
- index_error_code::failed_to_get_external_ast);
assert(&Unit->getFileManager() ==
&Unit->getASTContext().getSourceManager().getFileManager());
@@ -240,6 +235,7 @@
} else {
Unit = FnUnitCacheEntry->second;
}
+ assert(Unit);
return Unit;
}
Index: include/clang/CrossTU/CrossTranslationUnit.h
===================================================================
--- include/clang/CrossTU/CrossTranslationUnit.h
+++ include/clang/CrossTU/CrossTranslationUnit.h
@@ -40,7 +40,6 @@
multiple_definitions,
missing_definition,
failed_import,
- failed_to_get_external_ast,
failed_to_generate_usr
};
@@ -118,8 +117,8 @@
/// \p IndexName. In case the declaration is found in the index the
/// corresponding AST file will be loaded.
///
- /// \return Returns an ASTUnit that contains the definition of the looked up
- /// function.
+ /// \return Returns a pointer to the ASTUnit that contains the definition of
+ /// the looked up function. The pointer should not be a nullptr.
///
/// Note that the AST files should also be in the \p CrossTUDir.
llvm::Expected<ASTUnit *> loadExternalAST(StringRef LookupName,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55280.176658.patch
Type: text/x-patch
Size: 1922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181204/a1351df7/attachment.bin>
More information about the cfe-commits
mailing list