mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -2,13 +2,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "zeek/Expr.h"
|
||||
|
||||
namespace zeek::detail {
|
||||
namespace zeek::detail
|
||||
{
|
||||
|
||||
// UseDefs track which variables (identifiers) are used at or subsequent
|
||||
// to a given (reduced) Statement. They allow us to determine unproductive
|
||||
|
@ -19,33 +20,36 @@ namespace zeek::detail {
|
|||
class UseDefSet;
|
||||
typedef std::shared_ptr<UseDefSet> UDs;
|
||||
|
||||
class UseDefSet {
|
||||
class UseDefSet
|
||||
{
|
||||
public:
|
||||
UseDefSet() { }
|
||||
UseDefSet(const UDs& uds) { Replicate(uds); }
|
||||
UseDefSet() { }
|
||||
UseDefSet(const UDs& uds) { Replicate(uds); }
|
||||
|
||||
void Replicate(const UDs& from)
|
||||
{ use_defs = from->use_defs; }
|
||||
void Replicate(const UDs& from) { use_defs = from->use_defs; }
|
||||
|
||||
bool HasID(const ID* id)
|
||||
{ return use_defs.find(id) != use_defs.end(); }
|
||||
bool HasID(const ID* id) { return use_defs.find(id) != use_defs.end(); }
|
||||
|
||||
void Add(const ID* id) { use_defs.insert(id); }
|
||||
void Remove(const ID* id) { use_defs.erase(id); }
|
||||
void Add(const ID* id) { use_defs.insert(id); }
|
||||
void Remove(const ID* id) { use_defs.erase(id); }
|
||||
|
||||
const std::unordered_set<const ID*>& IterateOver() const
|
||||
{ return use_defs; }
|
||||
const std::unordered_set<const ID*>& IterateOver() const { return use_defs; }
|
||||
|
||||
void Dump() const;
|
||||
void DumpNL() const { Dump(); printf("\n"); }
|
||||
void DumpNL() const
|
||||
{
|
||||
Dump();
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unordered_set<const ID*> use_defs;
|
||||
};
|
||||
};
|
||||
|
||||
class Reducer;
|
||||
|
||||
class UseDefs {
|
||||
class UseDefs
|
||||
{
|
||||
public:
|
||||
UseDefs(StmtPtr body, std::shared_ptr<Reducer> rc);
|
||||
|
||||
|
@ -55,14 +59,12 @@ public:
|
|||
void Analyze();
|
||||
|
||||
// True if we've computed use-defs for the given statement.
|
||||
bool HasUsage(const Stmt* s) const
|
||||
{ return use_defs_map.find(s) != use_defs_map.end(); }
|
||||
bool HasUsage(const StmtPtr& s) const
|
||||
{ return HasUsage(s.get()); }
|
||||
bool HasUsage(const Stmt* s) const { return use_defs_map.find(s) != use_defs_map.end(); }
|
||||
bool HasUsage(const StmtPtr& s) const { return HasUsage(s.get()); }
|
||||
|
||||
// Returns the use-defs for the given statement.
|
||||
UDs GetUsage(const Stmt* s) const { return FindUsage(s); }
|
||||
UDs GetUsage(const StmtPtr& s) const { return FindUsage(s.get()); }
|
||||
UDs GetUsage(const Stmt* s) const { return FindUsage(s); }
|
||||
UDs GetUsage(const StmtPtr& s) const { return FindUsage(s.get()); }
|
||||
|
||||
// Removes assignments corresponding to unused temporaries.
|
||||
// In the process, reports on locals that are assigned
|
||||
|
@ -96,14 +98,11 @@ private:
|
|||
// second_pass is true when we revisit a set of statements
|
||||
// to propagate additional UDs generated by loop confluence.
|
||||
// If true, it prevents some redundant bookkeeping from occurring.
|
||||
UDs PropagateUDs(const StmtPtr& s, UDs succ_UDs,
|
||||
const StmtPtr& succ_stmt, bool second_pass)
|
||||
UDs PropagateUDs(const StmtPtr& s, UDs succ_UDs, const StmtPtr& succ_stmt, bool second_pass)
|
||||
{
|
||||
return PropagateUDs(s.get(), std::move(succ_UDs), succ_stmt.get(),
|
||||
second_pass);
|
||||
return PropagateUDs(s.get(), std::move(succ_UDs), succ_stmt.get(), second_pass);
|
||||
}
|
||||
UDs PropagateUDs(const Stmt* s, UDs succ_UDs,
|
||||
const Stmt* succ_stmt, bool second_pass);
|
||||
UDs PropagateUDs(const Stmt* s, UDs succ_UDs, const Stmt* succ_stmt, bool second_pass);
|
||||
|
||||
UDs FindUsage(const Stmt* s) const;
|
||||
UDs FindSuccUsage(const Stmt* s) const;
|
||||
|
@ -134,8 +133,7 @@ private:
|
|||
void UpdateUDs(const Stmt* s, const UDs& uds);
|
||||
|
||||
// Returns a new use-def corresponding to the union of 2 or 3 UDs.
|
||||
UDs UD_Union(const UDs& u1, const UDs& u2,
|
||||
const UDs& u3 = nullptr) const;
|
||||
UDs UD_Union(const UDs& u1, const UDs& u2, const UDs& u3 = nullptr) const;
|
||||
|
||||
// Associate a (shallow) copy of the given UDs with the given
|
||||
// statement.
|
||||
|
@ -149,7 +147,6 @@ private:
|
|||
// The given statement takes ownership of the given UDs.
|
||||
UDs CreateUDs(const Stmt* s, UDs uds);
|
||||
|
||||
|
||||
// Maps each statement to its associated use-def identifiers
|
||||
// (which could be nil).
|
||||
std::unordered_map<const Stmt*, UDs> use_defs_map;
|
||||
|
@ -176,6 +173,6 @@ private:
|
|||
|
||||
StmtPtr body;
|
||||
std::shared_ptr<Reducer> rc;
|
||||
};
|
||||
};
|
||||
|
||||
} // zeek::detail
|
||||
} // zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue