[PATCH] D44300: [SemaOverload] Fixed crash on code completion
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 9 06:41:23 PST 2018
ilya-biryukov updated this revision to Diff 137743.
ilya-biryukov added a comment.
- Added a comment
Repository:
rC Clang
https://reviews.llvm.org/D44300
Files:
lib/Sema/SemaOverload.cpp
test/CodeCompletion/enable-if-attr-crash.cpp
Index: test/CodeCompletion/enable-if-attr-crash.cpp
===================================================================
--- /dev/null
+++ test/CodeCompletion/enable-if-attr-crash.cpp
@@ -0,0 +1,8 @@
+int foo(bool x) __attribute__((enable_if(x, "")));
+
+int test() {
+ bool fffffff;
+ // RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:7:8 %s | FileCheck %s
+ // CHECK: COMPLETION: fffffff : [#bool#]fffffff
+ foo(ff
+}
Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -6245,12 +6245,17 @@
if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
for (unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
ParmVarDecl *P = Function->getParamDecl(i);
- ExprResult R = S.PerformCopyInitialization(
- InitializedEntity::InitializeParameter(S.Context,
- Function->getParamDecl(i)),
- SourceLocation(),
- P->hasUninstantiatedDefaultArg() ? P->getUninstantiatedDefaultArg()
- : P->getDefaultArg());
+ Expr *DefArg = P->hasUninstantiatedDefaultArg()
+ ? P->getUninstantiatedDefaultArg()
+ : P->getDefaultArg();
+ // This can only happen in code completion, i.e. when PartialOverloading
+ // is true.
+ if (!DefArg)
+ return false;
+ ExprResult R =
+ S.PerformCopyInitialization(InitializedEntity::InitializeParameter(
+ S.Context, Function->getParamDecl(i)),
+ SourceLocation(), DefArg);
if (R.isInvalid())
return false;
ConvertedArgs.push_back(R.get());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44300.137743.patch
Type: text/x-patch
Size: 1829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180309/c11d29c6/attachment.bin>
More information about the cfe-commits
mailing list