[PATCH] D35682: Fixed failing assert in code completion.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 06:36:11 PDT 2017
ilya-biryukov created this revision.
The code was accessing uninstantiated default argument.
This resulted in failing assertion at ParamVarDecl::getDefaultArg().
https://reviews.llvm.org/D35682
Files:
lib/Sema/SemaCodeComplete.cpp
test/CodeCompletion/uninstantiated_params.cpp
Index: test/CodeCompletion/uninstantiated_params.cpp
===================================================================
--- /dev/null
+++ 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()#>#})
+}
Index: lib/Sema/SemaCodeComplete.cpp
===================================================================
--- lib/Sema/SemaCodeComplete.cpp
+++ 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35682.107500.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170720/e2c78bf7/attachment.bin>
More information about the cfe-commits
mailing list