Rename GetLanguageInfo to GetLanguageSpecificData (#117012)
[llvm-project.git] / clang / lib / Basic / StackExhaustionHandler.cpp
blob24b499c810dbfe32323e220a6f3a3ea749abf1f5
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 //===----------------------------------------------------------------------===//
15 #include "clang/Basic/StackExhaustionHandler.h"
16 #include "clang/Basic/Stack.h"
18 void clang::StackExhaustionHandler::runWithSufficientStackSpace(
19 SourceLocation Loc, llvm::function_ref<void()> Fn) {
20 clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn);
23 void clang::StackExhaustionHandler::warnOnStackNearlyExhausted(
24 SourceLocation Loc) {
25 if (isStackNearlyExhausted())
26 warnStackExhausted(Loc);
29 void 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;