mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
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.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
|
@ -10,72 +10,66 @@
|
|||
#include "zeek/Func.h"
|
||||
#include "zeek/Scope.h"
|
||||
|
||||
namespace zeek::detail
|
||||
{
|
||||
namespace zeek::detail {
|
||||
|
||||
class FuncInfo;
|
||||
|
||||
class Inliner
|
||||
{
|
||||
class Inliner {
|
||||
public:
|
||||
// First argument is a collection of information about *all* of
|
||||
// the script functions. Second argument states whether to report
|
||||
// recursive functions (of interest as they're not in-lineable).
|
||||
Inliner(std::vector<FuncInfo>& _funcs, bool _report_recursive)
|
||||
: funcs(_funcs), report_recursive(_report_recursive)
|
||||
{
|
||||
Analyze();
|
||||
}
|
||||
// First argument is a collection of information about *all* of
|
||||
// the script functions. Second argument states whether to report
|
||||
// recursive functions (of interest as they're not in-lineable).
|
||||
Inliner(std::vector<FuncInfo>& _funcs, bool _report_recursive)
|
||||
: funcs(_funcs), report_recursive(_report_recursive) {
|
||||
Analyze();
|
||||
}
|
||||
|
||||
// Either returns the original CallExpr if it's not inline-able;
|
||||
// or an InlineExpr if it is; or nil if further inlining should stop.
|
||||
ExprPtr CheckForInlining(CallExprPtr c);
|
||||
// Either returns the original CallExpr if it's not inline-able;
|
||||
// or an InlineExpr if it is; or nil if further inlining should stop.
|
||||
ExprPtr CheckForInlining(CallExprPtr c);
|
||||
|
||||
// True if every instance of the function was inlined.
|
||||
bool WasFullyInlined(const Func* f)
|
||||
{
|
||||
return did_inline.count(f) > 0 && skipped_inlining.count(f) == 0;
|
||||
}
|
||||
// True if every instance of the function was inlined.
|
||||
bool WasFullyInlined(const Func* f) { return did_inline.count(f) > 0 && skipped_inlining.count(f) == 0; }
|
||||
|
||||
protected:
|
||||
// Driver routine that analyzes all of the script functions and
|
||||
// recursively inlines eligible ones.
|
||||
void Analyze();
|
||||
// Driver routine that analyzes all of the script functions and
|
||||
// recursively inlines eligible ones.
|
||||
void Analyze();
|
||||
|
||||
// Recursively inlines any calls associated with the given function.
|
||||
void InlineFunction(FuncInfo* f);
|
||||
// Recursively inlines any calls associated with the given function.
|
||||
void InlineFunction(FuncInfo* f);
|
||||
|
||||
// Information about all of the functions (and events/hooks) in
|
||||
// the full set of scripts.
|
||||
std::vector<FuncInfo>& funcs;
|
||||
// Information about all of the functions (and events/hooks) in
|
||||
// the full set of scripts.
|
||||
std::vector<FuncInfo>& funcs;
|
||||
|
||||
// Functions that we've determined to be suitable for inlining.
|
||||
std::unordered_set<const Func*> inline_ables;
|
||||
// Functions that we've determined to be suitable for inlining.
|
||||
std::unordered_set<const Func*> inline_ables;
|
||||
|
||||
// Functions that we inlined.
|
||||
std::unordered_set<const Func*> did_inline;
|
||||
// Functions that we inlined.
|
||||
std::unordered_set<const Func*> did_inline;
|
||||
|
||||
// Functions that we didn't fully inline, so require separate
|
||||
// compilation.
|
||||
std::unordered_set<const Func*> skipped_inlining;
|
||||
// Functions that we didn't fully inline, so require separate
|
||||
// compilation.
|
||||
std::unordered_set<const Func*> skipped_inlining;
|
||||
|
||||
// As we do inlining for a given function, this tracks the
|
||||
// largest frame size of any inlined function.
|
||||
int max_inlined_frame_size;
|
||||
// As we do inlining for a given function, this tracks the
|
||||
// largest frame size of any inlined function.
|
||||
int max_inlined_frame_size;
|
||||
|
||||
// The size of the frame of the currently-being-inlined function,
|
||||
// prior to increasing it to accommodate inlining.
|
||||
int curr_frame_size;
|
||||
// The size of the frame of the currently-being-inlined function,
|
||||
// prior to increasing it to accommodate inlining.
|
||||
int curr_frame_size;
|
||||
|
||||
// The number of statements and expressions in the function being
|
||||
// inlined. Dynamically updated as the inlining proceeds. Used
|
||||
// to cap inlining complexity.
|
||||
int num_stmts;
|
||||
int num_exprs;
|
||||
// The number of statements and expressions in the function being
|
||||
// inlined. Dynamically updated as the inlining proceeds. Used
|
||||
// to cap inlining complexity.
|
||||
int num_stmts;
|
||||
int num_exprs;
|
||||
|
||||
// Whether to generate a report about functions either directly and
|
||||
// indirectly recursive.
|
||||
bool report_recursive;
|
||||
};
|
||||
// Whether to generate a report about functions either directly and
|
||||
// indirectly recursive.
|
||||
bool report_recursive;
|
||||
};
|
||||
|
||||
} // namespace zeek::detail
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue