File 0001-Fix-crash-when-Q_PROPERTY-contents-is-empty.patch of Package clazy

From 3c673d922103424805b6113aaa648f3a42d5fc4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= <ivan.cukic@kdab.com>
Date: Tue, 21 Jun 2022 23:21:47 +0200
Subject: [PATCH] Fix crash when Q_PROPERTY contents is empty

---
 src/checks/level1/qproperty-without-notify.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/checks/level1/qproperty-without-notify.cpp b/src/checks/level1/qproperty-without-notify.cpp
index 3af9fee2..47b3a72b 100644
--- a/src/checks/level1/qproperty-without-notify.cpp
+++ b/src/checks/level1/qproperty-without-notify.cpp
@@ -70,6 +70,13 @@ void QPropertyWithoutNotify::VisitMacroExpands(const clang::Token &MacroNameTok,
     CharSourceRange crange = Lexer::getAsCharRange(range, sm(), lo());
 
     string text = static_cast<std::string>(Lexer::getSourceText(crange, sm(), lo()));
+    if (text.empty()) {
+        // If the text is empty, it is more likely there is an error
+        // in parsing than an empty Q_PROPERTY macro call (which would
+        // be a moc error anyhow).
+        return;
+    }
+
     if (text.back() == ')')
         text.pop_back();
 
-- 
2.37.3

openSUSE Build Service is sponsored by