[PATCH] D23821: Minor cleanup of the class Pattern

Alexander Shaposhnikov via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 23 15:53:16 PDT 2016


alexshap created this revision.
alexshap added reviewers: dsanders, probinson.
alexshap added a subscriber: cfe-commits.
alexshap set the repository for this revision to rL LLVM.
alexshap changed the visibility of this Differential Revision from "Public (No Login Required)" to "All Users".
Herald added a reviewer: vkalintiris.

1. Add the "explicit" specifier to the single-argument constructor of Pattern
2. Reorder the fields to remove excessive padding (8 bytes).

/Users/alexshap/LLVM_CLEAN/llvm/utils/FileCheck/FileCheck.cpp:100:7: warning: Excessive padding in 'class Pattern' (8 padding bytes, where 0 is optimal). Optimal fields order: PatternLoc, FixedStr, RegExStr, VariableUses, VariableDefs, CheckTy, LineNumber, consider reordering the fields or adding explicit padding members

clang-tidy -checks=google-explicit-constructor utils/FileCheck/FileCheck.cpp - no other issues found
clang-format -i -lines:126:128 utils/FileCheck/FileCheck.cpp - done

Repository:
  rL LLVM

https://reviews.llvm.org/D23821

Files:
  utils/FileCheck/FileCheck.cpp

Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ utils/FileCheck/FileCheck.cpp
@@ -100,8 +100,6 @@
 class Pattern {
   SMLoc PatternLoc;
 
-  Check::CheckType CheckTy;
-
   /// FixedStr - If non-empty, this pattern is a fixed string match with the
   /// specified fixed string.
   StringRef FixedStr;
@@ -109,9 +107,6 @@
   /// RegEx - If non-empty, this is a regex pattern.
   std::string RegExStr;
 
-  /// \brief Contains the number of line this pattern is in.
-  unsigned LineNumber;
-
   /// VariableUses - Entries in this vector map to uses of a variable in the
   /// pattern, e.g. "foo[[bar]]baz".  In this case, the RegExStr will contain
   /// "foobaz" and we'll get an entry in this vector that tells us to insert the
@@ -123,11 +118,14 @@
   /// E.g. for the pattern "foo[[bar:.*]]baz", VariableDefs will map "bar" to 1.
   std::map<StringRef, unsigned> VariableDefs;
 
+  Check::CheckType CheckTy;
+
+  /// \brief Contains the number of line this pattern is in.
+  unsigned LineNumber;
+
 public:
+  explicit Pattern(Check::CheckType Ty) : CheckTy(Ty) {}
 
-  Pattern(Check::CheckType Ty)
-    : CheckTy(Ty) { }
-
   /// getLoc - Return the location in source code.
   SMLoc getLoc() const { return PatternLoc; }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23821.69051.patch
Type: text/x-patch
Size: 1323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160823/739a1b8d/attachment.bin>


More information about the cfe-commits mailing list