mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Insert contents of #included script-opt files directly
Otherwise there is a functional problem caused by using #include to insert the disconnected source code: language server/analysis tools, like clangd, may get confused by those files and report everything in them as an error.
This commit is contained in:
parent
fa418cb179
commit
a0552f9771
10 changed files with 98 additions and 158 deletions
|
@ -81,7 +81,37 @@ public:
|
|||
|
||||
virtual TraversalCode Traverse(TraversalCallback* cb) const = 0;
|
||||
|
||||
#include "zeek/script_opt/StmtOpt-Public.h"
|
||||
// Returns a duplicate of the statement.
|
||||
virtual StmtPtr Duplicate() = 0;
|
||||
|
||||
// Recursively traverses the AST to inline eligible function calls.
|
||||
virtual void Inline(Inliner* inl) { }
|
||||
|
||||
// Access to the original statement from which this one is derived,
|
||||
// or this one if we don't have an original. Returns a bare pointer
|
||||
// rather than a StmtPtr to emphasize that the access is read-only.
|
||||
const Stmt* Original() const
|
||||
{ return original ? original->Original() : this; }
|
||||
|
||||
// Designate the given Stmt node as the original for this one.
|
||||
void SetOriginal(StmtPtr _orig)
|
||||
{
|
||||
if ( ! original )
|
||||
original = std::move(_orig);
|
||||
}
|
||||
|
||||
// A convenience function for taking a newly-created Stmt,
|
||||
// making it point to us as the successor, and returning it.
|
||||
//
|
||||
// Takes a Stmt* rather than a StmtPtr to de-clutter the calling
|
||||
// code, which is always passing in "new XyzStmt(...)". This
|
||||
// call, as a convenient side effect, transforms that bare pointer
|
||||
// into a StmtPtr.
|
||||
virtual StmtPtr SetSucc(Stmt* succ)
|
||||
{
|
||||
succ->SetOriginal({NewRef{}, this});
|
||||
return {AdoptRef{}, succ};
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit Stmt(StmtTag arg_tag);
|
||||
|
@ -97,7 +127,10 @@ protected:
|
|||
mutable double last_access; // time of last execution
|
||||
mutable uint32_t access_count; // number of executions
|
||||
|
||||
#include "zeek/script_opt/StmtOpt-Private.h"
|
||||
// The original statement from which this statement was
|
||||
// derived, if any. Used as an aid for generating meaningful
|
||||
// and correctly-localized error messages.
|
||||
StmtPtr original = nullptr;
|
||||
};
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue