]> granicus.if.org Git - clang/commitdiff
Fix failure caused by r373247
authorErich Keane <erich.keane@intel.com>
Mon, 30 Sep 2019 20:45:12 +0000 (20:45 +0000)
committerErich Keane <erich.keane@intel.com>
Mon, 30 Sep 2019 20:45:12 +0000 (20:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373259 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp

index 942588f4ede7186998d8cf3ba0279e9ad47f8581..5f181fa67de806466b57adfc2f3aaedcdc5f5d4c 100644 (file)
@@ -1413,11 +1413,15 @@ NamedDecl* getLambdaCallOperatorHelper(const CXXRecordDecl &RD) {
 
 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());