Commit graph

64 commits

Author SHA1 Message Date
Tim Wojtulewicz
2abb7830a5 Fix clang-tidy bugprone-use-after-move warnings in headers 2025-06-23 08:35:24 -07:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Tim Wojtulewicz
5a3abbe364 Revert "Merge remote-tracking branch 'origin/topic/vern/at-if-analyze'"
This reverts commit 4e797ddbbc, reversing
changes made to 3ac28ba5a2.
2023-05-31 09:20:33 +02:00
Vern Paxson
9aff0287f0 RemoveGlobal() method for Scope class + simplifying interfaces 2023-05-19 12:41:32 -07:00
Arne Welzel
bb80d80218 Stmt: Error on deprecated when/local usage
This has been around since Zeek v4.1, so it was warned about in Zeek 5.0
LTS and we could've removed it with 5.1.

Also removed merge_top_scope() from the zeek::detail namespace, it's
unused now.

Updated the when-aggregates test somehow. I'm not quite sure what had
been tested there :-/
2023-03-20 21:35:53 +01:00
Vern Paxson
71d1022269 fix for deprecated when's where the inner frame is larger than the outer frame 2022-09-25 19:55:47 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Vern Paxson
efd03d41f8 convert scopes to be managed using IntrusivePtr's 2021-05-30 17:20:29 -07:00
Tim Wojtulewicz
4ad08172d0 Remove obsolete ZEEK_FORWARD_DECLARE_NAMESPACED macros 2021-02-24 14:35:44 -07:00
Tim Wojtulewicz
0618be792f Remove all of the random single-file deprecations
These are the changes that don't require a ton of changes to other files outside
of the original removal.
2021-01-27 10:52:40 -07:00
Jon Siwek
481d989495 Superficial changes to script-opt related code
* Rename overly generic ACCESSORS macro with ZEEK_ prefix
* A few places where whitespace was noticeably wrong/distracting
* Minor/obvious reference/move semantics improvements suggested by linter
* Remove unused detail::Scope::Remove(), no need for deprecation
2020-12-13 10:33:28 -08:00
Vern Paxson
c42586af2c inlining of Zeek script functions 2020-11-19 16:16:59 -08:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
106a92a9a8 Rename BroList.h to ZeekList.h 2020-08-20 16:11:46 -07:00
Tim Wojtulewicz
4d96b7f1cc Various deprecation fixes, reported by failed Spicy builds
- Add deprecated version of ID::SetType() that takes Type*
- Add deprecated versions of zeek::set_location in the global namespace
- Fix global namespace version of lookup_ID to return ID*
2020-07-15 15:24:19 -07:00
Tim Wojtulewicz
02cef05f93 Rename BroObj to Obj 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
3098dd6fbb Minor cleanup items from PR review 2020-07-02 12:55:21 -07:00
Tim Wojtulewicz
d6f1ea16ac Move Func and associated classes into zeek::detail namespace 2020-06-30 20:51:58 -07:00
Tim Wojtulewicz
937a462e70 Move Frame and Scope to zeek::detail namespace 2020-06-30 20:51:53 -07:00
Tim Wojtulewicz
64332ca22c Move all Val classes to the zeek namespaces 2020-06-30 20:48:09 -07:00
Tim Wojtulewicz
ec9eff0bd5 Use type aliases for IntrusivePtr definitions 2020-06-30 20:37:30 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Jon Siwek
d4f3cad7d1 Merge remote-tracking branch 'origin/topic/timw/266-namespaces'
Merge adjustments:

- Preserved original `base_type_no_ref` argument type as ::TypeTag
- Removed superfluous #pragma guard around deprecated TableVal ctor
- Clarify NEWS regarding MetaHook{Pre,Post} deprecations
- Simplify some `::zeek::` qualifications to just `zeek::`
- Prefixed FORWARD_DECLARE_NAMESPACED macro with ZEEK_

