cmFunctionBlocker.cxx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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"
  4. #include <cassert>
  5. #include <memory> // IWYU pragma: keep
  6. #include <sstream>
  7. #include <string> // IWYU pragma: keep
  8. #include <utility>
  9. #include "cmExecutionStatus.h"
  10. #include "cmMakefile.h"
  11. #include "cmMessageType.h"
  12. bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
  13. cmExecutionStatus& status)
  14. {
  15. if (lff.Name.Lower == this->StartCommandName()) {
  16. this->ScopeDepth++;
  17. } else if (lff.Name.Lower == this->EndCommandName()) {
  18. this->ScopeDepth--;
  19. if (this->ScopeDepth == 0U) {
  20. cmMakefile& mf = status.GetMakefile();
  21. auto self = mf.RemoveFunctionBlocker();
  22. assert(self.get() == this);
  23. if (!this->ArgumentsMatch(lff, mf)) {
  24. cmListFileContext const& lfc = this->GetStartingContext();
  25. cmListFileContext closingContext =
  26. cmListFileContext::FromCommandContext(lff, lfc.FilePath);
  27. std::ostringstream e;
  28. /* clang-format off */
  29. e << "A logical block opening on the line\n"
  30. << " " << lfc << "\n"
  31. << "closes on the line\n"
  32. << " " << closingContext << "\n"
  33. << "with mis-matching arguments.";
  34. /* clang-format on */
  35. mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
  36. }
  37. return this->Replay(std::move(this->Functions), status);
  38. }
  39. }
  40. this->Functions.push_back(lff);
  41. return true;
  42. }