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 cmListFileContext const& lfc = this->GetStartingContext();
28 cmListFileContext closingContext =
29 cmListFileContext::FromListFileFunction(lff, lfc.FilePath);
30 if (this->EndCommandSupportsArguments() &&
31 !this->ArgumentsMatch(lff, mf)) {
33 /* clang-format off */
34 e << "A logical block opening on the line\n"
36 << "closes on the line\n"
37 << " " << closingContext << "\n"
38 << "with mis-matching arguments.";
40 mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
41 } else if (!this->EndCommandSupportsArguments() &&
42 !lff.Arguments().empty()) {
44 /* clang-format off */
45 e << "A logical block closing on the line\n"
46 " " << closingContext << "\n"
47 "has unexpected arguments.";
49 mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
52 return this->Replay(std::move(this->Functions), status);
56 this->Functions.push_back(lff);