[PATCH] D89186: [lit] Avoid calling realpath() for every printed message

Louis Dionne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 07:11:19 PDT 2020


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: llvm/utils/lit/lit/LitConfig.py:181
         f = f.f_back.f_back
-        file,line,_,_,_ = inspect.getframeinfo(f)
-        location = '%s:%d' % (file, line)
-
-        sys.stderr.write('%s: %s: %s: %s\n' % (self.progname, location,
-                                               kind, message))
+        file = os.path.normpath(os.path.abspath(inspect.getsourcefile(f)))
+        line = inspect.getlineno(f)
----------------
I don't think you need to call `normpath()` after calling `abspath()`. From the Python docs:

> `os.path.abspath(path)`
> Return a normalized absolutized version of the pathname path. On most platforms, this is equivalent to calling the function `normpath()` as follows: `normpath(join(os.getcwd(), path))`.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89186/new/

https://reviews.llvm.org/D89186



More information about the llvm-commits mailing list