[clang-plugin] Normalize path with back-slashes to one with slashes

- Backslashes can bypass some filtering based on regex or substring
  checking.
  - This just replaces '\' with '/' to avoid such issues.
  - Example:
    https://ci.chromium.org/ui/p/chromium/builders/ci/Win%20x64%20Builder/133542/overview


Change-Id: Ia189a5182b34b4b27b730cf3e6a6640aaf6b588d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4522366
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Keishi Hattori <[email protected]>
Commit-Queue: Mikihito Matsuura <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1147654}
diff --git a/tools/clang/plugins/Util.cpp b/tools/clang/plugins/Util.cpp
index 5b6ebb41..08fbc6a 100644
--- a/tools/clang/plugins/Util.cpp
+++ b/tools/clang/plugins/Util.cpp
@@ -4,6 +4,8 @@
 
 #include "Util.h"
 
+#include <algorithm>
+
 #include "clang/AST/Decl.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/Casting.h"
@@ -48,5 +50,10 @@
     return "";
   }
 
-  return ploc.getFilename();
+  std::string name = ploc.getFilename();
+
+  // File paths can have separators which differ from ones at this platform.
+  // Make them consistent.
+  std::replace(name.begin(), name.end(), '\\', '/');
+  return name;
 }