Skip to content

Commit c715023

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents ea2c72e + 1b4db78 commit c715023

File tree

30 files changed

+1638
-856
lines changed

30 files changed

+1638
-856
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12391,6 +12391,13 @@ def err_invalid_module_name : Error<"%0 is an invalid name for a module">;
1239112391
def err_extern_def_in_header_unit : Error<
1239212392
"non-inline external definitions are not permitted in C++ header units">;
1239312393

12394+
def warn_exposure : Warning <
12395+
"TU local entity %0 is exposed">,
12396+
InGroup<DiagGroup<"TU-local-entity-exposure">>;
12397+
def warn_reference_tu_local_entity_in_other_tu : Warning <
12398+
"instantiation of %0 triggers reference to TU-local entity %1 from other TU '%2'">,
12399+
InGroup<DiagGroup<"reference-tu-local-entity-in-other-tu">>;
12400+
1239412401
def warn_experimental_header_unit : Warning<
1239512402
"the implementation of header units is in an experimental phase">,
1239612403
InGroup<DiagGroup<"experimental-header-units">>;

clang/include/clang/Sema/Sema.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9945,6 +9945,20 @@ class Sema final : public SemaBase {
99459945

99469946
VisibleModuleSet VisibleModules;
99479947

9948+
/// Whether we had imported any named modules.
9949+
bool HadImportedNamedModules = false;
9950+
/// The set of instantiations we need to check if they references TU-local
9951+
/// entity from TUs. This only makes sense if we imported any named modules.
9952+
llvm::SmallVector<std::pair<FunctionDecl *, SourceLocation>>
9953+
PendingCheckReferenceForTULocal;
9954+
/// Implement [basic.link]p18, which requires that we can't use TU-local
9955+
/// entities from other TUs (ignoring header units).
9956+
void checkReferenceToTULocalFromOtherTU(FunctionDecl *FD,
9957+
SourceLocation PointOfInstantiation);
9958+
/// Implement [basic.link]p17, which diagnose for non TU local exposure in
9959+
/// module interface or module partition.
9960+
void checkExposure(const TranslationUnitDecl *TU);
9961+
99489962
///@}
99499963

99509964
//

clang/lib/Sema/Sema.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ void Sema::ActOnEndOfTranslationUnit() {
16211621

16221622
if (!PP.isIncrementalProcessingEnabled())
16231623
TUScope = nullptr;
1624+
1625+
checkExposure(Context.getTranslationUnitDecl());
16241626
}
16251627

16261628

0 commit comments

Comments
 (0)