[PATCH] D77395: [AST] Dont invalidate VarDecl even the default initializaiton is failed.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 12:52:53 PDT 2020


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

the `attempt to use a deleted function` diagnostic is a bit spammy, because the default-constructor and destructor are often deleted for similar reasons. But I guess this is probably OK, unless you can see an easy way to suppress it.



================
Comment at: clang/lib/Sema/SemaDecl.cpp:12559
+    // that we would preserve more AST nodes (DeclRefExpr could be built rather
+    // than dropped) in broken code.
+
----------------
Tempting as it is, I'm not sure we should leave a big comment around describing code that isn't here.
Maybe just a minimal `If default-init fails, leave var uninitialized but valid, for recovery.`


================
Comment at: clang/test/AST/ast-dump-invalid-initialized.cpp:6
+
+void test() {
+  // CHECK: `-VarDecl {{.*}} a1 'A'
----------------
may be worth testing the other existing behavior we're being consistent with here too: A a1 = garbage(); etc


================
Comment at: clang/test/CodeCompletion/invalid-initialized-class.cpp:7
+  // CHECK: COMPLETION: abc
+}
----------------
Again, may want Foo bar = garbage(); bar.^


================
Comment at: clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp:11
 union bad_union {
-  non_trivial nt; // expected-note {{non-trivial default constructor}}
+  non_trivial nt; // expected-note {{non-trivial default constructor}} // expected-note {{destructor of 'bad_union' is implicitly deleted}}
 };
----------------
nit: extra //


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77395





More information about the cfe-commits mailing list