clang 20.0.0git
StackExhaustionHandler.cpp
Go to the documentation of this file.
1//===--- StackExhaustionHandler.cpp - - A utility for warning once when close
2// to out of stack space -------*- C++ -*-===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// Defines a utilitiy for warning once when close to out of stack space.
12///
13//===----------------------------------------------------------------------===//
14
16#include "clang/Basic/Stack.h"
17
19 SourceLocation Loc, llvm::function_ref<void()> Fn) {
20 clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn);
21}
22
26 warnStackExhausted(Loc);
27}
28
29void clang::StackExhaustionHandler::warnStackExhausted(SourceLocation Loc) {
30 // Only warn about this once.
31 if (!WarnedStackExhausted) {
32 DiagsRef.Report(Loc, diag::warn_stack_exhausted);
33 WarnedStackExhausted = true;
34 }
35}
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines a utilitiy for warning once when close to out of stack space.
Defines utilities for dealing with stack allocation and stack space.
Encodes a location in the source.
void warnOnStackNearlyExhausted(SourceLocation Loc)
Check to see if we're low on stack space and produce a warning if we're low on stack space (Currently...
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
bool isStackNearlyExhausted()
Determine whether the stack is nearly exhausted.
Definition: Stack.cpp:45
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
Definition: Stack.h:40