r308722 - Fixed failing assert in code completion.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 21 02:24:00 PDT 2017
Author: ibiryukov
Date: Fri Jul 21 02:24:00 2017
New Revision: 308722
URL: http://llvm.org/viewvc/llvm-project?rev=308722&view=rev
Log:
Fixed failing assert in code completion.
Summary:
The code was accessing uninstantiated default argument.
This resulted in failing assertion at ParmVarDecl::getDefaultArg().
Reviewers: erikjv, klimek, bkramer, krasimir
Reviewed By: krasimir
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D35682
Added:
cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=308722&r1=308721&r2=308722&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jul 21 02:24:00 2017
@@ -2401,10 +2401,7 @@ formatBlockPlaceholder(const PrintingPol
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)
Added: cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp?rev=308722&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp (added)
+++ cfe/trunk/test/CodeCompletion/uninstantiated_params.cpp Fri Jul 21 02:24:00 2017
@@ -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()#>#})
+}
More information about the cfe-commits
mailing list