[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 24 06:22:20 PST 2019


ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added inline comments.


================
Comment at: lib/Sema/SemaCodeComplete.cpp:373
+    }
+    Type = QualType();
+  });
----------------
kadircet wrote:
> nit: maybe move this into top and get rid of the return statements inside `if`s(also by changing them to `else if`s)
FWIW I find ifs with return to be more readable than a bunch of if+else statements. The reason is that return clearly states function is done, while trailing `else` suggests it will go further.

But this particular function is short, so it's not a strong argument, can change it if you insist.


================
Comment at: lib/Sema/SemaCodeComplete.cpp:380
+  return update([&]() {
+    auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
+    Type = VD ? VD->getType() : QualType();
----------------
kadircet wrote:
> Is it really possible for D to be null ?
Probably shouldn't, but I can't be certain, I'm too lazy to inspect all code paths in the parser, so I'd simply rely on the types used there and assume this could happen.

I'll try adding an assertion and finding the example when it happens, though.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56723/new/

https://reviews.llvm.org/D56723





More information about the cfe-commits mailing list