Path: blob/main/contrib/llvm-project/clang/lib/Basic/StackExhaustionHandler.cpp
213765 views
//===--- StackExhaustionHandler.cpp - - A utility for warning once when close1// to out of stack space -------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8///9/// \file10/// Defines a utilitiy for warning once when close to out of stack space.11///12//===----------------------------------------------------------------------===//1314#include "clang/Basic/StackExhaustionHandler.h"15#include "clang/Basic/Stack.h"1617void clang::StackExhaustionHandler::runWithSufficientStackSpace(18SourceLocation Loc, llvm::function_ref<void()> Fn) {19clang::runWithSufficientStackSpace([&] { warnStackExhausted(Loc); }, Fn);20}2122void clang::StackExhaustionHandler::warnOnStackNearlyExhausted(23SourceLocation Loc) {24if (isStackNearlyExhausted())25warnStackExhausted(Loc);26}2728void clang::StackExhaustionHandler::warnStackExhausted(SourceLocation Loc) {29// Only warn about this once.30if (!WarnedStackExhausted) {31DiagsRef.Report(Loc, diag::warn_stack_exhausted);32WarnedStackExhausted = true;33}34}353637