Skip to content

Commit

Permalink
Fix clang tidy + remove warnings when building (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbarton authored May 8, 2024
1 parent 542fc55 commit b6ca3b5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.10
python-version: "3.11"

- name: Install clang-format
run: |
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/clang-tidy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ jobs:
- name: Checkout PR branch
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
uses: KyleMayes/install-llvm-action@v2.0.2
with:
version: "18.1.3"
version: "16.0.0"

- name: install lit
run: pip install lit

- name: Run clang-tidy
uses: ZedThree/[email protected]
id: review
with:
build_dir: build
apt_packages: libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
apt_packages: cmake,libxml2,libxml2-dev,libtinfo-dev,zlib1g-dev,libzstd-dev
split_workflow: true
cmake_command: >
pip install cmake lit &&
cmake --version &&
cmake . -B build -DCMAKE_BUILD_TYPE="Release"
-DUSE_CLING=OFF
-DUSE_REPL=ON
Expand All @@ -40,4 +46,4 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Upload artifacts
uses: ZedThree/clang-tidy-review/[email protected]
uses: ZedThree/clang-tidy-review/[email protected]
5 changes: 5 additions & 0 deletions lib/Interpreter/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"

#if LLVM_VERSION_MAJOR < 18
#define starts_with startswith
#define ends_with endswith
#endif

#if CLANG_VERSION_MAJOR >= 18
#include "clang/Interpreter/CodeCompletion.h"
#endif
Expand Down
6 changes: 3 additions & 3 deletions lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ namespace Cpp {
// Add quick checks for the std smart prts to cover most of the cases.
std::string typeString = GetTypeAsString(type);
llvm::StringRef tsRef(typeString);
if (tsRef.startswith("std::unique_ptr") ||
tsRef.startswith("std::shared_ptr") ||
tsRef.startswith("std::weak_ptr"))
if (tsRef.starts_with("std::unique_ptr") ||
tsRef.starts_with("std::shared_ptr") ||
tsRef.starts_with("std::weak_ptr"))
return true;
return isSmartPointer(RT);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Interpreter/DynamicLibraryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ namespace Cpp {
foundName = lookupLibMaybeAddExt(libStem, RPath, RunPath, libLoader);
if (foundName.empty()) {
StringRef libStemName = llvm::sys::path::filename(libStem);
if (!libStemName.startswith("lib")) {
if (!libStemName.starts_with("lib")) {
// try with "lib" prefix:
foundName = lookupLibMaybeAddExt(
libStem.str().insert(libStem.size()-libStemName.size(), "lib"),
Expand Down
2 changes: 1 addition & 1 deletion lib/Interpreter/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ bool SplitPaths(llvm::StringRef PathStr,
}

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

if (!PathStr.empty()) {
Expand Down

0 comments on commit b6ca3b5

Please sign in to comment.