diff --git a/src/Expr.h b/src/Expr.h index 5942c1f3fa..7662bac81d 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -179,19 +179,18 @@ public: void MarkParen() { paren = true; } bool IsParen() const { return paren; } -#undef ACCESSORS -#define ACCESSORS(ctype) \ +#define ZEEK_EXPR_ACCESSOR_DECLS(ctype) \ const ctype* As ## ctype () const; \ ctype* As ## ctype (); \ IntrusivePtr As ## ctype ## Ptr (); - ACCESSORS(ListExpr) - ACCESSORS(NameExpr) - ACCESSORS(ConstExpr) - ACCESSORS(CallExpr) - ACCESSORS(AssignExpr) - ACCESSORS(IndexExpr) - ACCESSORS(EventExpr) + ZEEK_EXPR_ACCESSOR_DECLS(ListExpr) + ZEEK_EXPR_ACCESSOR_DECLS(NameExpr) + ZEEK_EXPR_ACCESSOR_DECLS(ConstExpr) + ZEEK_EXPR_ACCESSOR_DECLS(CallExpr) + ZEEK_EXPR_ACCESSOR_DECLS(AssignExpr) + ZEEK_EXPR_ACCESSOR_DECLS(IndexExpr) + ZEEK_EXPR_ACCESSOR_DECLS(EventExpr) void Describe(ODesc* d) const override final; @@ -770,7 +769,7 @@ public: TableConstructorExpr(ListExprPtr constructor_list, std::unique_ptr> attrs, TypePtr arg_type = nullptr, - AttributesPtr arg_attrs = nullptr); + AttributesPtr arg_attrs = nullptr); [[deprecated("Remove in v4.1. Use GetAttrs().")]] Attributes* Attrs() { return attrs.get(); } diff --git a/src/Frame.h b/src/Frame.h index ae5fa83c94..c894655f8b 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -105,7 +105,7 @@ public: * @param incr Amount by which to increase the frame offset. * Use a negative value to shrink the offset. */ - void IncreaseOffset(int incr) { current_offset += incr; } + void IncreaseOffset(int incr) { current_offset += incr; } /** * Resets all of the indexes from [*startIdx, frame_size) in @@ -325,7 +325,8 @@ private: /** Associates ID's offsets with values. */ std::unique_ptr frame; - /** The offset we're currently using for references into the frame. + /** + * The offset we're currently using for references into the frame. * This is how we support inlined functions without having to * alter the offsets associated with their local variables. */ diff --git a/src/Func.h b/src/Func.h index e58b8b5ccf..2775819181 100644 --- a/src/Func.h +++ b/src/Func.h @@ -63,17 +63,11 @@ public: ~Func() override; - zeek::detail::ScriptFunc* AsScriptFunc() - { - return GetKind() == SCRIPT_FUNC ? - (zeek::detail::ScriptFunc*) this : nullptr; - } + zeek::detail::ScriptFunc* AsScriptFunc() + { return GetKind() == SCRIPT_FUNC ? (detail::ScriptFunc*) this : nullptr; } - const zeek::detail::ScriptFunc* AsScriptFunc() const - { - return GetKind() == SCRIPT_FUNC ? - (zeek::detail::ScriptFunc*) this : nullptr; - } + const zeek::detail::ScriptFunc* AsScriptFunc() const + { return GetKind() == SCRIPT_FUNC ? (detail::ScriptFunc*) this : nullptr; } virtual bool IsPure() const = 0; FunctionFlavor Flavor() const { return GetType()->Flavor(); } diff --git a/src/Scope.cc b/src/Scope.cc index 249e5e6557..a533da113e 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -47,20 +47,6 @@ const IDPtr& Scope::Find(std::string_view name) const return ID::nil; } -IDPtr Scope::Remove(std::string_view name) - { - auto entry = local.find(name); - - if ( entry != local.end() ) - { - auto id = std::move(entry->second); - local.erase(entry); - return id; - } - - return nullptr; - } - IDPtr Scope::GenerateTemporary(const char* name) { return make_intrusive(name, SCOPE_FUNCTION, false); diff --git a/src/Scope.h b/src/Scope.h index 7f6a6a4702..9587ba6626 100644 --- a/src/Scope.h +++ b/src/Scope.h @@ -50,9 +50,6 @@ public: ordered_vars.push_back(std::forward(id)); } - IDPtr Remove(std::string_view name); - [[deprecated("Remove in v4.1 as an unused API call.")]] - [[deprecated("Remove in v4.1. Use GetID().")]] ID* ScopeID() const { return scope_id.get(); } diff --git a/src/script_opt/Inline.cc b/src/script_opt/Inline.cc index 7b05bd7cb1..fb4dc24eb1 100644 --- a/src/script_opt/Inline.cc +++ b/src/script_opt/Inline.cc @@ -171,7 +171,7 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr c) if ( ! func->IsGlobal() ) return std::move(c); - auto func_v = func->GetVal(); + const auto& func_v = func->GetVal(); if ( ! func_v ) return std::move(c); diff --git a/src/script_opt/ProfileFunc.cc b/src/script_opt/ProfileFunc.cc index 7ea0667703..d6f37c085d 100644 --- a/src/script_opt/ProfileFunc.cc +++ b/src/script_opt/ProfileFunc.cc @@ -20,7 +20,7 @@ TraversalCode ProfileFunc::PreStmt(const Stmt* s) if ( tag == STMT_INIT ) { - for ( auto id : s->AsInitStmt()->Inits() ) + for ( const auto& id : s->AsInitStmt()->Inits() ) inits.insert(id.get()); // Don't recurse into these, as we don't want to consider diff --git a/src/script_opt/ScriptOpt.h b/src/script_opt/ScriptOpt.h index 0fb6deaf24..5d41feb8d0 100644 --- a/src/script_opt/ScriptOpt.h +++ b/src/script_opt/ScriptOpt.h @@ -34,9 +34,9 @@ class FuncInfo { public: FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body) { - func = _func; - scope = _scope; - body = _body; + func = std::move(_func); + scope = std::move(_scope); + body = std::move(_body); } ~FuncInfo(); diff --git a/src/script_opt/Stmt.cc b/src/script_opt/Stmt.cc index 07f3cbbddd..d24f7ba9c9 100644 --- a/src/script_opt/Stmt.cc +++ b/src/script_opt/Stmt.cc @@ -159,8 +159,8 @@ StmtPtr ReturnStmt::Duplicate() ReturnStmt::ReturnStmt(ExprPtr arg_e, bool ignored) : ExprStmt(STMT_RETURN, std::move(arg_e)) - { - } + { + } StmtPtr StmtList::Duplicate()