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

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 17 05:22:52 PST 2019


kadircet added a comment.

That really looks awesome, thanks!

One general comment: I am not really sure if the handling done in `ParseCastExpression` is extensive enough. But IIUC, this should not cause any regressions, rather should result in missing preferred types just as before this patch ?



================
Comment at: lib/Parse/ParseExpr.cpp:1157
 
   case tok::kw_co_await: {  // unary-expression: 'co_await' cast-expression
     SourceLocation CoawaitLoc = ConsumeToken();
----------------
shouldn't we have an enterunknown here as well?


================
Comment at: lib/Sema/SemaCodeComplete.cpp:352
+PreferredTypeBuilder::RestoreRAII
+PreferredTypeBuilder::update(llvm::function_ref<void()> Updater) {
+  RestoreRAII R(*this);
----------------
I am not sure it carries the weight, why not just inline it?


================
Comment at: lib/Sema/SemaCodeComplete.cpp:360
+  return update([&]() {
+    if (isa<BlockDecl>(S.CurContext)) {
+      if (sema::BlockScopeInfo *BSI = S.getCurBlock())
----------------
Is this check necessary? According to comments `getCurBlock` returns null if there is no block.


================
Comment at: lib/Sema/SemaCodeComplete.cpp:373
+    }
+    Type = QualType();
+  });
----------------
nit: maybe move this into top and get rid of the return statements inside `if`s(also by changing them to `else if`s)


================
Comment at: lib/Sema/SemaCodeComplete.cpp:380
+  return update([&]() {
+    auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
+    Type = VD ? VD->getType() : QualType();
----------------
Is it really possible for D to be null ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56723





More information about the cfe-commits mailing list