[PATCH] D117093: [C++20] [Modules] Exit early if export decl is invalid

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 12 13:01:33 PST 2022


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaModule.cpp:530-531
 
+  CurContext->addDecl(D);
+  PushDeclContext(S, D);
+
----------------
Am I understanding properly that this moved up here so that the for loop on line 553 can traverse the new context?

If so, can it be moved down to immediately before the for loop?


================
Comment at: clang/lib/Sema/SemaModule.cpp:539-550
+    return D;
   } else if (!ModuleScopes.back().ModuleInterface) {
     Diag(ExportLoc, diag::err_export_not_in_module_interface) << 1;
     Diag(ModuleScopes.back().BeginLoc,
          diag::note_not_module_interface_add_export)
         << FixItHint::CreateInsertion(ModuleScopes.back().BeginLoc, "export ");
+    return D;
----------------
It seems a bit suspicious to me that we call `D->getInvalidDecl()` below within the for loop, but all the other places we leave it as a valid declaration despite it causing error diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117093



More information about the cfe-commits mailing list