This commit is contained in:
parent
94b0d6bb63
commit
bd90199a2f
9 changed files with 26 additions and 22 deletions
|
|
@ -1412,7 +1412,7 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
|
||||||
proc genStmts(p: BProc, t: PNode) =
|
proc genStmts(p: BProc, t: PNode) =
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
|
|
||||||
let isPush = hintExtendedContext in p.config.notes
|
let isPush = p.config.hasHint(hintExtendedContext)
|
||||||
if isPush: pushInfoContext(p.config, t.info)
|
if isPush: pushInfoContext(p.config, t.info)
|
||||||
expr(p, t, a)
|
expr(p, t, a)
|
||||||
if isPush: popInfoContext(p.config)
|
if isPush: popInfoContext(p.config)
|
||||||
|
|
|
||||||
|
|
@ -715,7 +715,7 @@ proc compileCFiles(conf: ConfigRef; list: CfileList, script: var Rope, cmds: var
|
||||||
if optCompileOnly notin conf.globalOptions:
|
if optCompileOnly notin conf.globalOptions:
|
||||||
cmds.add(compileCmd)
|
cmds.add(compileCmd)
|
||||||
let (_, name, _) = splitFile(it.cname)
|
let (_, name, _) = splitFile(it.cname)
|
||||||
prettyCmds.add(if hintCC in conf.notes: "CC: " & demanglePackageName(name) else: "")
|
prettyCmds.add(if conf.hasHint(hintCC): "CC: " & demanglePackageName(name) else: "")
|
||||||
if optGenScript in conf.globalOptions:
|
if optGenScript in conf.globalOptions:
|
||||||
script.add(compileCmd)
|
script.add(compileCmd)
|
||||||
script.add("\n")
|
script.add("\n")
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ proc evalPattern(c: PContext, n, orig: PNode): PNode =
|
||||||
# awful to semcheck before macro invocation, so we don't and treat
|
# awful to semcheck before macro invocation, so we don't and treat
|
||||||
# templates and macros as immediate in this context.
|
# templates and macros as immediate in this context.
|
||||||
var rule: string
|
var rule: string
|
||||||
if optHints in c.config.options and hintPattern in c.config.notes:
|
if c.config.hasHint(hintPattern):
|
||||||
rule = renderTree(n, {renderNoComments})
|
rule = renderTree(n, {renderNoComments})
|
||||||
let s = n[0].sym
|
let s = n[0].sym
|
||||||
case s.kind
|
case s.kind
|
||||||
|
|
@ -27,7 +27,7 @@ proc evalPattern(c: PContext, n, orig: PNode): PNode =
|
||||||
result = semTemplateExpr(c, n, s, {efFromHlo})
|
result = semTemplateExpr(c, n, s, {efFromHlo})
|
||||||
else:
|
else:
|
||||||
result = semDirectOp(c, n, {})
|
result = semDirectOp(c, n, {})
|
||||||
if optHints in c.config.options and hintPattern in c.config.notes:
|
if c.config.hasHint(hintPattern):
|
||||||
message(c.config, orig.info, hintPattern, rule & " --> '" &
|
message(c.config, orig.info, hintPattern, rule & " --> '" &
|
||||||
renderTree(result, {renderNoComments}) & "'")
|
renderTree(result, {renderNoComments}) & "'")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ proc log*(s: string) =
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
||||||
if defined(debug) or msg == errInternal or hintStackTrace in conf.notes:
|
if defined(debug) or msg == errInternal or conf.hasHint(hintStackTrace):
|
||||||
{.gcsafe.}:
|
{.gcsafe.}:
|
||||||
if stackTraceAvailable() and isNil(conf.writelnHook):
|
if stackTraceAvailable() and isNil(conf.writelnHook):
|
||||||
writeStackTrace()
|
writeStackTrace()
|
||||||
|
|
@ -410,8 +410,7 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||||
color = ErrorColor
|
color = ErrorColor
|
||||||
of warnMin..warnMax:
|
of warnMin..warnMax:
|
||||||
sev = Severity.Warning
|
sev = Severity.Warning
|
||||||
if optWarns notin conf.options: return
|
if not conf.hasWarn(msg): return
|
||||||
if msg notin conf.notes: return
|
|
||||||
writeContext(conf, unknownLineInfo)
|
writeContext(conf, unknownLineInfo)
|
||||||
title = WarningTitle
|
title = WarningTitle
|
||||||
color = WarningColor
|
color = WarningColor
|
||||||
|
|
@ -419,8 +418,7 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||||
inc(conf.warnCounter)
|
inc(conf.warnCounter)
|
||||||
of hintMin..hintMax:
|
of hintMin..hintMax:
|
||||||
sev = Severity.Hint
|
sev = Severity.Hint
|
||||||
if optHints notin conf.options: return
|
if not conf.hasHint(msg): return
|
||||||
if msg notin conf.notes: return
|
|
||||||
title = HintTitle
|
title = HintTitle
|
||||||
color = HintColor
|
color = HintColor
|
||||||
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
||||||
|
|
@ -500,7 +498,7 @@ proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
conf.m.lastError = info
|
conf.m.lastError = info
|
||||||
of warnMin..warnMax:
|
of warnMin..warnMax:
|
||||||
sev = Severity.Warning
|
sev = Severity.Warning
|
||||||
ignoreMsg = optWarns notin conf.options or msg notin conf.notes
|
ignoreMsg = not conf.hasWarn(msg)
|
||||||
if not ignoreMsg: writeContext(conf, info)
|
if not ignoreMsg: writeContext(conf, info)
|
||||||
title = WarningTitle
|
title = WarningTitle
|
||||||
color = WarningColor
|
color = WarningColor
|
||||||
|
|
@ -508,7 +506,7 @@ proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
inc(conf.warnCounter)
|
inc(conf.warnCounter)
|
||||||
of hintMin..hintMax:
|
of hintMin..hintMax:
|
||||||
sev = Severity.Hint
|
sev = Severity.Hint
|
||||||
ignoreMsg = optHints notin conf.options or msg notin conf.notes
|
ignoreMsg = not conf.hasHint(msg)
|
||||||
title = HintTitle
|
title = HintTitle
|
||||||
color = HintColor
|
color = HintColor
|
||||||
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
||||||
|
|
@ -526,7 +524,7 @@ proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
KindColor, `%`(KindFormat, kind))
|
KindColor, `%`(KindFormat, kind))
|
||||||
else:
|
else:
|
||||||
styledMsgWriteln(styleBright, x, resetStyle, color, title, resetStyle, s)
|
styledMsgWriteln(styleBright, x, resetStyle, color, title, resetStyle, s)
|
||||||
if hintSource in conf.notes:
|
if conf.hasHint(hintSource):
|
||||||
conf.writeSurroundingSrc(info)
|
conf.writeSurroundingSrc(info)
|
||||||
handleError(conf, msg, eh, s)
|
handleError(conf, msg, eh, s)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
|
||||||
|
|
||||||
self.processCmdLineAndProjectPath(conf)
|
self.processCmdLineAndProjectPath(conf)
|
||||||
if not self.loadConfigsAndRunMainCommand(cache, conf): return
|
if not self.loadConfigsAndRunMainCommand(cache, conf): return
|
||||||
if optHints in conf.options and hintGCStats in conf.notes: echo(GC_getStatistics())
|
if conf.hasHint(hintGCStats): echo(GC_getStatistics())
|
||||||
#echo(GC_getStatistics())
|
#echo(GC_getStatistics())
|
||||||
if conf.errorCounter != 0: return
|
if conf.errorCounter != 0: return
|
||||||
when hasTinyCBackend:
|
when hasTinyCBackend:
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,12 @@ type
|
||||||
severity: Severity) {.closure, gcsafe.}
|
severity: Severity) {.closure, gcsafe.}
|
||||||
cppCustomNamespace*: string
|
cppCustomNamespace*: string
|
||||||
|
|
||||||
|
proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
|
||||||
|
optHints in conf.options and note in conf.notes
|
||||||
|
|
||||||
|
proc hasWarn*(conf: ConfigRef, note: TNoteKind): bool =
|
||||||
|
optWarns in conf.options and note in conf.notes
|
||||||
|
|
||||||
proc hcrOn*(conf: ConfigRef): bool = return optHotCodeReloading in conf.globalOptions
|
proc hcrOn*(conf: ConfigRef): bool = return optHotCodeReloading in conf.globalOptions
|
||||||
|
|
||||||
template depConfigFields*(fn) {.dirty.} =
|
template depConfigFields*(fn) {.dirty.} =
|
||||||
|
|
|
||||||
|
|
@ -990,7 +990,7 @@ proc buildEchoStmt(c: PContext, n: PNode): PNode =
|
||||||
result = semExpr(c, result)
|
result = semExpr(c, result)
|
||||||
|
|
||||||
proc semExprNoType(c: PContext, n: PNode): PNode =
|
proc semExprNoType(c: PContext, n: PNode): PNode =
|
||||||
let isPush = hintExtendedContext in c.config.notes
|
let isPush = c.config.hasHint(hintExtendedContext)
|
||||||
if isPush: pushInfoContext(c.config, n.info)
|
if isPush: pushInfoContext(c.config, n.info)
|
||||||
result = semExpr(c, n, {efWantStmt})
|
result = semExpr(c, n, {efWantStmt})
|
||||||
discardCheck(c, result, {})
|
discardCheck(c, result, {})
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ proc useVar(a: PEffects, n: PNode) =
|
||||||
if s.guard != nil: guardGlobal(a, n, s.guard)
|
if s.guard != nil: guardGlobal(a, n, s.guard)
|
||||||
if {sfGlobal, sfThread} * s.flags == {sfGlobal} and
|
if {sfGlobal, sfThread} * s.flags == {sfGlobal} and
|
||||||
(tfHasGCedMem in s.typ.flags or s.typ.isGCedMem):
|
(tfHasGCedMem in s.typ.flags or s.typ.isGCedMem):
|
||||||
#if warnGcUnsafe in gNotes: warnAboutGcUnsafe(n)
|
#if a.config.hasWarn(warnGcUnsafe): warnAboutGcUnsafe(n)
|
||||||
markGcUnsafe(a, s)
|
markGcUnsafe(a, s)
|
||||||
markSideEffect(a, s)
|
markSideEffect(a, s)
|
||||||
else:
|
else:
|
||||||
|
|
@ -463,7 +463,7 @@ proc propagateEffects(tracked: PEffects, n: PNode, s: PSym) =
|
||||||
mergeTags(tracked, tagSpec, n)
|
mergeTags(tracked, tagSpec, n)
|
||||||
|
|
||||||
if notGcSafe(s.typ) and sfImportc notin s.flags:
|
if notGcSafe(s.typ) and sfImportc notin s.flags:
|
||||||
if warnGcUnsafe in tracked.config.notes: warnAboutGcUnsafe(n, tracked.config)
|
if tracked.config.hasWarn(warnGcUnsafe): warnAboutGcUnsafe(n, tracked.config)
|
||||||
markGcUnsafe(tracked, s)
|
markGcUnsafe(tracked, s)
|
||||||
if tfNoSideEffect notin s.typ.flags:
|
if tfNoSideEffect notin s.typ.flags:
|
||||||
markSideEffect(tracked, s)
|
markSideEffect(tracked, s)
|
||||||
|
|
@ -544,7 +544,7 @@ proc trackOperand(tracked: PEffects, n: PNode, paramType: PType; caller: PNode)
|
||||||
assumeTheWorst(tracked, n, op)
|
assumeTheWorst(tracked, n, op)
|
||||||
# assume GcUnsafe unless in its type; 'forward' does not matter:
|
# assume GcUnsafe unless in its type; 'forward' does not matter:
|
||||||
if notGcSafe(op) and not isOwnedProcVar(a, tracked.owner):
|
if notGcSafe(op) and not isOwnedProcVar(a, tracked.owner):
|
||||||
if warnGcUnsafe in tracked.config.notes: warnAboutGcUnsafe(n, tracked.config)
|
if tracked.config.hasWarn(warnGcUnsafe): warnAboutGcUnsafe(n, tracked.config)
|
||||||
markGcUnsafe(tracked, a)
|
markGcUnsafe(tracked, a)
|
||||||
elif tfNoSideEffect notin op.flags and not isOwnedProcVar(a, tracked.owner):
|
elif tfNoSideEffect notin op.flags and not isOwnedProcVar(a, tracked.owner):
|
||||||
markSideEffect(tracked, a)
|
markSideEffect(tracked, a)
|
||||||
|
|
@ -552,7 +552,7 @@ proc trackOperand(tracked: PEffects, n: PNode, paramType: PType; caller: PNode)
|
||||||
mergeEffects(tracked, effectList[exceptionEffects], n)
|
mergeEffects(tracked, effectList[exceptionEffects], n)
|
||||||
mergeTags(tracked, effectList[tagEffects], n)
|
mergeTags(tracked, effectList[tagEffects], n)
|
||||||
if notGcSafe(op):
|
if notGcSafe(op):
|
||||||
if warnGcUnsafe in tracked.config.notes: warnAboutGcUnsafe(n, tracked.config)
|
if tracked.config.hasWarn(warnGcUnsafe): warnAboutGcUnsafe(n, tracked.config)
|
||||||
markGcUnsafe(tracked, a)
|
markGcUnsafe(tracked, a)
|
||||||
elif tfNoSideEffect notin op.flags:
|
elif tfNoSideEffect notin op.flags:
|
||||||
markSideEffect(tracked, a)
|
markSideEffect(tracked, a)
|
||||||
|
|
@ -584,7 +584,7 @@ proc trackCase(tracked: PEffects, n: PNode) =
|
||||||
let stringCase = skipTypes(n[0].typ,
|
let stringCase = skipTypes(n[0].typ,
|
||||||
abstractVarRange-{tyTypeDesc}).kind in {tyFloat..tyFloat128, tyString}
|
abstractVarRange-{tyTypeDesc}).kind in {tyFloat..tyFloat128, tyString}
|
||||||
let interesting = not stringCase and interestingCaseExpr(n[0]) and
|
let interesting = not stringCase and interestingCaseExpr(n[0]) and
|
||||||
warnProveField in tracked.config.notes
|
tracked.config.hasWarn(warnProveField)
|
||||||
var inter: TIntersection = @[]
|
var inter: TIntersection = @[]
|
||||||
var toCover = 0
|
var toCover = 0
|
||||||
for i in 1..<n.len:
|
for i in 1..<n.len:
|
||||||
|
|
@ -678,7 +678,7 @@ proc track(tracked: PEffects, n: PNode) =
|
||||||
if notGcSafe(op) and not importedFromC(a):
|
if notGcSafe(op) and not importedFromC(a):
|
||||||
# and it's not a recursive call:
|
# and it's not a recursive call:
|
||||||
if not (a.kind == nkSym and a.sym == tracked.owner):
|
if not (a.kind == nkSym and a.sym == tracked.owner):
|
||||||
if warnGcUnsafe in tracked.config.notes: warnAboutGcUnsafe(n, tracked.config)
|
if tracked.config.hasWarn(warnGcUnsafe): warnAboutGcUnsafe(n, tracked.config)
|
||||||
markGcUnsafe(tracked, a)
|
markGcUnsafe(tracked, a)
|
||||||
if tfNoSideEffect notin op.flags and not importedFromC(a):
|
if tfNoSideEffect notin op.flags and not importedFromC(a):
|
||||||
# and it's not a recursive call:
|
# and it's not a recursive call:
|
||||||
|
|
@ -779,7 +779,7 @@ proc track(tracked: PEffects, n: PNode) =
|
||||||
for i in 0..<n.len: track(tracked, n[i])
|
for i in 0..<n.len: track(tracked, n[i])
|
||||||
of nkCheckedFieldExpr:
|
of nkCheckedFieldExpr:
|
||||||
track(tracked, n[0])
|
track(tracked, n[0])
|
||||||
if warnProveField in tracked.config.notes:
|
if tracked.config.hasWarn(warnProveField):
|
||||||
checkFieldAccess(tracked.guards, n, tracked.config)
|
checkFieldAccess(tracked.guards, n, tracked.config)
|
||||||
of nkTryStmt: trackTryStmt(tracked, n)
|
of nkTryStmt: trackTryStmt(tracked, n)
|
||||||
of nkPragma: trackPragmaStmt(tracked, n)
|
of nkPragma: trackPragmaStmt(tracked, n)
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ proc applyFilter(p: var TParsers, n: PNode, filename: AbsoluteFile,
|
||||||
result = filterReplace(p.config, stdin, filename, n)
|
result = filterReplace(p.config, stdin, filename, n)
|
||||||
if f != filtNone:
|
if f != filtNone:
|
||||||
assert p.config != nil
|
assert p.config != nil
|
||||||
if hintCodeBegin in p.config.notes:
|
if p.config.hasHint(hintCodeBegin):
|
||||||
rawMessage(p.config, hintCodeBegin, [])
|
rawMessage(p.config, hintCodeBegin, [])
|
||||||
msgWriteln(p.config, result.s)
|
msgWriteln(p.config, result.s)
|
||||||
rawMessage(p.config, hintCodeEnd, [])
|
rawMessage(p.config, hintCodeEnd, [])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue