mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-26 12:55:06 +00:00
properly handle note override logic/verbosity/config/cmdline using modifiedyNotes, cmdlineNotes
This commit is contained in:
committed by
Andreas Rumpf
parent
c1cbf94e2d
commit
1056f9ecff
@@ -199,23 +199,21 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
||||
let x = findStr(lineinfos.WarningsToStr, id)
|
||||
if x >= 0: n = TNoteKind(x + ord(warnMin))
|
||||
else: localError(conf, info, "unknown warning: " & id)
|
||||
case substr(arg, i).normalize
|
||||
of "on":
|
||||
incl(conf.notes, n)
|
||||
incl(conf.mainPackageNotes, n)
|
||||
incl(conf.enableNotes, n)
|
||||
if pass == passCmd1:
|
||||
incl(conf.cmdLineNotes, n)
|
||||
excl(conf.cmdLineDisabledNotes, n)
|
||||
of "off":
|
||||
excl(conf.notes, n)
|
||||
excl(conf.mainPackageNotes, n)
|
||||
incl(conf.disableNotes, n)
|
||||
excl(conf.foreignPackageNotes, n)
|
||||
if pass == passCmd1:
|
||||
incl(conf.cmdLineDisabledNotes, n)
|
||||
excl(conf.cmdLineNotes, n)
|
||||
else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
|
||||
|
||||
let val = substr(arg, i).normalize
|
||||
if val notin ["on", "off"]:
|
||||
localError(conf, info, errOnOrOffExpectedButXFound % arg)
|
||||
elif n notin conf.cmdlineNotes or pass == passCmd1:
|
||||
if pass == passCmd1: incl(conf.cmdlineNotes, n)
|
||||
incl(conf.modifiedyNotes, n)
|
||||
case val
|
||||
of "on":
|
||||
incl(conf.notes, n)
|
||||
incl(conf.mainPackageNotes, n)
|
||||
of "off":
|
||||
excl(conf.notes, n)
|
||||
excl(conf.mainPackageNotes, n)
|
||||
excl(conf.foreignPackageNotes, n)
|
||||
|
||||
proc processCompile(conf: ConfigRef; filename: string) =
|
||||
var found = findFile(conf, filename)
|
||||
@@ -598,7 +596,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
of "deadcodeelim": discard # deprecated, dead code elim always on
|
||||
of "threads":
|
||||
processOnOffSwitchG(conf, {optThreads}, arg, pass, info)
|
||||
#if optThreads in conf.globalOptions: incl(conf.notes, warnGcUnsafe)
|
||||
#if optThreads in conf.globalOptions: conf.setNote(warnGcUnsafe)
|
||||
of "tlsemulation": processOnOffSwitchG(conf, {optTlsEmulation}, arg, pass, info)
|
||||
of "taintmode": processOnOffSwitchG(conf, {optTaintMode}, arg, pass, info)
|
||||
of "implicitstatic":
|
||||
@@ -710,9 +708,10 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
if verbosity notin {0..3}:
|
||||
localError(conf, info, "invalid verbosity level: '$1'" % arg)
|
||||
conf.verbosity = verbosity
|
||||
conf.notes = NotesVerbosity[conf.verbosity]
|
||||
incl(conf.notes, conf.enableNotes)
|
||||
excl(conf.notes, conf.disableNotes)
|
||||
var verb = NotesVerbosity[conf.verbosity]
|
||||
## We override the default `verb` by explicitly modified (set/unset) notes.
|
||||
conf.notes = (conf.modifiedyNotes * conf.notes + verb) -
|
||||
(conf.modifiedyNotes * verb - conf.notes)
|
||||
conf.mainPackageNotes = conf.notes
|
||||
of "parallelbuild":
|
||||
expectArg(conf, switch, arg, pass, info)
|
||||
|
||||
@@ -418,10 +418,7 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||
inc(conf.warnCounter)
|
||||
of hintMin..hintMax:
|
||||
sev = Severity.Hint
|
||||
if msg in conf.cmdLineDisabledNotes: return # eg: `--hints:conf:off` passed on cmdline
|
||||
# handle `--hints:off` (regardless of cmdline/cfg file)
|
||||
# handle `--hints:conf:on` on cmdline
|
||||
if not conf.hasHint(msg) and not (optHints in conf.options and msg in conf.cmdLineNotes): return
|
||||
if not conf.hasHint(msg): return
|
||||
title = HintTitle
|
||||
color = HintColor
|
||||
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
||||
|
||||
@@ -226,13 +226,11 @@ type
|
||||
ideCmd*: IdeCmd
|
||||
oldNewlines*: bool
|
||||
cCompiler*: TSystemCC
|
||||
enableNotes*: TNoteKinds
|
||||
disableNotes*: TNoteKinds
|
||||
modifiedyNotes*: TNoteKinds # notes that have been set/unset from either cmdline/configs
|
||||
cmdlineNotes*: TNoteKinds # notes that have been set/unset from cmdline
|
||||
foreignPackageNotes*: TNoteKinds
|
||||
notes*: TNoteKinds
|
||||
notes*: TNoteKinds # notes after resolving all logic(defaults, verbosity)/cmdline/configs
|
||||
mainPackageNotes*: TNoteKinds
|
||||
cmdLineNotes*: TNoteKinds
|
||||
cmdLineDisabledNotes*: TNoteKinds
|
||||
mainPackageId*: int
|
||||
errorCounter*: int
|
||||
hintCounter*: int
|
||||
@@ -289,6 +287,10 @@ type
|
||||
severity: Severity) {.closure, gcsafe.}
|
||||
cppCustomNamespace*: string
|
||||
|
||||
proc setNote*(conf: ConfigRef, note: TNoteKind, enabled = true) =
|
||||
if note notin conf.cmdlineNotes:
|
||||
if enabled: incl(conf.notes, note) else: excl(conf.notes, note)
|
||||
|
||||
proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
|
||||
optHints in conf.options and note in conf.notes
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ proc verboseProcess(context: PPassContext, n: PNode): PNode =
|
||||
let v = VerboseRef(context)
|
||||
if v.config.verbosity == 3:
|
||||
# system.nim deactivates all hints, for verbosity:3 we want the processing
|
||||
# messages nonetheless, so we activate them again unconditionally:
|
||||
incl(v.config.notes, hintProcessing)
|
||||
# messages nonetheless, so we activate them again (but honor cmdlineNotes)
|
||||
v.config.setNote(hintProcessing)
|
||||
message(v.config, n.info, hintProcessing, $idgen.gFrontEndId)
|
||||
|
||||
const verbosePass* = makePass(open = verboseOpen, process = verboseProcess)
|
||||
|
||||
@@ -328,6 +328,7 @@ proc processNote(c: PContext, n: PNode) =
|
||||
n[1] = x
|
||||
if x.kind == nkIntLit and x.intVal != 0: incl(c.config.notes, nk)
|
||||
else: excl(c.config.notes, nk)
|
||||
# checkme: honor cmdlineNotes with: c.setNote(nk, x.kind == nkIntLit and x.intVal != 0)
|
||||
else:
|
||||
invalidPragma(c, n)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user