Skip to content

Commit 8d91b1d

Browse files
committed
[NFC] [C++20] [Modules] Use Sema::isModuleUnitOfCurrentTU to simplify the code
1 parent e818ce0 commit 8d91b1d

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,9 +2278,6 @@ class Sema final {
22782278

22792279
bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);
22802280

2281-
// Determine whether the module M belongs to the current TU.
2282-
bool isModuleUnitOfCurrentTU(const Module *M) const;
2283-
22842281
public:
22852282
/// Get the module unit whose scope we are currently within.
22862283
Module *getCurrentModule() const {
@@ -2301,6 +2298,9 @@ class Sema final {
23012298
return DirectModuleImports.contains(M);
23022299
}
23032300

2301+
// Determine whether the module M belongs to the current TU.
2302+
bool isModuleUnitOfCurrentTU(const Module *M) const;
2303+
23042304
/// Make a merged definition of an existing hidden definition \p ND
23052305
/// visible at the specified location.
23062306
void makeMergedDefinitionVisible(NamedDecl *ND);

clang/lib/Sema/SemaLookup.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,12 +1920,7 @@ bool LookupResult::isReachableSlow(Sema &SemaRef, NamedDecl *D) {
19201920
// If D comes from a module and SemaRef doesn't own a module, it implies D
19211921
// comes from another TU. In case SemaRef owns a module, we could judge if D
19221922
// comes from another TU by comparing the module unit.
1923-
//
1924-
// FIXME: It would look better if we have direct method to judge whether D is
1925-
// in another TU.
1926-
if (SemaRef.getCurrentModule() &&
1927-
SemaRef.getCurrentModule()->getTopLevelModule() ==
1928-
DeclModule->getTopLevelModule())
1923+
if (SemaRef.isModuleUnitOfCurrentTU(DeclModule))
19291924
return true;
19301925

19311926
// [module.reach]/p3:

0 commit comments

Comments
 (0)