clang 20.0.0git
StackExhaustionHandler.h
Go to the documentation of this file.
1//===--- StackExhaustionHandler.h - A utility for warning once when close to out
2// 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
15#ifndef LLVM_CLANG_BASIC_STACK_EXHAUSTION_HANDLER_H
16#define LLVM_CLANG_BASIC_STACK_EXHAUSTION_HANDLER_H
17
19
20namespace clang {
22public:
23 StackExhaustionHandler(DiagnosticsEngine &diags) : DiagsRef(diags) {}
24
25 /// Run some code with "sufficient" stack space. (Currently, at least 256K
26 /// is guaranteed). Produces a warning if we're low on stack space and
27 /// allocates more in that case. Use this in code that may recurse deeply to
28 /// avoid stack overflow.
30 llvm::function_ref<void()> Fn);
31
32 /// Check to see if we're low on stack space and produce a warning if we're
33 /// low on stack space (Currently, at least 256Kis guaranteed).
35
36private:
37 /// Warn that the stack is nearly exhausted.
38 void warnStackExhausted(SourceLocation Loc);
39
40 DiagnosticsEngine &DiagsRef;
41 bool WarnedStackExhausted = false;
42};
43} // end namespace clang
44
45#endif // LLVM_CLANG_BASIC_STACK_EXHAUSTION_HANDLER_H
Defines the Diagnostic-related interfaces.
SourceLocation Loc
Definition: SemaObjC.cpp:759
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
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.
StackExhaustionHandler(DiagnosticsEngine &diags)
The JSON file list parser is used to communicate input to InstallAPI.