Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

78842 support for the .yml file extension #79900

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

harbandana
Copy link

No description provided.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 29, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

@llvm/pr-subscribers-clang-tools-extra

Author: None (harbandana)

Changes

Patch is 109.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/79900.diff

3 Files Affected:

  • (modified) clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp (+275-271)
  • (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+100-97)
  • (modified) compiler-rt/lib/hwasan/hwasan_report.cpp (+1096-1100)
diff --git a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 87ed1b8797cb05e..20bafef7240438f 100644
--- a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -1,271 +1,275 @@
-//===-- ApplyReplacements.cpp - Apply and deduplicate replacements --------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// This file provides the implementation for deduplicating, detecting
-/// conflicts in, and applying collections of Replacements.
-///
-/// FIXME: Use Diagnostics for output instead of llvm::errs().
-///
-//===----------------------------------------------------------------------===//
-#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Format/Format.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Diagnostic.h"
-#include "clang/Tooling/DiagnosticsYaml.h"
-#include "clang/Tooling/ReplacementsYaml.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringSet.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
-#include <optional>
-
-using namespace llvm;
-using namespace clang;
-
-static void eatDiagnostics(const SMDiagnostic &, void *) {}
-
-namespace clang {
-namespace replace {
-
-namespace detail {
-template <typename TranslationUnits>
-static std::error_code collectReplacementsFromDirectory(
-    const llvm::StringRef Directory, TranslationUnits &TUs,
-    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
-  using namespace llvm::sys::fs;
-  using namespace llvm::sys::path;
-
-  std::error_code ErrorCode;
-
-  for (recursive_directory_iterator I(Directory, ErrorCode), E;
-       I != E && !ErrorCode; I.increment(ErrorCode)) {
-    if (filename(I->path())[0] == '.') {
-      // Indicate not to descend into directories beginning with '.'
-      I.no_push();
-      continue;
-    }
-
-    if (extension(I->path()) != ".yaml")
-      continue;
-
-    TUFiles.push_back(I->path());
-
-    ErrorOr<std::unique_ptr<MemoryBuffer>> Out =
-        MemoryBuffer::getFile(I->path());
-    if (std::error_code BufferError = Out.getError()) {
-      errs() << "Error reading " << I->path() << ": " << BufferError.message()
-             << "\n";
-      continue;
-    }
-
-    yaml::Input YIn(Out.get()->getBuffer(), nullptr, &eatDiagnostics);
-    typename TranslationUnits::value_type TU;
-    YIn >> TU;
-    if (YIn.error()) {
-      // File doesn't appear to be a header change description. Ignore it.
-      continue;
-    }
-
-    // Only keep files that properly parse.
-    TUs.push_back(TU);
-  }
-
-  return ErrorCode;
-}
-} // namespace detail
-
-template <>
-std::error_code collectReplacementsFromDirectory(
-    const llvm::StringRef Directory, TUReplacements &TUs,
-    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
-  return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
-                                                  Diagnostics);
-}
-
-template <>
-std::error_code collectReplacementsFromDirectory(
-    const llvm::StringRef Directory, TUDiagnostics &TUs,
-    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
-  return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
-                                                  Diagnostics);
-}
-
-/// Extract replacements from collected TranslationUnitReplacements and
-/// TranslationUnitDiagnostics and group them per file. Identical replacements
-/// from diagnostics are deduplicated.
-///
-/// \param[in] TUs Collection of all found and deserialized
-/// TranslationUnitReplacements.
-/// \param[in] TUDs Collection of all found and deserialized
-/// TranslationUnitDiagnostics.
-/// \param[in] SM Used to deduplicate paths.
-///
-/// \returns A map mapping FileEntry to a set of Replacement targeting that
-/// file.
-static llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
-groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
-                  const clang::SourceManager &SM) {
-  llvm::StringSet<> Warned;
-  llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
-      GroupedReplacements;
-
-  // Deduplicate identical replacements in diagnostics unless they are from the
-  // same TU.
-  // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap<const FileEntry *,
-                 std::map<tooling::Replacement,
-                          const tooling::TranslationUnitDiagnostics *>>
-      DiagReplacements;
-
-  auto AddToGroup = [&](const tooling::Replacement &R,
-                        const tooling::TranslationUnitDiagnostics *SourceTU,
-                        const std::optional<std::string> BuildDir) {
-    // Use the file manager to deduplicate paths. FileEntries are
-    // automatically canonicalized. Since relative paths can come from different
-    // build directories, make them absolute immediately.
-    SmallString<128> Path = R.getFilePath();
-    if (BuildDir)
-      llvm::sys::fs::make_absolute(*BuildDir, Path);
-    else
-      SM.getFileManager().makeAbsolutePath(Path);
-
-    if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
-      if (SourceTU) {
-        auto &Replaces = DiagReplacements[*Entry];
-        auto It = Replaces.find(R);
-        if (It == Replaces.end())
-          Replaces.emplace(R, SourceTU);
-        else if (It->second != SourceTU)
-          // This replacement is a duplicate of one suggested by another TU.
-          return;
-      }
-      GroupedReplacements[*Entry].push_back(R);
-    } else if (Warned.insert(Path).second) {
-      errs() << "Described file '" << R.getFilePath()
-             << "' doesn't exist. Ignoring...\n";
-    }
-  };
-
-  for (const auto &TU : TUs)
-    for (const tooling::Replacement &R : TU.Replacements)
-      AddToGroup(R, nullptr, {});
-
-  for (const auto &TU : TUDs)
-    for (const auto &D : TU.Diagnostics)
-      if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
-        for (const auto &Fix : *ChoosenFix)
-          for (const tooling::Replacement &R : Fix.second)
-            AddToGroup(R, &TU, D.BuildDirectory);
-      }
-
-  // Sort replacements per file to keep consistent behavior when
-  // clang-apply-replacements run on differents machine.
-  for (auto &FileAndReplacements : GroupedReplacements) {
-    llvm::sort(FileAndReplacements.second);
-  }
-
-  return GroupedReplacements;
-}
-
-bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
-                         FileToChangesMap &FileChanges,
-                         clang::SourceManager &SM, bool IgnoreInsertConflict) {
-  auto GroupedReplacements = groupReplacements(TUs, TUDs, SM);
-  bool ConflictDetected = false;
-
-  // To report conflicting replacements on corresponding file, all replacements
-  // are stored into 1 big AtomicChange.
-  for (const auto &FileAndReplacements : GroupedReplacements) {
-    FileEntryRef Entry = FileAndReplacements.first;
-    const SourceLocation BeginLoc =
-        SM.getLocForStartOfFile(SM.getOrCreateFileID(Entry, SrcMgr::C_User));
-    tooling::AtomicChange FileChange(Entry.getName(), Entry.getName());
-    for (const auto &R : FileAndReplacements.second) {
-      llvm::Error Err =
-          FileChange.replace(SM, BeginLoc.getLocWithOffset(R.getOffset()),
-                             R.getLength(), R.getReplacementText());
-      if (Err) {
-        // FIXME: This will report conflicts by pair using a file+offset format
-        // which is not so much human readable.
-        // A first improvement could be to translate offset to line+col. For
-        // this and without loosing error message some modifications around
-        // `tooling::ReplacementError` are need (access to
-        // `getReplacementErrString`).
-        // A better strategy could be to add a pretty printer methods for
-        // conflict reporting. Methods that could be parameterized to report a
-        // conflict in different format, file+offset, file+line+col, or even
-        // more human readable using VCS conflict markers.
-        // For now, printing directly the error reported by `AtomicChange` is
-        // the easiest solution.
-        errs() << llvm::toString(std::move(Err)) << "\n";
-        if (IgnoreInsertConflict) {
-          tooling::Replacements &Replacements = FileChange.getReplacements();
-          unsigned NewOffset =
-              Replacements.getShiftedCodePosition(R.getOffset());
-          unsigned NewLength = Replacements.getShiftedCodePosition(
-                                   R.getOffset() + R.getLength()) -
-                               NewOffset;
-          if (NewLength == R.getLength()) {
-            tooling::Replacement RR = tooling::Replacement(
-                R.getFilePath(), NewOffset, NewLength, R.getReplacementText());
-            Replacements = Replacements.merge(tooling::Replacements(RR));
-          } else {
-            llvm::errs()
-                << "Can't resolve conflict, skipping the replacement.\n";
-            ConflictDetected = true;
-          }
-        } else
-          ConflictDetected = true;
-      }
-    }
-    FileChanges.try_emplace(Entry,
-                            std::vector<tooling::AtomicChange>{FileChange});
-  }
-
-  return !ConflictDetected;
-}
-
-llvm::Expected<std::string>
-applyChanges(StringRef File, const std::vector<tooling::AtomicChange> &Changes,
-             const tooling::ApplyChangesSpec &Spec,
-             DiagnosticsEngine &Diagnostics) {
-  FileManager Files((FileSystemOptions()));
-  SourceManager SM(Diagnostics, Files);
-
-  llvm::ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
-      SM.getFileManager().getBufferForFile(File);
-  if (!Buffer)
-    return errorCodeToError(Buffer.getError());
-  return tooling::applyAtomicChanges(File, Buffer.get()->getBuffer(), Changes,
-                                     Spec);
-}
-
-bool deleteReplacementFiles(const TUReplacementFiles &Files,
-                            clang::DiagnosticsEngine &Diagnostics) {
-  bool Success = true;
-  for (const auto &Filename : Files) {
-    std::error_code Error = llvm::sys::fs::remove(Filename);
-    if (Error) {
-      Success = false;
-      // FIXME: Use Diagnostics for outputting errors.
-      errs() << "Error deleting file: " << Filename << "\n";
-      errs() << Error.message() << "\n";
-      errs() << "Please delete the file manually\n";
-    }
-  }
-  return Success;
-}
-
-} // end namespace replace
-} // end namespace clang
+//===-- ApplyReplacements.cpp - Apply and deduplicate replacements --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file provides the implementation for deduplicating, detecting
+/// conflicts in, and applying collections of Replacements.
+///
+/// FIXME: Use Diagnostics for output instead of llvm::errs().
+///
+//===----------------------------------------------------------------------===//
+
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/DiagnosticsYaml.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include <optional>
+
+using namespace llvm;
+using namespace clang;
+
+static void eatDiagnostics(const SMDiagnostic &, void *) {}
+
+namespace clang {
+namespace replace {
+
+namespace detail {
+
+static constexpr std::array<StringRef, 3> AllowedExtensions = {".yaml", ".yml", ""};
+
+template <typename TranslationUnits>
+static std::error_code collectReplacementsFromDirectory(
+    const llvm::StringRef Directory, TranslationUnits &TUs,
+    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
+  using namespace llvm::sys::fs;
+  using namespace llvm::sys::path;
+
+  std::error_code ErrorCode;
+
+  for (recursive_directory_iterator I(Directory, ErrorCode), E;
+       I != E && !ErrorCode; I.increment(ErrorCode)) {
+    if (filename(I->path())[0] == '.') {
+      // Indicate not to descend into directories beginning with '.'
+      I.no_push();
+      continue;
+    }
+
+     if (!is_contained(AllowedExtensions, extension(I->path())))
+      continue;
+    
+    TUFiles.push_back(I->path());
+
+    ErrorOr<std::unique_ptr<MemoryBuffer>> Out =
+        MemoryBuffer::getFile(I->path());
+    if (std::error_code BufferError = Out.getError()) {
+      errs() << "Error reading " << I->path() << ": " << BufferError.message()
+             << "\n";
+      continue;
+    }
+
+    yaml::Input YIn(Out.get()->getBuffer(), nullptr, &eatDiagnostics);
+    typename TranslationUnits::value_type TU;
+    YIn >> TU;
+    if (YIn.error()) {
+      // File doesn't appear to be a header change description. Ignore it.
+      continue;
+    }
+
+    // Only keep files that properly parse.
+    TUs.push_back(TU);
+  }
+
+  return ErrorCode;
+}
+} // namespace detail
+
+template <>
+std::error_code collectReplacementsFromDirectory(
+    const llvm::StringRef Directory, TUReplacements &TUs,
+    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
+  return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
+                                                  Diagnostics);
+}
+
+template <>
+std::error_code collectReplacementsFromDirectory(
+    const llvm::StringRef Directory, TUDiagnostics &TUs,
+    TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
+  return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
+                                                  Diagnostics);
+}
+
+/// Extract replacements from collected TranslationUnitReplacements and
+/// TranslationUnitDiagnostics and group them per file. Identical replacements
+/// from diagnostics are deduplicated.
+///
+/// \param[in] TUs Collection of all found and deserialized
+/// TranslationUnitReplacements.
+/// \param[in] TUDs Collection of all found and deserialized
+/// TranslationUnitDiagnostics.
+/// \param[in] SM Used to deduplicate paths.
+///
+/// \returns A map mapping FileEntry to a set of Replacement targeting that
+/// file.
+static llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
+groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
+                  const clang::SourceManager &SM) {
+  llvm::StringSet<> Warned;
+  llvm::DenseMap<FileEntryRef, std::vector<tooling::Replacement>>
+      GroupedReplacements;
+
+  // Deduplicate identical replacements in diagnostics unless they are from the
+  // same TU.
+  // FIXME: Find an efficient way to deduplicate on diagnostics level.
+  llvm::DenseMap<const FileEntry *,
+                 std::map<tooling::Replacement,
+                          const tooling::TranslationUnitDiagnostics *>>
+      DiagReplacements;
+
+  auto AddToGroup = [&](const tooling::Replacement &R,
+                        const tooling::TranslationUnitDiagnostics *SourceTU,
+                        const std::optional<std::string> BuildDir) {
+    // Use the file manager to deduplicate paths. FileEntries are
+    // automatically canonicalized. Since relative paths can come from different
+    // build directories, make them absolute immediately.
+    SmallString<128> Path = R.getFilePath();
+    if (BuildDir)
+      llvm::sys::fs::make_absolute(*BuildDir, Path);
+    else
+      SM.getFileManager().makeAbsolutePath(Path);
+
+    if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
+      if (SourceTU) {
+        auto &Replaces = DiagReplacements[*Entry];
+        auto It = Replaces.find(R);
+        if (It == Replaces.end())
+          Replaces.emplace(R, SourceTU);
+        else if (It->second != SourceTU)
+          // This replacement is a duplicate of one suggested by another TU.
+          return;
+      }
+      GroupedReplacements[*Entry].push_back(R);
+    } else if (Warned.insert(Path).second) {
+      errs() << "Described file '" << R.getFilePath()
+             << "' doesn't exist. Ignoring...\n";
+    }
+  };
+
+  for (const auto &TU : TUs)
+    for (const tooling::Replacement &R : TU.Replacements)
+      AddToGroup(R, nullptr, {});
+
+  for (const auto &TU : TUDs)
+    for (const auto &D : TU.Diagnostics)
+      if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
+        for (const auto &Fix : *ChoosenFix)
+          for (const tooling::Replacement &R : Fix.second)
+            AddToGroup(R, &TU, D.BuildDirectory);
+      }
+
+  // Sort replacements per file to keep consistent behavior when
+  // clang-apply-replacements run on differents machine.
+  for (auto &FileAndReplacements : GroupedReplacements) {
+    llvm::sort(FileAndReplacements.second);
+  }
+
+  return GroupedReplacements;
+}
+
+bool mergeAndDeduplicate(const TUReplacements &TUs, const TUDiagnostics &TUDs,
+                         FileToChangesMap &FileChanges,
+                         clang::SourceManager &SM, bool IgnoreInsertConflict) {
+  auto GroupedReplacements = groupReplacements(TUs, TUDs, SM);
+  bool ConflictDetected = false;
+
+  // To report conflicting replacements on corresponding file, all replacements
+  // are stored into 1 big AtomicChange.
+  for (const auto &FileAndReplacements : GroupedReplacements) {
+    FileEntryRef Entry = FileAndReplacements.first;
+    const SourceLocation BeginLoc =
+        SM.getLocForStartOfFile(SM.getOrCreateFileID(Entry, SrcMgr::C_User));
+    tooling::AtomicChange FileChange(Entry.getName(), Entry.getName());
+    for (const auto &R : FileAndReplacements.second) {
+      llvm::Error Err =
+          FileChange.replace(SM, BeginLoc.getLocWithOffset(R.getOffset()),
+                             R.getLength(), R.getReplacementText());
+      if (Err) {
+        // FIXME: This will report conflicts by pair using a file+offset format
+        // which is not so much human readable.
+        // A first improvement could be to translate offset to line+col. For
+        // this and without loosing error message some modifications around
+        // `tooling::ReplacementError` are need (access to
+        // `getReplacementErrString`).
+        // A better strategy could be to add a pretty printer methods for
+        // conflict reporting. Methods that could be parameterized to report a
+        // conflict in different format, file+offset, file+line+col, or even
+        // more human readable using VCS conflict markers.
+        // For now, printing directly the error reported by `AtomicChange` is
+        // the easiest solution.
+        errs() << llvm::toString(std::move(Err)) << "\n";
+        if (IgnoreInsertConflict) {
+          tooling::Replacements &Replacements = FileChange.getReplacements();
+          unsigned NewOffset =
+              Replacements.getShiftedCodePosition(R.getOffset());
+          unsigned NewLength = Replacements.getShiftedCodePosition(
+                                   R.getOffset() + R.getLength()) -
+                               NewOffset;
+          if (NewLength == R.getLength()) {
+            tooling::...
[truncated]

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 0175a1e4d33720ed7e827b3db5a36f88bdd790a3 86232bd5dd6fe28ea830f0b5fe3ffa4f48d545ce -- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp compiler-rt/lib/hwasan/hwasan_report.cpp
View the diff from clang-format here.
diff --git a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 20bafef724..dece201d37 100644
--- a/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ b/clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -41,7 +41,8 @@ namespace replace {
 
 namespace detail {
 
-static constexpr std::array<StringRef, 3> AllowedExtensions = {".yaml", ".yml", ""};
+static constexpr std::array<StringRef, 3> AllowedExtensions = {".yaml", ".yml",
+                                                               ""};
 
 template <typename TranslationUnits>
 static std::error_code collectReplacementsFromDirectory(
@@ -60,9 +61,9 @@ static std::error_code collectReplacementsFromDirectory(
       continue;
     }
 
-     if (!is_contained(AllowedExtensions, extension(I->path())))
+    if (!is_contained(AllowedExtensions, extension(I->path())))
       continue;
-    
+
     TUFiles.push_back(I->path());
 
     ErrorOr<std::unique_ptr<MemoryBuffer>> Out =
@@ -271,5 +272,5 @@ bool deleteReplacementFiles(const TUReplacementFiles &Files,
   return Success;
 }
 
-} 
-} 
+} // namespace replace
+} // namespace clang
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 6765888ce7..2ee7ac520c 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -12,7 +12,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "hwasan_report.h"
+
 #include <dlfcn.h>
+
 #include "hwasan.h"
 #include "hwasan_allocator.h"
 #include "hwasan_globals.h"
@@ -148,9 +150,9 @@ class SavedStackAllocations {
   u32 thread_id_;
 };
 
-class Decorator: public __sanitizer::SanitizerCommonDecorator {
+class Decorator : public __sanitizer::SanitizerCommonDecorator {
  public:
-  Decorator() : SanitizerCommonDecorator() { }
+  Decorator() : SanitizerCommonDecorator() {}
   const char *Access() { return Blue(); }
   const char *Allocation() const { return Magenta(); }
   const char *Origin() const { return Magenta(); }
@@ -164,7 +166,8 @@ static bool FindHeapAllocation(HeapAllocationsRingBuffer *rb, uptr tagged_addr,
                                HeapAllocationRecord *har, uptr *ring_index,
                                uptr *num_matching_addrs,
                                uptr *num_matching_addrs_4b) {
-  if (!rb) return false;
+  if (!rb)
+    return false;
 
   *num_matching_addrs = 0;
   *num_matching_addrs_4b = 0;
@@ -188,9 +191,7 @@ static bool FindHeapAllocation(HeapAllocationsRingBuffer *rb, uptr tagged_addr,
 
     // Measure the number of heap ring buffer entries that would have matched
     // if we only had 4 tag bits, which is the case for MTE.
-    auto untag_4b = [](uptr p) {
-      return p & ((1ULL << 60) - 1);
-    };
+    auto untag_4b = [](uptr p) { return p & ((1ULL << 60) - 1); };
     if (untag_4b(h.tagged_addr) <= untag_4b(tagged_addr) &&
         untag_4b(h.tagged_addr) + h.requested_size > untag_4b(tagged_addr)) {
       ++*num_matching_addrs_4b;
@@ -1058,25 +1059,25 @@ void ReportRegisters(const uptr *frame, uptr pc) {
   // result in a new logcat line, irrespective of whether a newline is present,
   // and so we wish to reduce the number of Printf() calls we have to make.
 #if defined(__aarch64__)
-  Printf("    x0  %016llx  x1  %016llx  x2  %016llx  x3  %016llx\n",
-       frame[0], frame[1], frame[2], frame[3]);
+  Printf("    x0  %016llx  x1  %016llx  x2  %016llx  x3  %016llx\n", frame[0],
+         frame[1], frame[2], frame[3]);
 #elif SANITIZER_RISCV64
   Printf("    sp  %016llx  x1  %016llx  x2  %016llx  x3  %016llx\n",
          reinterpret_cast<const u8 *>(frame) + 256, frame[1], frame[2],
          frame[3]);
 #endif
-  Printf("    x4  %016llx  x5  %016llx  x6  %016llx  x7  %016llx\n",
-       frame[4], frame[5], frame[6], frame[7]);
-  Printf("    x8  %016llx  x9  %016llx  x10 %016llx  x11 %016llx\n",
-       frame[8], frame[9], frame[10], frame[11]);
-  Printf("    x12 %016llx  x13 %016llx  x14 %016llx  x15 %016llx\n",
-       frame[12], frame[13], frame[14], frame[15]);
-  Printf("    x16 %016llx  x17 %016llx  x18 %016llx  x19 %016llx\n",
-       frame[16], frame[17], frame[18], frame[19]);
-  Printf("    x20 %016llx  x21 %016llx  x22 %016llx  x23 %016llx\n",
-       frame[20], frame[21], frame[22], frame[23]);
-  Printf("    x24 %016llx  x25 %016llx  x26 %016llx  x27 %016llx\n",
-       frame[24], frame[25], frame[26], frame[27]);
+  Printf("    x4  %016llx  x5  %016llx  x6  %016llx  x7  %016llx\n", frame[4],
+         frame[5], frame[6], frame[7]);
+  Printf("    x8  %016llx  x9  %016llx  x10 %016llx  x11 %016llx\n", frame[8],
+         frame[9], frame[10], frame[11]);
+  Printf("    x12 %016llx  x13 %016llx  x14 %016llx  x15 %016llx\n", frame[12],
+         frame[13], frame[14], frame[15]);
+  Printf("    x16 %016llx  x17 %016llx  x18 %016llx  x19 %016llx\n", frame[16],
+         frame[17], frame[18], frame[19]);
+  Printf("    x20 %016llx  x21 %016llx  x22 %016llx  x23 %016llx\n", frame[20],
+         frame[21], frame[22], frame[23]);
+  Printf("    x24 %016llx  x25 %016llx  x26 %016llx  x27 %016llx\n", frame[24],
+         frame[25], frame[26], frame[27]);
   // hwasan_check* reduces the stack pointer by 256, then __hwasan_tag_mismatch
   // passes it to this function.
 #if defined(__aarch64__)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants