r348586 - [CTU] Add asserts to protect invariants

Gabor Marton via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 7 04:21:43 PST 2018


Author: martong
Date: Fri Dec  7 04:21:43 2018
New Revision: 348586

URL: http://llvm.org/viewvc/llvm-project?rev=348586&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp

Modified: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp?rev=348586&r1=348585&r2=348586&view=diff
==============================================================================
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp (original)
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp Fri Dec  7 04:21:43 2018
@@ -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 *> CrossTranslati
 
 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)));




More information about the cfe-commits mailing list