forked from qt-creator/qt-creator
Clang: Suppress a compiler warning in fulltokeninfo.cpp
Change-Id: I75fadf3c38b2a75cb8791da0271bf6e100505708 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -106,8 +106,18 @@ static Utf8String propertyParentSpelling(CXTranslationUnit cxTranslationUnit,
|
|||||||
return parentSpelling;
|
return parentSpelling;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Utf8String getPropertyType(const char *const lineContents, uint propertyPosition)
|
static Utf8String getPropertyType(const CXSourceLocation &cxLocation,
|
||||||
|
CXTranslationUnit cxTranslationUnit,
|
||||||
|
uint propertyPosition)
|
||||||
{
|
{
|
||||||
|
#if defined(CINDEX_VERSION_HAS_GETFILECONTENTS_BACKPORTED) || CINDEX_VERSION_MINOR >= 47
|
||||||
|
// Extract property type from the source code
|
||||||
|
CXFile cxFile;
|
||||||
|
uint offset;
|
||||||
|
clang_getFileLocation(cxLocation, &cxFile, nullptr, nullptr, &offset);
|
||||||
|
const char *const contents = clang_getFileContents(cxTranslationUnit, cxFile, nullptr);
|
||||||
|
const char *const lineContents = &contents[offset - propertyPosition];
|
||||||
|
|
||||||
const char *typeStart = std::strstr(lineContents, "Q_PROPERTY") + 10;
|
const char *typeStart = std::strstr(lineContents, "Q_PROPERTY") + 10;
|
||||||
typeStart += std::strspn(typeStart, "( \t\n\r");
|
typeStart += std::strspn(typeStart, "( \t\n\r");
|
||||||
if (typeStart - lineContents >= propertyPosition)
|
if (typeStart - lineContents >= propertyPosition)
|
||||||
@@ -117,6 +127,12 @@ static Utf8String getPropertyType(const char *const lineContents, uint propertyP
|
|||||||
Utils::unequalTo(' '));
|
Utils::unequalTo(' '));
|
||||||
|
|
||||||
return Utf8String(typeStart, static_cast<int>(&(*typeEnd) + 1 - typeStart));
|
return Utf8String(typeStart, static_cast<int>(&(*typeEnd) + 1 - typeStart));
|
||||||
|
#else
|
||||||
|
Q_UNUSED(cxLocation)
|
||||||
|
Q_UNUSED(cxTranslationUnit)
|
||||||
|
Q_UNUSED(propertyPosition)
|
||||||
|
return Utf8String();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullTokenInfo::updatePropertyData()
|
void FullTokenInfo::updatePropertyData()
|
||||||
@@ -130,17 +146,9 @@ void FullTokenInfo::updatePropertyData()
|
|||||||
m_extraInfo.cursorRange = range;
|
m_extraInfo.cursorRange = range;
|
||||||
m_extraInfo.declaration = true;
|
m_extraInfo.declaration = true;
|
||||||
m_extraInfo.definition = true;
|
m_extraInfo.definition = true;
|
||||||
#if defined(CINDEX_VERSION_HAS_GETFILECONTENTS_BACKPORTED) || CINDEX_VERSION_MINOR >= 47
|
m_extraInfo.typeSpelling = getPropertyType(clang_getRangeStart(cxRange),
|
||||||
// Extract property type from the source code
|
m_cxTranslationUnit,
|
||||||
CXFile cxFile;
|
column() - 1);
|
||||||
uint offset;
|
|
||||||
clang_getFileLocation(clang_getRangeStart(cxRange), &cxFile, nullptr, nullptr, &offset);
|
|
||||||
const uint propertyPosition = column() - 1;
|
|
||||||
const char *const contents = clang_getFileContents(m_cxTranslationUnit, cxFile, nullptr);
|
|
||||||
const char *const lineContents = &contents[offset - propertyPosition];
|
|
||||||
|
|
||||||
m_extraInfo.typeSpelling = getPropertyType(lineContents, propertyPosition);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullTokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
|
void FullTokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||||
|
|||||||
Reference in New Issue
Block a user