[PATCH] D114256: [clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls

Bal√°zs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 29 00:57:30 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe1d0673aeeec: [clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls (authored by steakhal).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114256/new/

https://reviews.llvm.org/D114256

Files:
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-invalid-decl-no-crash.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-invalid-decl-no-crash.cpp
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-invalid-decl-no-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s altera-struct-pack-align %t -- -header-filter=.*
+
+struct Foo {
+  member; // no-crash
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:3: error: C++ requires a type specifier for all declarations [clang-diagnostic-error]
Index: clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -51,6 +51,10 @@
   if (Struct->isTemplated())
      return;
 
+  // Packing and alignment requirements for invalid decls are meaningless.
+  if (Struct->isInvalidDecl())
+    return;
+
   // Get sizing info for the struct.
   llvm::SmallVector<std::pair<unsigned int, unsigned int>, 10> FieldSizes;
   unsigned int TotalBitSize = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114256.390274.patch
Type: text/x-patch
Size: 1165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211129/e85753a9/attachment-0001.bin>


More information about the cfe-commits mailing list