mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Firstly, this change reworks how inter-process races are resolved. Moreover some responsability reorganization has led to merging `TrapArena` and `TrapOutput` again into a `TrapDomain` class. A `TargetFile` class is introduced, that is successfully created only for the first process that starts processing a given trap output file. From then on `TargetFile` simply wraps around `<<` stream operations, dumping them to a temporary file. When `TargetFile::commit` is called, the temporary file is moved on to the actual target trap file. Processes that lose the race can now just ignore the unneeded extraction and go on, while previously all processes would carry out all extractions overwriting each other at the end. Some of the file system logic contained in `SwiftExtractor.cpp` has been moved to this class, and two TODOs are solved: * introducing a better inter process file collision avoidance strategy * better error handling for trap output operations: if unable to write to the trap file (or carry out other basic file operations), we just abort. The changes to `ExprVisitor` and `StmtVisitor` are due to wanting to hide the raw `TrapDomain::createLabel` from them, and bring more funcionality under the generic caching/dispatching mechanism.
43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "swift/extractor/visitors/VisitorBase.h"
|
|
#include "swift/extractor/trap/generated/stmt/TrapClasses.h"
|
|
|
|
namespace codeql {
|
|
|
|
class StmtVisitor : public AstVisitorBase<StmtVisitor> {
|
|
public:
|
|
using AstVisitorBase<StmtVisitor>::AstVisitorBase;
|
|
|
|
void visitLabeledStmt(swift::LabeledStmt* stmt);
|
|
codeql::StmtCondition translateStmtCondition(const swift::StmtCondition& cond);
|
|
codeql::ConditionElement translateStmtConditionElement(
|
|
const swift::StmtConditionElement& element);
|
|
void visitLabeledConditionalStmt(swift::LabeledConditionalStmt* stmt);
|
|
void visitCaseLabelItem(swift::CaseLabelItem* labelItem);
|
|
void visitBraceStmt(swift::BraceStmt* stmt);
|
|
void visitReturnStmt(swift::ReturnStmt* stmt);
|
|
void visitForEachStmt(swift::ForEachStmt* stmt);
|
|
void visitIfStmt(swift::IfStmt* stmt);
|
|
void visitBreakStmt(swift::BreakStmt* stmt);
|
|
void visitContinueStmt(swift::ContinueStmt* stmt);
|
|
void visitWhileStmt(swift::WhileStmt* stmt);
|
|
void visitRepeatWhileStmt(swift::RepeatWhileStmt* stmt);
|
|
void visitDoCatchStmt(swift::DoCatchStmt* stmt);
|
|
void visitCaseStmt(swift::CaseStmt* stmt);
|
|
void visitGuardStmt(swift::GuardStmt* stmt);
|
|
void visitThrowStmt(swift::ThrowStmt* stmt);
|
|
void visitDeferStmt(swift::DeferStmt* stmt);
|
|
void visitDoStmt(swift::DoStmt* stmt);
|
|
void visitSwitchStmt(swift::SwitchStmt* stmt);
|
|
void visitFallthroughStmt(swift::FallthroughStmt* stmt);
|
|
void visitYieldStmt(swift::YieldStmt* stmt);
|
|
|
|
private:
|
|
void emitLabeledStmt(const swift::LabeledStmt* stmt, TrapLabel<LabeledStmtTag> label);
|
|
void emitLabeledConditionalStmt(swift::LabeledConditionalStmt* stmt,
|
|
TrapLabel<LabeledConditionalStmtTag> label);
|
|
};
|
|
|
|
} // namespace codeql
|