1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-09 23:08:18 +08:00
CMake/Source/cmFunctionBlocker.cxx
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00

59 lines
2.0 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFunctionBlocker.h"
#include <cassert>
#include <memory> // IWYU pragma: keep
#include <sstream>
#include <string> // IWYU pragma: keep
#include <utility>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
bool cmFunctionBlocker::IsFunctionBlocked(cmListFileFunction const& lff,
cmExecutionStatus& status)
{
if (lff.LowerCaseName() == this->StartCommandName()) {
this->ScopeDepth++;
} else if (lff.LowerCaseName() == this->EndCommandName()) {
this->ScopeDepth--;
if (this->ScopeDepth == 0U) {
cmMakefile& mf = status.GetMakefile();
auto self = mf.RemoveFunctionBlocker();
assert(self.get() == this);
cmListFileContext const& lfc = this->GetStartingContext();
cmListFileContext closingContext =
cmListFileContext::FromListFileFunction(lff, lfc.FilePath);
if (this->EndCommandSupportsArguments() &&
!this->ArgumentsMatch(lff, mf)) {
std::ostringstream e;
/* clang-format off */
e << "A logical block opening on the line\n"
<< " " << lfc << "\n"
<< "closes on the line\n"
<< " " << closingContext << "\n"
<< "with mis-matching arguments."; // noqa: spellcheck disable-line
/* clang-format on */
mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
} else if (!this->EndCommandSupportsArguments() &&
!lff.Arguments().empty()) {
std::ostringstream e;
/* clang-format off */
e << "A logical block closing on the line\n"
" " << closingContext << "\n"
"has unexpected arguments.";
/* clang-format on */
mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
}
return this->Replay(std::move(this->Functions), status);
}
}
this->Functions.push_back(lff);
return true;
}