Author: Chuanqi Xu Date: 2022-07-27T14:33:28+08:00 New Revision: 8d91b1da576b1643175fbac0fb4b3a95bed07bf0
URL: https://github.com/llvm/llvm-project/commit/8d91b1da576b1643175fbac0fb4b3a95bed07bf0 DIFF: https://github.com/llvm/llvm-project/commit/8d91b1da576b1643175fbac0fb4b3a95bed07bf0.diff LOG: [NFC] [C++20] [Modules] Use Sema::isModuleUnitOfCurrentTU to simplify the code Added: Modified: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaLookup.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 06ea0b417cb3a..2ada0499ad728 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2278,9 +2278,6 @@ class Sema final { bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind); - // Determine whether the module M belongs to the current TU. - bool isModuleUnitOfCurrentTU(const Module *M) const; - public: /// Get the module unit whose scope we are currently within. Module *getCurrentModule() const { @@ -2301,6 +2298,9 @@ class Sema final { return DirectModuleImports.contains(M); } + // Determine whether the module M belongs to the current TU. + bool isModuleUnitOfCurrentTU(const Module *M) const; + /// Make a merged definition of an existing hidden definition \p ND /// visible at the specified location. void makeMergedDefinitionVisible(NamedDecl *ND); diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 68158ec977cfe..dd1a1e1ccb007 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -1920,12 +1920,7 @@ bool LookupResult::isReachableSlow(Sema &SemaRef, NamedDecl *D) { // If D comes from a module and SemaRef doesn't own a module, it implies D // comes from another TU. In case SemaRef owns a module, we could judge if D // comes from another TU by comparing the module unit. - // - // FIXME: It would look better if we have direct method to judge whether D is - // in another TU. - if (SemaRef.getCurrentModule() && - SemaRef.getCurrentModule()->getTopLevelModule() == - DeclModule->getTopLevelModule()) + if (SemaRef.isModuleUnitOfCurrentTU(DeclModule)) return true; // [module.reach]/p3: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits