1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmFunctionBlocker.h"
6 #include <memory> // IWYU pragma: keep
8 #include <string> // IWYU pragma: keep
11 #include "cmExecutionStatus.h"
12 #include "cmMakefile.h"
13 #include "cmMessageType.h"
15 bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
16 cmExecutionStatus& status)
18 if (lff.LowerCaseName() == this->StartCommandName()) {
20 } else if (lff.LowerCaseName() == this->EndCommandName()) {
22 if (this->ScopeDepth == 0U) {
23 cmMakefile& mf = status.GetMakefile();
24 auto self = mf.RemoveFunctionBlocker();
25 assert(self.get() == this);
27 if (!this->ArgumentsMatch(lff, mf)) {
28 cmListFileContext const& lfc = this->GetStartingContext();
29 cmListFileContext closingContext =
30 cmListFileContext::FromListFileFunction(lff, lfc.FilePath);
32 /* clang-format off */
33 e << "A logical block opening on the line\n"
35 << "closes on the line\n"
36 << " " << closingContext << "\n"
37 << "with mis-matching arguments.";
39 mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
42 return this->Replay(std::move(this->Functions), status);
46 this->Functions.push_back(lff);