aboutsummaryrefslogtreecommitdiffstats
path: root/src/AccessSpecifierManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/AccessSpecifierManager.cpp')
-rw-r--r--src/AccessSpecifierManager.cpp50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/AccessSpecifierManager.cpp b/src/AccessSpecifierManager.cpp
index eea709fa..b5282931 100644
--- a/src/AccessSpecifierManager.cpp
+++ b/src/AccessSpecifierManager.cpp
@@ -85,7 +85,8 @@ public:
const bool isSlot = (isSlots || isSignals) ? false : name == "Q_SLOT";
const bool isSignal = (isSlots || isSignals || isSlot) ? false : name == "Q_SIGNAL";
- if (!isSlots && !isSignals && !isSlot && !isSignal)
+ const bool isInvokable = (isSlots || isSignals || isSlot || isSignal) ? false : name == "Q_INVOKABLE";
+ if (!isSlots && !isSignals && !isSlot && !isSignal & !isInvokable)
return;
SourceLocation loc = range.getBegin();
@@ -95,7 +96,6 @@ public:
if (isSignals || isSlots) {
QtAccessSpecifierType qtAccessSpecifier = isSlots ? QtAccessSpecifier_Slot
: QtAccessSpecifier_Signal;
-
m_qtAccessSpecifiers.push_back( { loc, clang::AS_none, qtAccessSpecifier } );
} else {
// Get the location of the method declaration, so we can compare directly when we visit methods
@@ -104,14 +104,17 @@ public:
return;
if (isSignal) {
m_individualSignals.push_back(loc.getRawEncoding());
- } else {
+ } else if (isSlot) {
m_individualSlots.push_back(loc.getRawEncoding());
+ } else if (isInvokable) {
+ m_individualInvokables.push_back(loc.getRawEncoding());
}
}
}
vector<unsigned> m_individualSignals; // Q_SIGNAL
vector<unsigned> m_individualSlots; // Q_SLOT
+ vector<unsigned> m_individualInvokables; // Q_INVOKABLE
const CompilerInstance &m_ci;
ClazySpecifierList m_qtAccessSpecifiers;
};
@@ -134,7 +137,7 @@ const CXXRecordDecl *AccessSpecifierManager::classDefinitionForLoc(SourceLocatio
{
for (const auto &it : m_specifiersMap) {
const CXXRecordDecl *record = it.first;
- if (record->getLocStart() < loc && loc < record->getLocEnd())
+ if (getLocStart(record) < loc && loc < getLocEnd(record))
return record;
}
return nullptr;
@@ -143,7 +146,7 @@ const CXXRecordDecl *AccessSpecifierManager::classDefinitionForLoc(SourceLocatio
void AccessSpecifierManager::VisitDeclaration(Decl *decl)
{
auto record = dyn_cast<CXXRecordDecl>(decl);
- if (!QtUtils::isQObject(record))
+ if (!clazy::isQObject(record))
return;
const auto &sm = m_ci.getSourceManager();
@@ -168,20 +171,24 @@ void AccessSpecifierManager::VisitDeclaration(Decl *decl)
if (!accessSpec || accessSpec->getDeclContext() != record)
continue;
ClazySpecifierList &specifiers = entryForClassDefinition(record);
- sorted_insert(specifiers, {accessSpec->getLocStart(), accessSpec->getAccess(), QtAccessSpecifier_None }, sm);
+ sorted_insert(specifiers, {getLocStart(accessSpec), accessSpec->getAccess(), QtAccessSpecifier_None }, sm);
}
}
QtAccessSpecifierType AccessSpecifierManager::qtAccessSpecifierType(const CXXMethodDecl *method) const
{
- if (!method || method->getLocStart().isMacroID())
+ if (!method || getLocStart(method).isMacroID())
return QtAccessSpecifier_Unknown;
// We want the declaration that's inside class {}, not the ones that are also a method definition
// and possibly outside the class
method = method->getCanonicalDecl();
- const SourceLocation methodLoc = method->getLocStart();
+ const CXXRecordDecl *record = method->getParent();
+ if (!record || isa<clang::ClassTemplateSpecializationDecl>(record))
+ return QtAccessSpecifier_None;
+
+ const SourceLocation methodLoc = getLocStart(method);
// Process Q_SIGNAL:
for (auto signalLoc : m_preprocessorCallbacks->m_individualSignals) {
@@ -195,11 +202,13 @@ QtAccessSpecifierType AccessSpecifierManager::qtAccessSpecifierType(const CXXMet
return QtAccessSpecifier_Slot;
}
- // Process Q_SLOTS and Q_SIGNALS:
+ // Process Q_INVOKABLE:
+ for (auto loc : m_preprocessorCallbacks->m_individualInvokables) {
+ if (loc == methodLoc.getRawEncoding())
+ return QtAccessSpecifier_Invokable;
+ }
- const CXXRecordDecl *record = method->getParent();
- if (!record || isa<clang::ClassTemplateSpecializationDecl>(record))
- return QtAccessSpecifier_None;
+ // Process Q_SLOTS and Q_SIGNALS:
auto it = m_specifiersMap.find(record);
if (it == m_specifiersMap.cend())
@@ -222,3 +231,20 @@ QtAccessSpecifierType AccessSpecifierManager::qtAccessSpecifierType(const CXXMet
--i; // One before the upper bound is the last access specifier before our method
return (*i).qtAccessSpecifier;
}
+
+llvm::StringRef AccessSpecifierManager::qtAccessSpecifierTypeStr(QtAccessSpecifierType t) const
+{
+ switch (t) {
+ case QtAccessSpecifier_None:
+ case QtAccessSpecifier_Unknown:
+ return "";
+ case QtAccessSpecifier_Slot:
+ return "slot";
+ case QtAccessSpecifier_Signal:
+ return "signal";
+ case QtAccessSpecifier_Invokable:
+ return "invokable";
+ default:
+ return "";
+ }
+}