@@ -1615,6 +1615,18 @@ class Sema final {
16151615
16161616 void emitAndClearUnusedLocalTypedefWarnings();
16171617
1618+ private:
1619+ /// Function or variable declarations to be checked for whether the deferred
1620+ /// diagnostics should be emitted.
1621+ SmallVector<Decl *, 4> DeclsToCheckForDeferredDiags;
1622+
1623+ public:
1624+ // Emit all deferred diagnostics.
1625+ void emitDeferredDiags();
1626+ // Emit any deferred diagnostics for FD and erase them from the map in which
1627+ // they're stored.
1628+ void emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack);
1629+
16181630 enum TUFragmentKind {
16191631 /// The global module fragment, between 'module;' and a module-declaration.
16201632 Global,
@@ -3901,7 +3913,8 @@ class Sema final {
39013913 TemplateDiscarded, // Discarded due to uninstantiated templates
39023914 Unknown,
39033915 };
3904- FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl);
3916+ FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl,
3917+ bool Final = false);
39053918
39063919 // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check.
39073920 bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee);
@@ -9925,22 +9938,10 @@ class Sema final {
99259938 /// Pop OpenMP function region for non-capturing function.
99269939 void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
99279940
9928- /// Check whether we're allowed to call Callee from the current function.
9929- void checkOpenMPDeviceFunction(SourceLocation Loc, FunctionDecl *Callee,
9930- bool CheckForDelayedContext = true);
9931-
9932- /// Check whether we're allowed to call Callee from the current function.
9933- void checkOpenMPHostFunction(SourceLocation Loc, FunctionDecl *Callee,
9934- bool CheckCaller = true);
9935-
99369941 /// Check if the expression is allowed to be used in expressions for the
99379942 /// OpenMP devices.
99389943 void checkOpenMPDeviceExpr(const Expr *E);
99399944
9940- /// Finishes analysis of the deferred functions calls that may be declared as
9941- /// host/nohost during device/host compilation.
9942- void finalizeOpenMPDelayedAnalysis();
9943-
99449945 /// Checks if a type or a declaration is disabled due to the owning extension
99459946 /// being disabled, and emits diagnostic messages if it is disabled.
99469947 /// \param D type or declaration to be checked.
@@ -10131,6 +10132,11 @@ class Sema final {
1013110132 void
1013210133 checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D,
1013310134 SourceLocation IdLoc = SourceLocation());
10135+ /// Finishes analysis of the deferred functions calls that may be declared as
10136+ /// host/nohost during device/host compilation.
10137+ void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
10138+ const FunctionDecl *Callee,
10139+ SourceLocation Loc);
1013410140 /// Return true inside OpenMP declare target region.
1013510141 bool isInOpenMPDeclareTargetContext() const {
1013610142 return DeclareTargetNestingLevel > 0;
@@ -11517,18 +11523,6 @@ class Sema final {
1151711523 /* Caller = */ FunctionDeclAndLoc>
1151811524 DeviceKnownEmittedFns;
1151911525
11520- /// A partial call graph maintained during CUDA/OpenMP device code compilation
11521- /// to support deferred diagnostics.
11522- ///
11523- /// Functions are only added here if, at the time they're considered, they are
11524- /// not known-emitted. As soon as we discover that a function is
11525- /// known-emitted, we remove it and everything it transitively calls from this
11526- /// set and add those functions to DeviceKnownEmittedFns.
11527- llvm::DenseMap</* Caller = */ CanonicalDeclPtr<FunctionDecl>,
11528- /* Callees = */ llvm::MapVector<CanonicalDeclPtr<FunctionDecl>,
11529- SourceLocation>>
11530- DeviceCallGraph;
11531-
1153211526 /// Diagnostic builder for CUDA/OpenMP devices errors which may or may not be
1153311527 /// deferred.
1153411528 ///
@@ -11603,14 +11597,6 @@ class Sema final {
1160311597 llvm::Optional<unsigned> PartialDiagId;
1160411598 };
1160511599
11606- /// Indicate that this function (and thus everything it transtively calls)
11607- /// will be codegen'ed, and emit any deferred diagnostics on this function and
11608- /// its (transitive) callees.
11609- void markKnownEmitted(
11610- Sema &S, FunctionDecl *OrigCaller, FunctionDecl *OrigCallee,
11611- SourceLocation OrigLoc,
11612- const llvm::function_ref<bool(Sema &, FunctionDecl *)> IsKnownEmitted);
11613-
1161411600 /// Creates a DeviceDiagBuilder that emits the diagnostic if the current context
1161511601 /// is "used as device code".
1161611602 ///
@@ -12478,10 +12464,11 @@ class Sema final {
1247812464 /// codegen'ed yet.
1247912465 bool checkSYCLDeviceFunction(SourceLocation Loc, FunctionDecl *Callee);
1248012466
12481- /// Emit diagnostic that can't be emitted with deferred diagnostics mechanism.
12482- /// At this step we imply that all device functions are marked with
12483- /// sycl_device attribute.
12484- void finalizeSYCLDelayedAnalysis();
12467+ /// Finishes analysis of the deferred functions calls that may be declared as
12468+ /// host during device compilation.
12469+ void finalizeSYCLDelayedAnalysis(const FunctionDecl *Caller,
12470+ const FunctionDecl *Callee,
12471+ SourceLocation Loc);
1248512472};
1248612473
1248712474template <typename AttrType>
0 commit comments