[PATCH] D27810: Normalize all filenames before searching FileManager caches

Manuel Klimek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 14 06:34:57 PST 2017


klimek added inline comments.


================
Comment at: lib/Basic/FileManager.cpp:167-168
     DirNameStr = DirName.str() + '.';
+    llvm::sys::path::native(DirNameStr);
+    DirName = DirNameStr;
+  } else {
----------------
I'd add a canonicalizePath function that:
-> on unix just returns the path
-> on windows, does the ::native dance and returns that path

Then we can call that when we access the cache or write to the cache instead of sprinkling #ifdefs around.


================
Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1716-1717
     Loc = Loc.getSpellingLoc();
-    if (SM.getFilename(Loc).endswith("sys/queue.h")) {
+	StringRef FN = SM.getFilename(Loc);
+    if (FN.endswith("sys/queue.h") || FN.endswith("sys\\queue.h")) {
       BR.markInvalid(getTag(), nullptr);
----------------
I'd do changes like this in a separate patch.


================
Comment at: test/CodeGen/debug-prefix-map.c:21
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{/|\\5C}}Inputs{{/|\\5C}}stdio.h"
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
----------------
That is super unfortunate.
If we want tests to be able to run on windows, I think we might just want to give clang a flag to always show paths in unix format. That also should be something we could just make the file manager do (I think whatever the filemanager stores will be what is visible to the user).


https://reviews.llvm.org/D27810





More information about the cfe-commits mailing list