Skip to content

Commit

Permalink
Merge branch 'topic/bbannier/uninitialized-values'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Jan 8, 2025
2 parents dc31aee + 7a5f9d6 commit 789b223
Show file tree
Hide file tree
Showing 68 changed files with 105 additions and 132 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
stages: ["pre-commit"]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v19.1.4'
rev: 'v19.1.6'
hooks:
- id: clang-format
types_or: ["c", "c++"]
Expand Down Expand Up @@ -86,14 +86,14 @@ repos:
stages: ["pre-commit"]

- repo: https://github.com/crate-ci/typos
rev: v1.27.2
rev: v1.29.4
hooks:
- id: typos
exclude: 'tests/.*/regexp/.*|.clang-tidy'

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.2
rev: v0.8.6
hooks:
- id: ruff
args: [ --fix ]
Expand Down
20 changes: 19 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
1.13.0-dev.43 | 2025-01-08 09:39:45 +0100

* Drop unused includes. (Benjamin Bannier, Corelight)

* Move temporaries instead of creating copies. (Benjamin Bannier, Corelight)

* Avoid copies in implementation of trivial getters. (Benjamin Bannier, Corelight)

* Avoid copy when constructing node properties. (Benjamin Bannier, Corelight)

* Bump pre-commit hooks. (Benjamin Bannier, Corelight)

* Always initialize enum member to reasonable default. (Benjamin Bannier, Corelight)

* Always initialize pointer members. (Benjamin Bannier, Corelight)

* Fix use-after-move. (Benjamin Bannier, Corelight)

1.13.0-dev.34 | 2025-01-08 09:39:11 +0100

* Bump `3rdparty/filesystem` to pick up fixes for clang-tidy-19. (Benjamin Bannier, Corelight)
Expand Down Expand Up @@ -1927,7 +1945,7 @@

