[PATCH] D35682: Fixed failing assert in code completion.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 21 02:24:40 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL308722: Fixed failing assert in code completion. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D35682

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp


Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2401,10 +2401,7 @@
 static std::string GetDefaultValueString(const ParmVarDecl *Param,
                                          const SourceManager &SM,
                                          const LangOptions &LangOpts) {
-  const Expr *defaultArg = Param->getDefaultArg();
-  if (!defaultArg)
-    return "";
-  const SourceRange SrcRange = defaultArg->getSourceRange();
+  const SourceRange SrcRange = Param->getDefaultArgRange();
   CharSourceRange CharSrcRange = CharSourceRange::getTokenRange(SrcRange);
   bool Invalid = CharSrcRange.isInvalid();
   if (Invalid)
Index: cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
===================================================================
--- cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
+++ cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
@@ -0,0 +1,13 @@
+template <class T>
+struct unique_ptr {
+  typedef T* pointer;
+
+  void reset(pointer ptr = pointer());
+};
+
+void test() {
+  unique_ptr<int> x;
+  x.
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: [#void#]reset({#<#unique_ptr<int>::pointer ptr = pointer()#>#})
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35682.107644.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170721/4874686b/attachment-0001.bin>


More information about the cfe-commits mailing list