summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/internal/Error.scala
diff options
context:
space:
mode:
authorRichard Lin2018-02-08 10:50:35 -0800
committerGitHub2018-02-08 10:50:35 -0800
commita57e4b1ea0970266aae8ce3bb5edaaf605057035 (patch)
treee14f8e70b67829708216ce329e0e84f5a8823525 /chiselFrontend/src/main/scala/chisel3/internal/Error.scala
parent254597c125bda06e041a4a241177e959200ce8f7 (diff)
Make uncloneable IO deprecated instead of error, improve error handling (#771)
It appears #754 breaks more code than I thought, so this makes it a soft error (with a runtime deprecation warning - to get people to fix their stuff before we break it for real) for now. This additionally changes the autoclonetype errors to be more deterministic (reporting class names instead of object names) in the most common cases, to allow the deprecations manager to deduplicate warnings.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/internal/Error.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/internal/Error.scala22
1 files changed, 13 insertions, 9 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/internal/Error.scala b/chiselFrontend/src/main/scala/chisel3/internal/Error.scala
index 6e7e4002..7d209219 100644
--- a/chiselFrontend/src/main/scala/chisel3/internal/Error.scala
+++ b/chiselFrontend/src/main/scala/chisel3/internal/Error.scala
@@ -28,8 +28,16 @@ private[chisel3] class ErrorLog {
println(new Info("[%2.3f] %s".format(elapsedTime/1e3, m), None)) // scalastyle:ignore regex
/** Log a deprecation warning message */
- def deprecated(m: => String): Unit = {
- val thisEntry = (m, getUserLineNumber)
+ def deprecated(m: => String, location: Option[String]): Unit = {
+ val sourceLoc = location match {
+ case Some(loc) => loc
+ case None => getUserLineNumber match {
+ case Some(elt: StackTraceElement) => s"${elt.getFileName}:${elt.getLineNumber}"
+ case None => "(unknown)"
+ }
+ }
+
+ val thisEntry = (m, sourceLoc)
deprecations += ((thisEntry, deprecations.getOrElse(thisEntry, 0) + 1))
}
@@ -38,12 +46,8 @@ private[chisel3] class ErrorLog {
val depTag = s"[${Console.BLUE}deprecated${Console.RESET}]"
val warnTag = s"[${Console.YELLOW}warn${Console.RESET}]"
val errTag = s"[${Console.RED}error${Console.RESET}]"
- deprecations foreach { case ((message, stackElement), count) =>
- val line = stackElement match {
- case Some(stackElement) => s"$depTag ${stackElement.getFileName}:${stackElement.getLineNumber} ($count calls): $message"
- case None => s"$depTag (unknown location) ($count calls): $message"
- }
- println(line)
+ deprecations.foreach { case ((message, sourceLoc), count) =>
+ println(s"$depTag $sourceLoc ($count calls): $message")
}
errors foreach println
@@ -99,7 +103,7 @@ private[chisel3] class ErrorLog {
}
private val errors = ArrayBuffer[LogEntry]()
- private val deprecations = LinkedHashMap[(String, Option[StackTraceElement]), Int]()
+ private val deprecations = LinkedHashMap[(String, String), Int]()
private val startTime = System.currentTimeMillis
private def elapsedTime: Long = System.currentTimeMillis - startTime