github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp --
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
index 857e22dda..84a76069d 100644
--- a/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
@@ -25,14 +25,16 @@ static std::string findLLVMProjectRoot(StringRef Filename) {
SmallString<256> Path = Filename;
while (!Path.empty()) {
llvm::sys::path::remove_filename(Path);
- if (Path.empty()) break;
-
+ if (Path.empty())
+ break;
+
SmallString<256> LLVMPath = Path;
llvm::sys::path::append(LLVMPath, "llvm");
SmallString<256> ClangPath = Path;
llvm::sys::path::append(ClangPath, "clang");
-
- if (llvm::sys::fs::is_directory(LLVMPath) &&
llvm::sys::fs::is_directory(ClangPath)) {
+
+ if (llvm::sys::fs::is_directory(LLVMPath) &&
+ llvm::sys::fs::is_directory(ClangPath)) {
return std::string(Path);
}
}
@@ -43,19 +45,19 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef
Filename,
StringRef OldGuard) {
std::string AbsolutePath = tooling::getAbsolutePath(Filename);
std::string Guard = AbsolutePath;
-
+
// If we can find the LLVM project root, canonicalize the path by replacing
// the root path prefix with "/llvm-project/". This ensures the subsequent
// legacy logic (which relies on hardcoded "llvm-project" or "llvm" path
- // components) works correctly regardless of the actual worktree directory
name.
+ // components) works correctly regardless of the actual worktree directory
+ // name.
std::string Root = findLLVMProjectRoot(AbsolutePath);
if (!Root.empty()) {
StringRef RelativePath = StringRef(AbsolutePath).substr(Root.size());
- if (RelativePath.starts_with("/")) {
+ if (RelativePath.starts_with("/"))
Guard = ("/llvm-project" + RelativePath).str();
- } else {
+ else
Guard = ("/llvm-project/" + RelativePath).str();
- }
}
// When running under Windows, need to convert the path separators from
``````````
</details>
https://github.com/llvm/llvm-project/pull/205839
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits