Skip to content

Commit

Permalink
Fix build warnings, add docs for new warning
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed Feb 11, 2025
1 parent 6648181 commit 76aeb51
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
6 changes: 3 additions & 3 deletions include/slang/analysis/AnalysisManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class AnalyzedScope;
class SLANG_EXPORT AnalyzedInstance {
public:
/// The symbol that was analyzed.
const ast::InstanceSymbol& symbol;
not_null<const ast::InstanceSymbol*> symbol;

/// Constructs a new AnalyzedInstance object.
AnalyzedInstance(AnalysisManager& analysisManager, const ast::InstanceSymbol& symbol) :
symbol(symbol), analysisManager(analysisManager) {}
symbol(&symbol), analysisManager(&analysisManager) {}

/// Returns the analyzed body of the instance, if available.
/// If the body has not been analyzed yet, this will return nullptr.
const AnalyzedScope* getBody() const;

private:
AnalysisManager& analysisManager;
not_null<AnalysisManager*> analysisManager;
};

/// Represents an analyzed AST scope.
Expand Down
2 changes: 1 addition & 1 deletion include/slang/analysis/AnalyzedProcedure.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AnalysisManager;

class SLANG_EXPORT AnalyzedProcedure {
public:
const ast::ProceduralBlockSymbol& procedureSymbol;
not_null<const ast::ProceduralBlockSymbol*> procedureSymbol;

AnalyzedProcedure(AnalysisManager& analysisManager, AnalysisContext& context,
const ast::ProceduralBlockSymbol& symbol);
Expand Down
4 changes: 2 additions & 2 deletions include/slang/analysis/DataFlowAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SLANG_EXPORT DataFlowAnalysis : public AbstractFlowAnalysis<DataFlowAnalys

owner.visit(expr.value());

auto guard = owner.saveLValueFlag();
[[maybe_unused]] auto guard = owner.saveLValueFlag();
owner.visit(expr.selector());
}

Expand All @@ -121,7 +121,7 @@ class SLANG_EXPORT DataFlowAnalysis : public AbstractFlowAnalysis<DataFlowAnalys

owner.visit(expr.value());

auto guard = owner.saveLValueFlag();
[[maybe_unused]] auto guard = owner.saveLValueFlag();
owner.visit(expr.left());
owner.visit(expr.right());
}
Expand Down
13 changes: 13 additions & 0 deletions scripts/warning_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1624,3 +1624,16 @@ module m;
end
endmodule
```

-Winferred-latch
A signal assigned in an always_comb procedure is not assigned on all control
paths and so infers a latch instead of combinatorial logic.
@options --disable-analysis=false
```
module m(input a, output b);
always_comb begin
if (a)
b = 0;
end
endmodule
```
2 changes: 1 addition & 1 deletion source/analysis/AnalysisManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace slang::analysis {
using namespace ast;

const AnalyzedScope* AnalyzedInstance::getBody() const {
return analysisManager.getAnalyzedScope(symbol.body);
return analysisManager->getAnalyzedScope(symbol->body);
}

AnalysisManager::AnalysisManager(uint32_t numThreads) : threadPool(numThreads) {
Expand Down
2 changes: 1 addition & 1 deletion source/analysis/AnalyzedProcedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static const TimingControl* inferClock(const ProceduralBlockSymbol& procedureSym

AnalyzedProcedure::AnalyzedProcedure(AnalysisManager&, AnalysisContext& context,
const ProceduralBlockSymbol& procedure) :
procedureSymbol(procedure) {
procedureSymbol(&procedure) {

DataFlowAnalysis dfa(context, procedure);
dfa.run(procedure.getBody());
Expand Down

0 comments on commit 76aeb51

Please sign in to comment.