diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-01-30 16:02:02 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-02-03 18:13:30 +0100 |
| commit | 96b6c9b816f04e5eb7c34c3c7345a9adbd5d85ea (patch) | |
| tree | 9151820ec8ab84f7e1b08676dc24defbc5fda5ab /sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp | |
| parent | e03a1552a701838cc616bcddaa64c8f3509c1753 (diff) | |
shiboken6: Fix some clang-tidy warnings
- Fix invocation of static functions
- Use std::any, range-based for where applicable
- Use std::make_shared instead of new
- Replace QByteArrayLiteral() by literal
- Use const-ref to avoid copies
Pick-to: 6.8
Change-Id: Iec864bd6eee8fb06f5afd122084a9e0f551ff8f1
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp')
| -rw-r--r-- | sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp index 43334c306..7ce132813 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangparser.cpp @@ -28,8 +28,6 @@ QString SourceFileCache::getFileName(CXFile file) std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor, QString *errorMessage) { - static const char empty[] = ""; - if (errorMessage) errorMessage->clear(); @@ -37,12 +35,12 @@ std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor, // Quick check for equal locations: Frequently happens if the code is // the result of a macro expansion if (range.first == range.second) - return std::string_view(empty, 0); + return {}; if (range.first.file != range.second.file) { if (errorMessage) *errorMessage = "Range spans several files"_L1; - return std::string_view(empty, 0); + return {}; } auto it = m_fileBufferCache.find(range.first.file); @@ -51,7 +49,7 @@ std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor, if (fileName.isEmpty()) { if (errorMessage) *errorMessage = "Range has no file"_L1; - return std::string_view(empty, 0); + return {}; } QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { @@ -60,7 +58,7 @@ std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor, str << "Cannot open \"" << QDir::toNativeSeparators(fileName) << "\": " << file.errorString(); } - return std::string_view(empty, 0); + return {}; } it = m_fileBufferCache.insert(range.first.file, file.readAll()); } @@ -76,7 +74,7 @@ std::string_view SourceFileCache::getCodeSnippet(const CXCursor &cursor, << QDir::toNativeSeparators(getFileName(range.first.file)) << "\" (" << contents.size() << ')'; } - return std::string_view(empty, 0); + return {}; } return std::string_view(contents.constData() + pos, end - pos); |
