Go: be consistent in replacement of backslashes in file labels

This commit is contained in:
Nick Rolfe
2025-10-23 15:56:59 +01:00
parent e4c9bb3c5c
commit 10fa1d650d

View File

@@ -3,6 +3,7 @@ package trap
import (
"fmt"
"go/types"
"path/filepath"
"github.com/github/codeql-go/extractor/srcarchive"
"github.com/github/codeql-go/extractor/util"
@@ -75,7 +76,7 @@ func (l *Labeler) FileLabel() Label {
// FileLabelFor returns the label for the file for which the trap writer `tw` is associated
func (l *Labeler) FileLabelFor(path string) Label {
return l.GlobalID(util.EscapeTrapSpecialChars(path) + ";sourcefile")
return l.GlobalID(util.EscapeTrapSpecialChars(filepath.ToSlash(path)) + ";sourcefile")
}
// LocalID associates a label with the given AST node `nd` and returns it