commit | dfd2caedc7edf7c25eaa860012221fd1e9148ece | [log] [tgz] |
---|---|---|
author | mikt <[email protected]> | Tue May 23 04:10:57 2023 |
committer | Chromium LUCI CQ <[email protected]> | Tue May 23 04:10:57 2023 |
tree | c3d5b133daa98cce45b084cbd6b680ed3cc1fc39 | |
parent | 59e1383dcc9811df08575a450e55ded347edb0f6 [diff] [blame] |
[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; }