Skip to content

Commit b6ca3b5

Browse files
authored
Fix clang tidy + remove warnings when building (#272)
1 parent 542fc55 commit b6ca3b5

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

.github/workflows/clang-format.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Python
2424
uses: actions/setup-python@v5
2525
with:
26-
python-version: 3.10
26+
python-version: "3.11"
2727

2828
- name: Install clang-format
2929
run: |

.github/workflows/clang-tidy-review.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@ jobs:
1717
- name: Checkout PR branch
1818
uses: actions/checkout@v4
1919

20+
- name: Setup Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
2025
- name: Install LLVM and Clang
21-
uses: KyleMayes/install-llvm-action@v2
26+
uses: KyleMayes/install-llvm-action@v2.0.2
2227
with:
23-
version: "18.1.3"
28+
version: "16.0.0"
2429

30+
- name: install lit
31+
run: pip install lit
32+
2533
- name: Run clang-tidy
2634
uses: ZedThree/[email protected]
2735
id: review
2836
with:
2937
build_dir: build
30-
apt_packages: libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
38+
apt_packages: cmake,libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
3139
split_workflow: true
3240
cmake_command: >
33-
pip install cmake lit &&
34-
cmake --version &&
3541
cmake . -B build -DCMAKE_BUILD_TYPE="Release"
3642
-DUSE_CLING=OFF
3743
-DUSE_REPL=ON
@@ -40,4 +46,4 @@ jobs:
4046
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
4147
4248
- name: Upload artifacts
43-
uses: ZedThree/clang-tidy-review/[email protected]
49+
uses: ZedThree/clang-tidy-review/[email protected]

lib/Interpreter/Compatibility.h

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include "clang/Basic/Version.h"
1111
#include "clang/Config/config.h"
1212

13+
#if LLVM_VERSION_MAJOR < 18
14+
#define starts_with startswith
15+
#define ends_with endswith
16+
#endif
17+
1318
#if CLANG_VERSION_MAJOR >= 18
1419
#include "clang/Interpreter/CodeCompletion.h"
1520
#endif

lib/Interpreter/CppInterOp.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ namespace Cpp {
316316
// Add quick checks for the std smart prts to cover most of the cases.
317317
std::string typeString = GetTypeAsString(type);
318318
llvm::StringRef tsRef(typeString);
319-
if (tsRef.startswith("std::unique_ptr") ||
320-
tsRef.startswith("std::shared_ptr") ||
321-
tsRef.startswith("std::weak_ptr"))
319+
if (tsRef.starts_with("std::unique_ptr") ||
320+
tsRef.starts_with("std::shared_ptr") ||
321+
tsRef.starts_with("std::weak_ptr"))
322322
return true;
323323
return isSmartPointer(RT);
324324
}

lib/Interpreter/DynamicLibraryManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ namespace Cpp {
323323
foundName = lookupLibMaybeAddExt(libStem, RPath, RunPath, libLoader);
324324
if (foundName.empty()) {
325325
StringRef libStemName = llvm::sys::path::filename(libStem);
326-
if (!libStemName.startswith("lib")) {
326+
if (!libStemName.starts_with("lib")) {
327327
// try with "lib" prefix:
328328
foundName = lookupLibMaybeAddExt(
329329
libStem.str().insert(libStem.size()-libStemName.size(), "lib"),

lib/Interpreter/Paths.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ bool SplitPaths(llvm::StringRef PathStr,
413413
}
414414

415415
// Trim trailing sep in case of A:B:C:D:
416-
if (!PathStr.empty() && PathStr.endswith(Delim))
416+
if (!PathStr.empty() && PathStr.ends_with(Delim))
417417
PathStr = PathStr.substr(0, PathStr.size()-Delim.size());
418418

419419
if (!PathStr.empty()) {

0 commit comments

Comments
 (0)