* origin/topic/timw/266-namespaces:
  Disable some deprecation diagnostics for GCC
  Rename BroType to Type
  Update NEWS
  Review cleanup
  Move Type types to zeek namespace
  Move Flare/Pipe from the bro namespace to zeek::detail
  Move Attr to the zeek::detail namespace
  Move Trigger into the zeek::detail namespace
  Move ID to the zeek::detail namespace
  Move Anon.h into zeek::detail namespace
  Mark all of the aliased classes in plugin/Plugin.h deprecated, and fix all of the plugins that were using them
  Move all of the base plugin classes into the zeek::plugin namespace
  Expr: move all classes into zeek::detail
  Stmt: move Stmt classes into zeek::detail namespace
  Add utility macro for creating namespaced aliases for classes
2020-06-11 23:20:51 -07:00
Tim Wojtulewicz
137e416a03 Rename BroType to Type 2020-06-10 14:27:36 -07:00
Tim Wojtulewicz
ed13972924 Move Type types to zeek namespace 2020-06-09 17:20:45 -07:00
Tim Wojtulewicz
60ed29c3b6 Move Attr to the zeek::detail namespace 2020-06-03 15:16:19 -07:00
Tim Wojtulewicz
0d623d003c Move ID to the zeek::detail namespace 2020-06-03 15:16:19 -07:00
Jon Siwek
2cee468eac Change Scope/Func inits from id_list* to vector<IntrusivePtr<ID>> 2020-05-27 17:27:40 -07:00
Jon Siwek
46e23b49fb Change Scope::GenerateTemporary() to return IntrusivePtr 2020-05-27 16:51:25 -07:00
Jon Siwek
a13899c95e Deprecate Scope::ReturnType(), replace with GetReturnType() 2020-05-27 16:38:31 -07:00
Jon Siwek
b0c95e30d0 Deprecate Scope::ScopeID(), replace with GetID() 2020-05-27 16:36:14 -07:00
Jon Siwek
8b6de5852c Switch parsing to use vector<IntrusivePtr<Attr>> from attr_list
This allows improved passing/storing of Attr references to Exprs,
TypeDecl, Scope, etc.
2020-05-26 18:19:29 -07:00
Jon Siwek
86cbab3b7f Change Scope::Find() and Scope::Remove() to use std::string_view 2020-05-14 17:24:21 -07:00
Jon Siwek
0af7f8141b Change lookup_ID() to return a const-reference 2020-05-14 17:24:21 -07:00
Jon Siwek
8f95a2a0bb Deprecate Scope::Lookup(), replace with Scope::Find() 2020-05-14 17:24:21 -07:00
Jon Siwek
b62727a7fa Merge branch 'intrusive_ptr' of https://github.com/MaxKellermann/zeek
* 'intrusive_ptr' of https://github.com/MaxKellermann/zeek: (32 commits)
  Scope: store IntrusivePtr in `local`
  Scope: pass IntrusivePtr to AddInit()
  DNS_Mgr: use class IntrusivePtr
  Scope: use class IntrusivePtr
  Attr: use class IntrusivePtr
  Expr: check_and_promote_expr() returns IntrusivePtr
  Frame: use class IntrusivePtr
  Val: RecordVal::LookupWithDefault() returns IntrusivePtr
  Type: RecordType::FieldDefault() returns IntrusivePtr
  Val: TableVal::Delete() returns IntrusivePtr
  Type: base_type() returns IntrusivePtr
  Type: init_type() returns IntrusivePtr
  Type: merge_types() returns IntrusivePtr
  Type: use class IntrusivePtr in VectorType
  Type: use class IntrusivePtr in EnumType
  Type: use class IntrusivePtr in FileType
  Type: use class IntrusivePtr in TypeDecl
  Type: make TypeDecl `final` and the dtor non-`virtual`
  Type: use class IntrusivePtr in TypeType
  Type: use class IntrusivePtr in FuncType
  ...
2020-03-17 22:51:46 -07:00
Max Kellermann
785ff57d11 Scope: store IntrusivePtr in local 2020-03-06 13:03:41 +01:00
Max Kellermann
6e0d331267 Scope: pass IntrusivePtr to AddInit() 2020-03-06 13:02:15 +01:00
Max Kellermann
dc518c0fb4 Scope: use class IntrusivePtr 2020-03-06 13:00:45 +01:00
Jon Siwek
cf196bb148 Merge branch 'leaks' of https://github.com/MaxKellermann/zeek
Only one instance of base_type() getting a NewRef instead of AdoptRef
fixed in merge.  All other changes are superficial formatting and
factoring.

