summaryrefslogtreecommitdiff
path: root/lib/CrossTU
diff options
context:
space:
mode:
authorGabor Marton <martongabesz@gmail.com>2018-12-07 12:21:43 +0000
committerGabor Marton <martongabesz@gmail.com>2018-12-07 12:21:43 +0000
commit3a8b1ec0b3add798d7e9ebe7a51734148b697fa1 (patch)
treea2639dd421274a01dc24457f1eb99ef3e113d8b3 /lib/CrossTU
parentfd01d8b9288b3558a597daeb0cb4481b37c5bf68 (diff)
downloadclang-3a8b1ec0b3add798d7e9ebe7a51734148b697fa1.tar.gz
[CTU] Add asserts to protect invariants
Reviewers: xazax.hun, a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Differential Revision: https://reviews.llvm.org/D55132 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348586 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CrossTU')
-rw-r--r--lib/CrossTU/CrossTranslationUnit.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/CrossTU/CrossTranslationUnit.cpp b/lib/CrossTU/CrossTranslationUnit.cpp
index 08c9d99ec9..97563b05b0 100644
--- a/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/lib/CrossTU/CrossTranslationUnit.cpp
@@ -160,6 +160,7 @@ llvm::Expected<const FunctionDecl *>
CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
StringRef CrossTUDir,
StringRef IndexName) {
+ assert(FD && "FD is missing, bad call to this function!");
assert(!FD->hasBody() && "FD has a definition in current translation unit!");
++NumGetCTUCalled;
const std::string LookupFnName = getLookupName(FD);
@@ -258,6 +259,8 @@ llvm::Expected<ASTUnit *> CrossTranslationUnitContext::loadExternalAST(
llvm::Expected<const FunctionDecl *>
CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) {
+ assert(FD->hasBody() && "Functions to be imported should have body.");
+
ASTImporter &Importer = getOrCreateASTImporter(FD->getASTContext());
auto *ToDecl =
cast<FunctionDecl>(Importer.Import(const_cast<FunctionDecl *>(FD)));