r373259 - Fix failure caused by r373247

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 13:45:12 PDT 2019


Author: erichkeane
Date: Mon Sep 30 13:45:12 2019
New Revision: 373259

URL: http://llvm.org/viewvc/llvm-project?rev=373259&view=rev
Log:
Fix failure caused by r373247

I incorrectly thought that the 'isLambda' check never fired, so when
splitting up a helper function, I lost the 'nullptr' return value.
ClangD Hover functionality apparently uses this, so the Unittest caught
that.

This patch correctly propogates the nullptr from the helper function.

Modified:
    cfe/trunk/lib/AST/DeclCXX.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=373259&r1=373258&r2=373259&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Sep 30 13:45:12 2019
@@ -1413,11 +1413,15 @@ NamedDecl* getLambdaCallOperatorHelper(c
 
 FunctionTemplateDecl* CXXRecordDecl::getDependentLambdaCallOperator() const {
   NamedDecl *CallOp = getLambdaCallOperatorHelper(*this);
-  return  dyn_cast<FunctionTemplateDecl>(CallOp);
+  return  dyn_cast_or_null<FunctionTemplateDecl>(CallOp);
 }
 
 CXXMethodDecl *CXXRecordDecl::getLambdaCallOperator() const {
   NamedDecl *CallOp = getLambdaCallOperatorHelper(*this);
+
+  if (CallOp == nullptr)
+    return nullptr;
+
   if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp))
     return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
 




More information about the cfe-commits mailing list