]> granicus.if.org Git - clang/commitdiff
[CodeComplete] Allow getDeclaration on RK_Pattern result.
authorEric Liu <ioeric@google.com>
Wed, 18 Jul 2018 15:17:52 +0000 (15:17 +0000)
committerEric Liu <ioeric@google.com>
Wed, 18 Jul 2018 15:17:52 +0000 (15:17 +0000)
Summary:
RK_Pattern results can also have associated declarations e.g. field
decls in constructor initializers.

Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D49484

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

include/clang/Sema/CodeCompleteConsumer.h

index 606f3b36901be7afeaff76fce2732e926a458f30..ede3ddf9199316df43ce5d05d840f70d7c2d072e 100644 (file)
@@ -895,9 +895,11 @@ public:
     computeCursorKindAndAvailability();
   }
 
-  /// Retrieve the declaration stored in this result.
+  /// Retrieve the declaration stored in this result. This might be nullptr if
+  /// Kind is RK_Pattern.
   const NamedDecl *getDeclaration() const {
-    assert(Kind == RK_Declaration && "Not a declaration result");
+    assert(((Kind == RK_Declaration) || (Kind == RK_Pattern)) &&
+           "Not a declaration or pattern result");
     return Declaration;
   }