MCPcopy Create free account
hub / github.com/Kitware/CMake / IsFunctionBlocked

Method IsFunctionBlocked

Source/cmFunctionBlocker.cxx:16–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "cmake.h"
15
16bool cmFunctionBlocker::IsFunctionBlocked(cmListFileFunction const& lff,
17 cmExecutionStatus& status)
18{
19 if (lff.LowerCaseName() == this->StartCommandName()) {
20 this->ScopeDepth++;
21 } else if (lff.LowerCaseName() == this->EndCommandName()) {
22 this->ScopeDepth--;
23 if (this->ScopeDepth == 0U) {
24 cmMakefile& mf = status.GetMakefile();
25 auto self = mf.RemoveFunctionBlocker();
26 assert(self.get() == this);
27
28 cmListFileContext const& lfc = this->GetStartingContext();
29 cmListFileContext closingContext =
30 cmListFileContext::FromListFileFunction(lff, lfc.FilePath);
31 if (this->EndCommandSupportsArguments() &&
32 !this->ArgumentsMatch(lff, mf)) {
33 std::ostringstream e;
34 /* clang-format off */
35 e << "A logical block opening on the line\n"
36 << " " << lfc << "\n"
37 << "closes on the line\n"
38 << " " << closingContext << "\n"
39 << "with mis-matching arguments."; // noqa: spellcheck disable-line
40 /* clang-format on */
41 mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
42 } else if (!this->EndCommandSupportsArguments() &&
43 !lff.Arguments().empty()) {
44 std::ostringstream e;
45 /* clang-format off */
46 e << "A logical block closing on the line\n"
47 " " << closingContext << "\n"
48 "has unexpected arguments.";
49 /* clang-format on */
50 mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
51 }
52
53 bool replayResult = this->Replay(std::move(this->Functions), status);
54 cmListFileBacktrace endCommandBT =
55 mf.GetBacktrace().Push(closingContext);
56 // if trace is enabled, print a (trivially) evaluated "end" statement
57 if (mf.GetCMakeInstance()->GetTrace()) {
58 mf.PrintCommandTrace(lff, endCommandBT,
59 cmMakefile::CommandMissingFromStack::Yes);
60 }
61 return replayResult;
62 }
63 }
64
65 this->Functions.push_back(lff);
66 return true;
67}

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
RemoveFunctionBlockerMethod · 0.80
strMethod · 0.80
ArgumentsMethod · 0.80
PushMethod · 0.80
GetTraceMethod · 0.80
PrintCommandTraceMethod · 0.80
push_backMethod · 0.80
StartCommandNameMethod · 0.45
EndCommandNameMethod · 0.45
GetMakefileMethod · 0.45

Tested by

no test coverage detected