[PATCH] D44300: [SemaOverload] Fixed crash on code completion

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 9 06:47:06 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL327134: [SemaOverload] Fixed crash on code completion (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44300

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeCompletion/enable-if-attr-crash.cpp


Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/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());
Index: cfe/trunk/test/CodeCompletion/enable-if-attr-crash.cpp
===================================================================
--- cfe/trunk/test/CodeCompletion/enable-if-attr-crash.cpp
+++ cfe/trunk/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
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44300.137744.patch
Type: text/x-patch
Size: 1924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180309/ed853ee6/attachment-0001.bin>


More information about the cfe-commits mailing list