[PATCH] D23816: Add support for -fdiagnostics-abs-path: printing absolute paths in diagnostics

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 15:56:28 PDT 2016


rsmith added inline comments.

================
Comment at: include/clang/Driver/Options.td:994
@@ -993,1 +993,3 @@
   Flags<[CC1Option]>, HelpText<"Do not include source location information with diagnostics">;
+def fdiagnostics_abs_path : Flag<["-"], "fdiagnostics-abs-path">, Group<f_Group>,
+  Flags<[CC1Option, CoreOption]>, HelpText<"Print absolute paths in diagnostics">;
----------------
How about `-fdiagnostics-[use-]absolute-paths` rather than `-fdiagnostics-abs-path` to avoid any confusion about this referring to the `abs` function?

================
Comment at: lib/Frontend/TextDiagnostic.cpp:773
@@ +772,3 @@
+    SM.getFileManager().makeAbsolutePath(AbsoluteFilename);
+    llvm::sys::path::remove_dots(AbsoluteFilename, true);
+    llvm::sys::path::native(AbsoluteFilename);
----------------
Err, setting the second parameter to `true` here causes it to generate incorrect paths. I wouldn't do that... If you want to remove `..` components, you should use `FileManager::getCanonicalName` instead, which will do the appropriate symlink resolution here.


https://reviews.llvm.org/D23816





More information about the cfe-commits mailing list