aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-07 15:52:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-09 19:34:08 +0200
commit3a0b9ebc9e2980af8dc5fbf4ac8bc6ddfd49c9d9 (patch)
treea9a499b128090c2131db7590e934d83241d21cf8 /sources/shiboken2/ApiExtractor/clangparser/clangutils.h
parentfb2dc48389c1099bef3aaed97f16ce2bd1b90fee (diff)
shiboken2/clangparser: Refactor code snippet extraction handling
Code snippets resulting from macro expansion have a 0 range. Detect this first thing and return an empty snippet before starting to convert file names and reading files. For that purpose, use a CXFile instead of a QString in SourceLocation. For all other cases, output a verbose warning. Provide a function to obtain the file name from a CXFile with caching in the builder. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ie30563f5b25d0d21b3a1ceb0c9da37cfc8d808dd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser/clangutils.h')
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangutils.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
index 5f005bd5d..41d0af460 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
@@ -62,16 +62,24 @@ inline bool isCursorValid(const CXCursor &c)
return c.kind < CXCursor_FirstInvalid || c.kind > CXCursor_LastInvalid;
}
+QString getFileName(CXFile file); // Uncached,see BaseVisitor for a cached version
+
struct SourceLocation
{
- int compare(const SourceLocation &rhs) const;
+ bool equals(const SourceLocation &rhs) const;
- QString file;
+ CXFile file;
unsigned line = 0;
unsigned column = 0;
unsigned offset = 0;
};
+inline bool operator==(const SourceLocation &l1, const SourceLocation &l2)
+{ return l1.equals(l2); }
+
+inline bool operator!=(const SourceLocation &l1, const SourceLocation &l2)
+{ return !l1.equals(l2); }
+
SourceLocation getExpansionLocation(const CXSourceLocation &location);
using SourceRange =QPair<SourceLocation, SourceLocation>;