This is an archive of the discontinued LLVM Phabricator instance.

[libclang] Fix crash in member access code completion with implicit base
ClosedPublic

Authored by erikjv on Feb 22 2017, 2:45 AM.

Details

Reviewers
klimek
bkramer
Summary

If there is an unresolved member access AST node, and the base is
implicit, do not access/use it for generating candidate overloads for
code completion results (because the base is a nullptr).

Fixes PR31093.

Diff Detail

Event Timeline

erikjv created this revision.Feb 22 2017, 2:45 AM

It seems that unresolved member expressions have other lookup issues. For example, this will crash when code-completing as well:

struct Foo {
  void foo() const;
  static void foo(bool);
};

struct Bar: Foo {
  void foo(bool param) {
this->Foo::foo(/*CC CRASH*/  );// unresolved member expression with an explicit base
  }
};

Are we sure that a call to AddFunctionCandidates is the right way to gather the method overloads in this particular instance?

bkramer accepted this revision.Mar 27 2017, 1:35 AM

Let's fix those crashes one at a time. This patch looks good, only minor comments below.

lib/Sema/SemaOverload.cpp
6311

This could use a comment explaining that this can happen if there's an error in the code, e.g. in code completion context.

6329

Same here.

This revision is now accepted and ready to land.Mar 27 2017, 1:35 AM
erikjv closed this revision.Mar 28 2017, 12:46 AM

Landed as r298903.