Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ Checks: >
modernize-make-unique,
modernize-redundant-void-arg,
modernize-use-bool-literals,
modernize-use-default-member-init,
# Disabled: there is not consensus on whether the Clang-14 behavior
# of this checker is always desirable or not, and there isn't currently
# a way to revert to the Clang-13 behavior. We may revisit this
# check the next time we examine clang-tidy options.
# modernize-use-default-member-init,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
Expand Down Expand Up @@ -54,7 +58,7 @@ Checks: >
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
FormatStyle: 'file'
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: 1
#CheckOptions:
# - key: modernize-use-default-member-init.UseAssignment
# value: 1
...
14 changes: 7 additions & 7 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.13
- uses: DoozyX/clang-format-lint-action@v0.14
with:
source: '.'
extensions: 'h,c,cpp'
clangFormatVersion: 13
clangFormatVersion: 14
check_clang_tidy:
name: Check clang-tidy
runs-on: ubuntu-20.04
Expand All @@ -30,14 +30,14 @@ jobs:
# from apt.llvm.org
# wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
sudo apt-add-repository "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-13 main"
sudo apt-add-repository "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-14 main"
sudo apt-get update
sudo apt-get install llvm-13 clang-13 liblld-13-dev libclang-13-dev clang-tidy-13 ninja-build
sudo apt-get install llvm-14 clang-14 liblld-14-dev libclang-14-dev clang-tidy-14 ninja-build
- name: Run clang-tidy
run: |
export CC=clang-13
export CXX=clang++-13
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-13
export CC=clang-14
export CXX=clang++-14
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-14
./run-clang-tidy.sh
check_cmake_file_lists:
name: Check CMake file lists
Expand Down
14 changes: 7 additions & 7 deletions run-clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ set -e

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# We are currently standardized on using LLVM/Clang13 for this script.
# We are currently standardized on using LLVM/Clang14 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM13 installed,
# are using to build Halide itself. If you don't have LLVM14 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-13 clang-13 libclang-13-dev clang-tidy-13
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-13
# sudo apt-get install llvm-14 clang-14 libclang-14-dev clang-tidy-14
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-14

[ -z "$CLANG_FORMAT_LLVM_INSTALL_DIR" ] && echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_FORMAT_LLVM_INSTALL_DIR = ${CLANG_FORMAT_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_FORMAT_LLVM_INSTALL_DIR}/bin/clang-format --version)
if [[ ${VERSION} =~ .*version\ 13.* ]]
if [[ ${VERSION} =~ .*version\ 14.* ]]
then
echo "clang-format version 13 found."
echo "clang-format version 14 found."
else
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 13 install!"
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 14 install!"
exit 1
fi

Expand Down
14 changes: 7 additions & 7 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

FIX=$1

# We are currently standardized on using LLVM/Clang12 for this script.
# We are currently standardized on using LLVM/Clang14 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM12 installed,
# are using to build Halide itself. If you don't have LLVM14 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-13 clang-13 libclang-13-dev clang-tidy-13
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-13
# sudo apt-get install llvm-14 clang-14 libclang-14-dev clang-tidy-14
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-14

[ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ] && echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy --version)
if [[ ${VERSION} =~ .*version\ 13.* ]]
if [[ ${VERSION} =~ .*version\ 14.* ]]
then
echo "clang-tidy version 13 found."
echo "clang-tidy version 14 found."
else
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 13 install!"
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 14 install!"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion src/BoundsInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ class BoundsInference : public IRMutator {