A chain now retains one previously used but no longer needed chunk for
reuse, so that we can avoid constant cycles of creating/destructing
chunks (and their paylaod memory) in the common case of a parser
chunks (and their payload memory) in the common case of a parser
consuming full chunks without yielding. The caching is also geared
towards owning/non-owning semantics staying consistent across
subsequent append operations.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.13.0-dev.34
1.13.0-dev.43
4 changes: 2 additions & 2 deletions hilti/runtime/include/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class Exception : public std::runtime_error {
~Exception() override;

/** Returns the message associated with the exception. */
auto description() const { return _description; }
const auto& description() const { return _description; }

/** Returns the location associated with the exception. */
auto location() const { return _location; }
const auto& location() const { return _location; }

/**
* Returns a stack backtrace captured at the time the exception was
Expand Down
4 changes: 2 additions & 2 deletions hilti/runtime/include/type-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class Value {
throw InvalidValue("type info value expired");
}

const void* _ptr;
const TypeInfo* _ti;
const void* _ptr = nullptr;
const TypeInfo* _ti = nullptr;
std::weak_ptr<bool> _parent_handle;
};

Expand Down
2 changes: 1 addition & 1 deletion hilti/toolchain/include/ast/attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Attribute : public Node {

node::Properties properties() const final {
auto p = node::Properties{{"tag", std::string{attributeName()}}};
return Node::properties() + p;
return Node::properties() + std::move(p);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/rt/types/address.h>
Expand All @@ -22,7 +21,7 @@ class Address : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", to_string(_value)}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, hilti::rt::Address v, const Meta& meta = {}) {
Expand Down
9 changes: 2 additions & 7 deletions hilti/toolchain/include/ast/ctors/bitfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#pragma once

#include <algorithm>
#include <memory>
#include <utility>
#include <vector>

Expand All @@ -27,11 +25,8 @@ class BitRange final : public Node {
auto expression() const { return child<Expression>(0); }

node::Properties properties() const final {
auto p = node::Properties{
{"id", _id},
};

return Node::properties() + p;
auto p = node::Properties{{"id", _id}};
return Node::properties() + std::move(p);
}

static auto create(ASTContext* ctx, const ID& id, Expression* expr, Meta meta = Meta()) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/ast/ctor.h>
Expand All @@ -19,7 +18,7 @@ class Bool : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, bool v, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <string>
#include <utility>

Expand All @@ -20,7 +19,7 @@ class Bytes : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, std::string value, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <string>
#include <utility>

Expand All @@ -20,7 +19,7 @@ class Error : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, std::string v, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/ast/ctor.h>
Expand All @@ -22,7 +21,7 @@ class IntegerBase : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}, {"width", _width}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

protected:
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/rt/types/interval.h>
Expand All @@ -21,7 +20,7 @@ class Interval : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", to_string(_value)}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, hilti::rt::Interval v, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/rt/types/network.h>
Expand All @@ -21,7 +20,7 @@ class Network : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", to_string(_value)}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, hilti::rt::Network v, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/rt/types/port.h>
Expand All @@ -21,7 +20,7 @@ class Port : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", to_string(_value)}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, hilti::rt::Port v, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/real.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/ast/ctor.h>
Expand All @@ -19,7 +18,7 @@ class Real : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, double v, const Meta& meta = {}) {
Expand Down
2 changes: 1 addition & 1 deletion hilti/toolchain/include/ast/ctors/regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RegExp : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", util::join(_value, " | ")}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, std::vector<std::string> v, AttributeSet* attrs, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <string>
#include <utility>

Expand All @@ -20,7 +19,7 @@ class Stream : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, std::string value, const Meta& meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <string>
#include <utility>

Expand All @@ -21,7 +20,7 @@ class String : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", _value}, {"is_literal", _is_literal}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, std::string value, bool is_literal, const Meta& meta = {}) {
Expand Down
4 changes: 2 additions & 2 deletions hilti/toolchain/include/ast/ctors/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Field final : public Node {

node::Properties properties() const override {
auto p = node::Properties{{"id", _id}};
return Node::properties() + p;
return Node::properties() + std::move(p);
}

static auto create(ASTContext* ctx, ID id, Expression* expr, Meta meta = {}) {
Expand Down Expand Up @@ -66,7 +66,7 @@ class Struct : public Ctor, public node::WithUniqueID {
/** Implements the node interface. */
node::Properties properties() const override {
auto p = node::Properties{};
return Ctor::properties() + node::WithUniqueID::properties() + p;
return Ctor::properties() + node::WithUniqueID::properties() + std::move(p);
}

static auto create(ASTContext* ctx, const struct_::Fields& fields, QualifiedType* t, Meta meta = {}) {
Expand Down
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ctors/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <utility>

#include <hilti/rt/types/time.h>
Expand All @@ -21,7 +20,7 @@ class Time : public Ctor {

node::Properties properties() const final {
auto p = node::Properties{{"value", to_string(_value)}};
return Ctor::properties() + p;
return Ctor::properties() + std::move(p);
}

static auto create(ASTContext* ctx, hilti::rt::Time v, const Meta& meta = {}) {
Expand Down
2 changes: 1 addition & 1 deletion hilti/toolchain/include/ast/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Declaration : public Node, public node::WithDocString {
{"fqid", _fqid},
{"canonical-id", _canonical_id}};

return Node::properties() + p;
return Node::properties() + std::move(p);
}

Declaration(const Declaration& other) : Node(other), node::WithDocString(other) {
Expand Down
9 changes: 5 additions & 4 deletions hilti/toolchain/include/ast/declarations/imported-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#pragma once

#include <memory>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -33,7 +32,7 @@ class ImportedModule : public Declaration {
const auto& searchDirectories() const { return _dirs; }
const auto& parseExtension() const { return _parse_extension; }

auto uid() const { return _uid; }
const auto& uid() const { return _uid; }
void setUID(declaration::module::UID uid) { _uid = std::move(uid); }
void clearUID() { _uid.reset(); }
void setSearchDirectories(std::vector<hilti::rt::filesystem::path> dirs) { _dirs = std::move(dirs); }
Expand All @@ -48,7 +47,7 @@ class ImportedModule : public Declaration {
{"dirs", util::join(_dirs)},
{"uid", _uid ? _uid->str() : std::string("<n/a>")},
};
return Declaration::properties() + p;
return Declaration::properties() + std::move(p);
}

static auto create(ASTContext* ctx, ID id, const std::string& parse_extension, Meta meta = {}) {
Expand All @@ -62,7 +61,9 @@ class ImportedModule : public Declaration {
}

static auto create(ASTContext* ctx, ID id, hilti::rt::filesystem::path path, Meta meta = {}) {
return ctx->make<ImportedModule>(ctx, std::move(id), std::move(path), path.extension(), ID{}, std::move(meta));
auto extension = path.extension();
return ctx->make<ImportedModule>(ctx, std::move(id), std::move(path), std::move(extension), ID{},
std::move(meta));
}

protected:
Expand Down
Loading

0 comments on commit 789b223

Please sign in to comment.