[llvm] [Minidump] Support multiple exceptions in a minidump (PR #107319)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 15:16:35 PDT 2024


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 52dc4918ca8b874ddd4e4fcad873a66ecc5b6953 c67ad4098a5ffe220eae82d53d8b0e391318cae2 --extensions h,cpp -- llvm/include/llvm/Object/Minidump.h llvm/lib/Object/Minidump.cpp llvm/lib/ObjectYAML/MinidumpYAML.cpp llvm/unittests/Object/MinidumpTest.cpp llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Object/Minidump.h b/llvm/include/llvm/Object/Minidump.h
index cf3d88889e..1e9bc741d7 100644
--- a/llvm/include/llvm/Object/Minidump.h
+++ b/llvm/include/llvm/Object/Minidump.h
@@ -219,70 +219,67 @@ public:
     bool IsEnd;
   };
 
-class ExceptionStreamsIterator {
+  class ExceptionStreamsIterator {
   public:
-
-    static ExceptionStreamsIterator begin(ArrayRef<minidump::Directory> Streams, const MinidumpFile *File) {
+    static ExceptionStreamsIterator begin(ArrayRef<minidump::Directory> Streams,
+                                          const MinidumpFile *File) {
       return ExceptionStreamsIterator(Streams, File);
     }
 
-    static ExceptionStreamsIterator end() {
-      return ExceptionStreamsIterator();
-    }
+    static ExceptionStreamsIterator end() { return ExceptionStreamsIterator(); }
 
     bool operator==(const ExceptionStreamsIterator &R) const {
       return Streams.empty() && R.Streams.empty();
     }
 
-    bool operator!=(const ExceptionStreamsIterator &R) const { return !(*this == R); }
+    bool operator!=(const ExceptionStreamsIterator &R) const {
+      return !(*this == R);
+    }
 
-    Expected<const minidump::ExceptionStream &>
-    operator*() {
+    Expected<const minidump::ExceptionStream &> operator*() {
       return ReadCurrent();
     }
 
-    Expected<const minidump::ExceptionStream &>
-    operator->() {
+    Expected<const minidump::ExceptionStream &> operator->() {
       return ReadCurrent();
     }
 
-    ExceptionStreamsIterator &
-    operator++ () {
+    ExceptionStreamsIterator &operator++() {
       if (!Streams.empty())
         Streams = Streams.drop_front();
 
-
       return *this;
     }
 
   private:
-    ExceptionStreamsIterator(ArrayRef<minidump::Directory> Streams, const MinidumpFile *File)
-      : Streams(Streams), File(File) {}
+    ExceptionStreamsIterator(ArrayRef<minidump::Directory> Streams,
+                             const MinidumpFile *File)
+        : Streams(Streams), File(File) {}
 
-    ExceptionStreamsIterator() : Streams(ArrayRef<minidump::Directory>()), File(nullptr) {}
+    ExceptionStreamsIterator()
+        : Streams(ArrayRef<minidump::Directory>()), File(nullptr) {}
 
     ArrayRef<minidump::Directory> Streams;
     const MinidumpFile *File;
 
-    Expected<const minidump::ExceptionStream&> ReadCurrent() {
+    Expected<const minidump::ExceptionStream &> ReadCurrent() {
       assert(!Streams.empty());
       Expected<const minidump::ExceptionStream &> ExceptionStream =
           File->getExceptionStream(Streams.front());
       if (!ExceptionStream)
         return ExceptionStream.takeError();
-      
+
       return ExceptionStream;
     }
   };
 
   using FallibleMemory64Iterator = llvm::fallible_iterator<Memory64Iterator>;
 
-  /// Returns an iterator that reads each exception stream independently. The 
-  /// contents of the exception strema are not validated before being read, an 
+  /// Returns an iterator that reads each exception stream independently. The
+  /// contents of the exception strema are not validated before being read, an
   /// error will be returned if the stream is not large enough to contain an
   /// exception stream, or if the stream points beyond the end of the file.
-  iterator_range<ExceptionStreamsIterator>
-  getExceptionStreams() const;
+  iterator_range<ExceptionStreamsIterator> getExceptionStreams() const;
 
   /// Returns an iterator that pairs each descriptor with it's respective
   /// content from the Memory64List stream. An error is returned if the file
@@ -325,7 +322,8 @@ private:
                DenseMap<minidump::StreamType, std::size_t> StreamMap,
                std::vector<minidump::Directory> ExceptionStreams)
       : Binary(ID_Minidump, Source), Header(Header), Streams(Streams),
-        StreamMap(std::move(StreamMap)), ExceptionStreams(std::move(ExceptionStreams)) {}
+        StreamMap(std::move(StreamMap)),
+        ExceptionStreams(std::move(ExceptionStreams)) {}
 
   ArrayRef<uint8_t> getData() const {
     return arrayRefFromStringRef(Data.getBuffer());
diff --git a/llvm/lib/Object/Minidump.cpp b/llvm/lib/Object/Minidump.cpp
index f334cd2a9a..e53d11ddbe 100644
--- a/llvm/lib/Object/Minidump.cpp
+++ b/llvm/lib/Object/Minidump.cpp
@@ -166,8 +166,8 @@ MinidumpFile::create(MemoryBufferRef Source) {
       return createError("Duplicate stream type");
   }
 
-  return std::unique_ptr<MinidumpFile>(
-      new MinidumpFile(Source, Hdr, *ExpectedStreams, std::move(StreamMap), ExceptionStreams));
+  return std::unique_ptr<MinidumpFile>(new MinidumpFile(
+      Source, Hdr, *ExpectedStreams, std::move(StreamMap), ExceptionStreams));
 }
 
 iterator_range<MinidumpFile::FallibleMemory64Iterator>
diff --git a/llvm/unittests/Object/MinidumpTest.cpp b/llvm/unittests/Object/MinidumpTest.cpp
index 6dcdccc4de..7e5ec35c41 100644
--- a/llvm/unittests/Object/MinidumpTest.cpp
+++ b/llvm/unittests/Object/MinidumpTest.cpp
@@ -751,8 +751,7 @@ TEST(MinidumpFile, getExceptionStream) {
   auto ExpectedFile = create(Data);
   ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
   const MinidumpFile &File = **ExpectedFile;
-  auto ExceptionIterator =
-      File.getExceptionStreams().begin();
+  auto ExceptionIterator = File.getExceptionStreams().begin();
 
   Expected<const ExceptionStream &> ExpectedStream = *ExceptionIterator;
   ASSERT_THAT_EXPECTED(ExpectedStream, Succeeded());
diff --git a/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp b/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
index 6b2963902a..c805665e0b 100644
--- a/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
+++ b/llvm/unittests/ObjectYAML/MinidumpYAMLTest.cpp
@@ -162,8 +162,7 @@ Streams:
 
   ASSERT_EQ(1u, File.streams().size());
 
-  auto ExceptionIterator =
-      File.getExceptionStreams().begin();
+  auto ExceptionIterator = File.getExceptionStreams().begin();
 
   Expected<const ExceptionStream &> ExpectedStream = *ExceptionIterator;
 
@@ -207,8 +206,7 @@ Streams:
 
   ASSERT_EQ(1u, File.streams().size());
 
-  auto ExceptionIterator =
-      File.getExceptionStreams().begin();
+  auto ExceptionIterator = File.getExceptionStreams().begin();
 
   Expected<const ExceptionStream &> ExpectedStream = *ExceptionIterator;
   ASSERT_THAT_EXPECTED(ExpectedStream, Succeeded());
@@ -264,8 +262,7 @@ Streams:
 
   ASSERT_EQ(1u, File.streams().size());
 
-  auto ExceptionIterator =
-      File.getExceptionStreams().begin();
+  auto ExceptionIterator = File.getExceptionStreams().begin();
 
   Expected<const ExceptionStream &> ExpectedStream = *ExceptionIterator;
 
@@ -317,8 +314,7 @@ Streams:
 
   ASSERT_EQ(1u, File.streams().size());
 
-  auto ExceptionIterator =
-      File.getExceptionStreams().begin();
+  auto ExceptionIterator = File.getExceptionStreams().begin();
 
   Expected<const ExceptionStream &> ExpectedStream = *ExceptionIterator;
 
@@ -405,7 +401,6 @@ Streams:
   ASSERT_THAT(*DescTwoExpectedContentSlice, arrayRefFromStringRef("world"));
 
   ASSERT_EQ(Iterator, MemoryList.end());
-
 }
 
 // Test that we can parse multiple exception streams.
@@ -434,7 +429,7 @@ Streams:
       Exception Record: 0x0102030405060708
       Exception Address: 0x0a0b0c0d0e0f1011
     Thread Context:  3DeadBeefDefacedABadCafe)");
-  
+
   ASSERT_THAT_EXPECTED(ExpectedFile, Succeeded());
   object::MinidumpFile &File = **ExpectedFile;
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/107319


More information about the llvm-commits mailing list