Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
- Fixed issue where statements under top-level in-eachs were not correctly tracked.
- Moved storage of reference->symbol mapping to on-demand timing, should significantly speed
up device analysises
- CLI tool DFA now uses default one-indexed line count for reporting warnings on analyzed files.
`--zero-indexed` flag can be set to `true` when executing DFA for using zero-indexed counting if required.

## 0.9.12
- Added 'simics\_util\_vect' as a known provisional (with no DLS semantics)
Expand Down
12 changes: 7 additions & 5 deletions src/dfa/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,15 @@ impl ClientInterface {
}{}
}

pub fn output_errors(&self) {
pub fn output_errors(&self, zero_indexed: bool) {
for (path, diagnostics) in &self.diagnostics {
for diag in diagnostics {
println!("{} line {}: {}",
path.to_str().unwrap(),
diag.line,
diag.desc);
println!(
"{} line {}: {}",
path.to_str().unwrap(),
diag.line + if zero_indexed { 0 } else { 1 },
diag.desc
);
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/dfa/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct Args {
workspaces: Vec<PathBuf>,
compile_info: Option<PathBuf>,
suppress_imports: Option<bool>,
zero_indexed: Option<bool>,
linting_enabled: Option<bool>,
lint_cfg_path: Option<PathBuf>,
test: bool,
Expand Down Expand Up @@ -78,6 +79,11 @@ fn parse_args() -> Args {
.action(ArgAction::Set)
.value_parser(clap::value_parser!(bool))
.required(false))
.arg(Arg::new("zero-indexed").short('z').long("zero-indexed")
.help("Diagnostics reported by the server will be zero-indexed (defaults to false)")
.action(ArgAction::Set)
.value_parser(clap::value_parser!(bool))
.required(false))
.arg(Arg::new("linting-enabled").short('l').long("linting-enabled")
.help("Turns linting on/off (defaults to true)")
.action(ArgAction::Set)
Expand Down Expand Up @@ -106,6 +112,8 @@ fn parse_args() -> Args {
.cloned(),
suppress_imports: args.get_one::<bool>("suppress-imports")
.cloned(),
zero_indexed: args.get_one::<bool>("zero-indexed")
.cloned(),
linting_enabled: args.get_one::<bool>("linting-enabled")
.cloned(),
lint_cfg_path: args.get_one::<PathBuf>("lint-cfg-path")
Expand All @@ -126,6 +134,7 @@ fn main_inner() -> Result<(), i32> {
let first_workspace = workspace_rest.next();

let linting_enabled = arg.linting_enabled.unwrap_or(true);
let zero_indexed = arg.zero_indexed.unwrap_or(false);

let root = match first_workspace {
Some(w) => w,
Expand Down Expand Up @@ -167,7 +176,7 @@ fn main_inner() -> Result<(), i32> {
})?;

if !arg.quiet {
dlsclient.output_errors();
dlsclient.output_errors(zero_indexed);
}
if arg.test && !dlsclient.no_errors() {
exit_code = Err(1);
Expand Down
Loading