diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-09-05 15:42:16 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-09-13 14:19:32 +0000 |
commit | 8eca5916a7534b3cb25a84501cadc1f056ceb8d8 (patch) | |
tree | a1c09396ca92964713404f748d9f76aa6b96334f /sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | |
parent | f47b304e920b45fb51e1a532f6197d518b307797 (diff) |
Do not consider gl.h a system include file (all platforms)
Amends db904f8e9ed06eac37151c9a8b955c63c1eb8a46 to
apply to all platforms since the issue is also present
on Linux.
Task-number: PYSIDE-516
Change-Id: I564506f6aefc26e95beae90d95643553eba5dbff
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 9fff9af8b..ea6559689 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -514,11 +514,28 @@ Builder::~Builder() delete d; } +static inline bool compareHeaderName(const char *haystack, const char *needle) +{ + const char *lastSlash = strrchr(haystack, '/'); +#ifdef Q_OS_WIN + if (lastSlash == nullptr) + lastSlash = strrchr(haystack, '\\'); +#endif + if (lastSlash == nullptr) + lastSlash = haystack; + else + ++lastSlash; +#ifdef Q_OS_WIN + return _stricmp(lastSlash, needle) == 0; +#else + return strcmp(lastSlash, needle) == 0; +#endif +} + bool Builder::visitLocation(const CXSourceLocation &location) const { if (clang_Location_isInSystemHeader(location) == 0) return true; -#ifdef Q_OS_WIN CXFile file; // void * unsigned line; unsigned column; @@ -528,12 +545,11 @@ bool Builder::visitLocation(const CXSourceLocation &location) const // Has been observed to be 0 for invalid locations if (const char *cFileName = clang_getCString(cxFileName)) { // Resolve OpenGL typedefs although the header is considered a system header. - const bool visitHeader = _stricmp(cFileName, "GL/gl.h") || _stricmp(cFileName, "gl.h") == 0; + const bool visitHeader = compareHeaderName(cFileName, "gl.h"); clang_disposeString(cxFileName); if (visitHeader) return true; } -#endif // Q_OS_WIN return false; } |