// Do any pure inlining (TODO: This is currently slow)
for (size_t i = f.size(); i > 0; i--) {
Function func = f[i - 1];
const Function &func = f[i - 1];
if (inlined[i - 1]) {
for (auto &s : stages) {
for (auto &cond_val : s.exprs) {
Expand Down
2 changes: 0 additions & 2 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "PythonExtensionGen.h"
#include "StmtToHtml.h"

using Halide::Internal::debug;

namespace Halide {
namespace Internal {

Expand Down
8 changes: 6 additions & 2 deletions src/WasmExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,9 @@ void wasm_jit_malloc_callback(const v8::FunctionCallbackInfo<v8::Value> &args) {

size_t size = args[0]->Int32Value(context).ToChecked() + kExtraMallocSlop;
wasm32_ptr_t p = v8_WasmMemoryObject_malloc(context, size);
if (p) { p += kExtraMallocSlop; }
if (p) {
p += kExtraMallocSlop;
}
args.GetReturnValue().Set(load_scalar(context, p));
}

Expand All @@ -1851,7 +1853,9 @@ void wasm_jit_free_callback(const v8::FunctionCallbackInfo<v8::Value> &args) {
HandleScope scope(isolate);
Local<Context> context = isolate->GetCurrentContext();
wasm32_ptr_t p = args[0]->Int32Value(context).ToChecked();
if (p) { p -= kExtraMallocSlop; }
if (p) {
p -= kExtraMallocSlop;
}
v8_WasmMemoryObject_free(context, p);
}

Expand Down
8 changes: 6 additions & 2 deletions src/runtime/internal/block_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ MemoryRegion *BlockAllocator::reserve(void *user_context, const MemoryRequest &r
void BlockAllocator::reclaim(void *user_context, MemoryRegion *memory_region) {
halide_abort_if_false(user_context, memory_region != nullptr);
RegionAllocator *allocator = RegionAllocator::find_allocator(user_context, memory_region);
if (allocator == nullptr) { return; }
if (allocator == nullptr) {
return;
}
allocator->reclaim(user_context, memory_region);
}

Expand Down Expand Up @@ -331,7 +333,9 @@ void BlockAllocator::destroy_region_allocator(void *user_context, RegionAllocato
<< "user_context=" << (void *)(user_context) << " "
<< "region_allocator=" << (void *)(region_allocator) << ")...\n";
#endif
if (region_allocator == nullptr) { return; }
if (region_allocator == nullptr) {
return;
}
RegionAllocator::destroy(user_context, region_allocator);
}

Expand Down
8 changes: 6 additions & 2 deletions src/runtime/internal/block_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ BlockStorage &BlockStorage::operator=(const BlockStorage &other) {
}

bool BlockStorage::operator==(const BlockStorage &other) const {
if (config.entry_size != other.config.entry_size) { return false; }
if (count != other.count) { return false; }
if (config.entry_size != other.config.entry_size) {
return false;
}
if (count != other.count) {
return false;
}
return memcmp(this->ptr, other.ptr, this->size() * config.entry_size) == 0;
}

Expand Down
8 changes: 6 additions & 2 deletions src/runtime/internal/linked_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ void LinkedList::initialize(void *user_context, uint32_t entry_size, uint32_t ca

void LinkedList::destroy(void *user_context) {
clear(nullptr);
if (link_arena) { MemoryArena::destroy(nullptr, link_arena); }
if (data_arena) { MemoryArena::destroy(nullptr, data_arena); }
if (link_arena) {
MemoryArena::destroy(nullptr, link_arena);
}
if (data_arena) {
MemoryArena::destroy(nullptr, data_arena);
}
link_arena = nullptr;
data_arena = nullptr;
front_ptr = nullptr;
Expand Down
8 changes: 6 additions & 2 deletions src/runtime/internal/pointer_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ PointerTable::PointerTable(void *user_context, size_t initial_capacity, const Sy
: allocator(sma) {
halide_abort_if_false(user_context, allocator.allocate != nullptr);
halide_abort_if_false(user_context, allocator.deallocate != nullptr);
if (initial_capacity) { reserve(user_context, initial_capacity); }
if (initial_capacity) {
reserve(user_context, initial_capacity);
}
}

PointerTable::PointerTable(const PointerTable &other)
Expand Down Expand Up @@ -122,7 +124,9 @@ PointerTable &PointerTable::operator=(const PointerTable &other) {
}

bool PointerTable::operator==(const PointerTable &other) const {
if (count != other.count) { return false; }
if (count != other.count) {
return false;
}
return memcmp(this->ptr, other.ptr, this->size() * sizeof(void *)) == 0;
}

Expand Down
4 changes: 3 additions & 1 deletion src/runtime/internal/region_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ BlockRegion *RegionAllocator::find_block_region(void *user_context, const Memory
}

bool RegionAllocator::can_coalesce(BlockRegion *block_region) {
if (block_region == nullptr) { return false; }
if (block_region == nullptr) {
return false;
}
if (block_region->prev_ptr && (block_region->prev_ptr->status == AllocationStatus::Available)) {
return true;
}
Expand Down
64 changes: 48 additions & 16 deletions src/runtime/internal/string_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ namespace Internal {
// Static utility functions for dealing with string data
struct StringUtils {
static bool is_empty(const char *str) {
if (str == nullptr) { return true; }
if (str[0] == '\0') { return true; }
if (str == nullptr) {
return true;
}
if (str[0] == '\0') {
return true;
}
return false;
}

// count the number of delimited string tokens
static size_t count_tokens(const char *str, const char *delim) {
if (StringUtils::is_empty(str)) { return 0; }
if (StringUtils::is_empty(delim)) { return 1; } // no delim ... string is one token
if (StringUtils::is_empty(str)) {
return 0;
}
if (StringUtils::is_empty(delim)) {
return 1;
} // no delim ... string is one token

size_t count = 0;
const char *ptr = str;
Expand All @@ -33,7 +41,9 @@ struct StringUtils {

// retuns true if s1 contains s2 (within n characters)
static bool contains(const char *s1, const char *s2, size_t n) {
if (is_empty(s2)) { return true; } // s2 is empty ... return true to match strstr
if (is_empty(s2)) {
return true;
} // s2 is empty ... return true to match strstr
char starts_with = *s2;
for (size_t length = strlen(s2); length <= n; n--, s1++) {
if (*s1 == starts_with) {
Expand Down Expand Up @@ -105,7 +115,9 @@ class StringStorage {

StringStorage::StringStorage(void *user_context, uint32_t capacity, const SystemMemoryAllocatorFns &sma)
: contents(user_context, {sizeof(char), 32, 32}, sma) {
if (capacity) { contents.reserve(user_context, capacity); }
if (capacity) {
contents.reserve(user_context, capacity);
}
}

StringStorage::~StringStorage() {
Expand Down Expand Up @@ -142,21 +154,29 @@ StringStorage &StringStorage::operator=(const StringStorage &other) {
}

bool StringStorage::contains(const char *str) const {
if (contents.empty()) { return false; }
if (contents.empty()) {
return false;
}
const char *this_str = static_cast<const char *>(contents.data());
return StringUtils::contains(this_str, str, contents.size());
}

bool StringStorage::contains(const StringStorage &other) const {
if (contents.empty()) { return false; }
if (other.contents.empty()) { return false; }
if (contents.empty()) {
return false;
}
if (other.contents.empty()) {
return false;
}
const char *this_str = static_cast<const char *>(contents.data());
const char *other_str = static_cast<const char *>(other.contents.data());
return StringUtils::contains(this_str, other_str, contents.size());
}

bool StringStorage::operator==(const StringStorage &other) const {
if (contents.size() != other.contents.size()) { return false; }
if (contents.size() != other.contents.size()) {
return false;
}
const char *this_str = static_cast<const char *>(contents.data());
const char *other_str = static_cast<const char *>(other.contents.data());
return strncmp(this_str, other_str, contents.size()) == 0;
Expand All @@ -180,16 +200,24 @@ void StringStorage::assign(void *user_context, char ch) {
}

void StringStorage::assign(void *user_context, const char *str, size_t length) {
if (StringUtils::is_empty(str)) { return; }
if (length == 0) { length = strlen(str); }
if (StringUtils::is_empty(str)) {
return;
}
if (length == 0) {
length = strlen(str);
}
reserve(user_context, length);
contents.replace(user_context, 0, str, length);
terminate(user_context, length);
}

void StringStorage::append(void *user_context, const char *str, size_t length) {
if (StringUtils::is_empty(str)) { return; }
if (length == 0) { length = strlen(str); }
if (StringUtils::is_empty(str)) {
return;
}
if (length == 0) {
length = strlen(str);
}
const size_t old_length = StringUtils::count_length(data(), contents.size());
size_t new_length = old_length + length;
reserve(user_context, new_length);
Expand All @@ -206,8 +234,12 @@ void StringStorage::append(void *user_context, char ch) {
}

void StringStorage::prepend(void *user_context, const char *str, size_t length) {
if (StringUtils::is_empty(str)) { return; }
if (length == 0) { length = strlen(str); }
if (StringUtils::is_empty(str)) {
return;
}
if (length == 0) {
length = strlen(str);
}
const size_t old_length = StringUtils::count_length(data(), contents.size());
size_t new_length = old_length + length;
reserve(user_context, new_length);
Expand Down
Loading