* 'leaks' of https://github.com/MaxKellermann/zeek: (22 commits)
  Stmt: use class IntrusivePtr
  Stmt: remove unused default constructors and `friend` declarations
  Val: remove unimplemented prototype recover_val()
  Val: cast_value_to_type() returns IntrusivePtr
  Val: use IntrusivePtr in check_and_promote()
  Val: use nullptr instead of 0
  zeekygen: use class IntrusivePtr
  ID: use class IntrusivePtr
  Expr: use class IntrusivePtr
  Var: copy Location to stack, to fix use-after-free crash bug
  Scope: lookup_ID() and install_ID() return IntrusivePtr<ID>
  Scope: delete duplicate locals
  EventRegistry: automatically delete EventHandlers
  main: destroy event_registry after iosource_mgr
  zeekygen/IdentifierInfo: delete duplicate fields
  main: free the global scope in terminate_bro()
  Scope: pop_scope() returns IntrusivePtr<>
  Scope: unref all inits in destructor
  Var: pass IntrusivePtr to add_global(), add_local() etc.
  plugin/ComponentManager: hold a reference to the EnumType
  ...
2020-02-28 00:48:20 -08:00
Max Kellermann
528cf11a5c Scope: lookup_ID() and install_ID() return IntrusivePtr<ID>
This fixes several memory leaks and double free bugs.
2020-02-27 12:02:55 +01:00
Max Kellermann
cbb6f09726 Scope: delete duplicate locals 2020-02-27 12:02:55 +01:00
Max Kellermann
875bfc09a2 Scope: pop_scope() returns IntrusivePtr<>
Make sure unused scopes are freed to fix memory leaks.

The comment inside pop_scope() is now obsolete and I deleted it,
because this commit implements the real solution.

Note that this requires us to add a reference to the
push_existing_scope() call in dbg_eval_expr(), because it never owned
the reference.
2020-02-27 12:02:55 +01:00
Max Kellermann
f1908b6212 Scope: convert Scope::Lookup() and others to template
Allows passing rvalue references which eliminates unnecessary
std::string copies.

This speeds up Zeek startup by 1-2%.
2020-02-07 10:56:14 +01:00
Max Kellermann
f8e9cc0fc5 Scope: Vars() returns const reference
No caller wants to modify the container.
2020-02-07 10:56:14 +01:00
Max Kellermann
0db61f3094 include cleanup
The Zeek code base has very inconsistent #includes.  Many sources
included a few headers, and those headers included other headers, and
in the end, nearly everything is included everywhere, so missing
#includes were never noticed.  Another side effect was a lot of header
bloat which slows down the build.

First step to fix it: in each source file, its own header should be
included first to verify that each header's includes are correct, and
none is missing.

After adding the missing #includes, I replaced lots of #includes
inside headers with class forward declarations.  In most headers,
object pointers are never referenced, so declaring the function
prototypes with forward-declared classes is just fine.

This patch speeds up the build by 19%, because each compilation unit
gets smaller.  Here are the "time" numbers for a fresh build (with a
warm page cache but without ccache):

Before this patch:

 3144.94user 161.63system 3:02.87elapsed 1808%CPU (0avgtext+0avgdata 2168608maxresident)k
 760inputs+12008400outputs (1511major+57747204minor)pagefaults 0swaps

After this patch:

 2565.17user 141.83system 2:25.46elapsed 1860%CPU (0avgtext+0avgdata 1489076maxresident)k
 72576inputs+9130920outputs (1667major+49400430minor)pagefaults 0swaps
2020-02-04 20:51:02 +01:00
Jon Siwek
62161dcc34 Remove "using namespace std" from header files 2019-10-30 12:26:10 -07:00
Dominik Charousset
c1f3fe7829 Switch from header guards to pragma once 2019-09-17 14:10:30 +02:00
Tim Wojtulewicz
a3deb0446c Scope: remove uses of PDict 2019-08-13 19:57:42 -07:00