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)
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)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits