[flang-commits] [flang] 1e96c4b - [fir][NFC] Fix couple of clang-tidy warnings

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Mon Oct 4 11:55:11 PDT 2021


Author: Valentin Clement
Date: 2021-10-04T20:55:06+02:00
New Revision: 1e96c4b50831bea4698e2a4c7571ef12e02a8539

URL: https://github.com/llvm/llvm-project/commit/1e96c4b50831bea4698e2a4c7571ef12e02a8539
DIFF: https://github.com/llvm/llvm-project/commit/1e96c4b50831bea4698e2a4c7571ef12e02a8539.diff

LOG: [fir][NFC] Fix couple of clang-tidy warnings

Fix some clang-tidy wrning in flang/Optimizer/Support and
remove explicit number of inlined elements for SmallVector. This
is mostly to sync with the changes from fir-dev.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D111044

Added: 
    

Modified: 
    flang/include/flang/Optimizer/Support/FIRContext.h
    flang/include/flang/Optimizer/Support/InternalNames.h
    flang/lib/Optimizer/Support/FIRContext.cpp
    flang/lib/Optimizer/Support/InternalNames.cpp
    flang/lib/Optimizer/Support/KindMapping.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Optimizer/Support/FIRContext.h b/flang/include/flang/Optimizer/Support/FIRContext.h
index 7f236081e2710..8dfe7802b123e 100644
--- a/flang/include/flang/Optimizer/Support/FIRContext.h
+++ b/flang/include/flang/Optimizer/Support/FIRContext.h
@@ -22,7 +22,7 @@
 
 namespace mlir {
 class ModuleOp;
-}
+} // namespace mlir
 
 namespace fir {
 class KindMapping;

diff  --git a/flang/include/flang/Optimizer/Support/InternalNames.h b/flang/include/flang/Optimizer/Support/InternalNames.h
index 36e3ed093ca42..b6e1e3728d575 100644
--- a/flang/include/flang/Optimizer/Support/InternalNames.h
+++ b/flang/include/flang/Optimizer/Support/InternalNames.h
@@ -54,10 +54,10 @@ struct NameUniquer {
         : modules{modules.begin(), modules.end()}, host{host}, name{name},
           kinds{kinds.begin(), kinds.end()} {}
 
-    llvm::SmallVector<std::string, 2> modules;
+    llvm::SmallVector<std::string> modules;
     llvm::Optional<std::string> host;
     std::string name;
-    llvm::SmallVector<std::int64_t, 4> kinds;
+    llvm::SmallVector<std::int64_t> kinds;
   };
 
   /// Unique a common block name

diff  --git a/flang/lib/Optimizer/Support/FIRContext.cpp b/flang/lib/Optimizer/Support/FIRContext.cpp
index b4910dff9f7df..890364a0f1473 100644
--- a/flang/lib/Optimizer/Support/FIRContext.cpp
+++ b/flang/lib/Optimizer/Support/FIRContext.cpp
@@ -33,14 +33,14 @@ static constexpr const char *kindMapName = "fir.kindmap";
 static constexpr const char *defKindName = "fir.defaultkind";
 
 void fir::setKindMapping(mlir::ModuleOp mod, fir::KindMapping &kindMap) {
-  auto ctx = mod.getContext();
+  auto *ctx = mod.getContext();
   mod->setAttr(kindMapName, mlir::StringAttr::get(ctx, kindMap.mapToString()));
   auto defs = kindMap.defaultsToString();
   mod->setAttr(defKindName, mlir::StringAttr::get(ctx, defs));
 }
 
 fir::KindMapping fir::getKindMapping(mlir::ModuleOp mod) {
-  auto ctx = mod.getContext();
+  auto *ctx = mod.getContext();
   if (auto defs = mod->getAttrOfType<mlir::StringAttr>(defKindName)) {
     auto defVals = fir::KindMapping::toDefaultKinds(defs.getValue());
     if (auto maps = mod->getAttrOfType<mlir::StringAttr>(kindMapName))

diff  --git a/flang/lib/Optimizer/Support/InternalNames.cpp b/flang/lib/Optimizer/Support/InternalNames.cpp
index bd281638e443c..08dd927e495a3 100644
--- a/flang/lib/Optimizer/Support/InternalNames.cpp
+++ b/flang/lib/Optimizer/Support/InternalNames.cpp
@@ -21,7 +21,7 @@ static llvm::cl::opt<std::string> mainEntryName(
     llvm::cl::desc("override the name of the default PROGRAM entry (may be "
                    "helpful for using other runtimes)"));
 
-constexpr std::int64_t BAD_VALUE = -1;
+constexpr std::int64_t badValue = -1;
 
 inline std::string prefix() { return "_Q"; }
 
@@ -69,9 +69,9 @@ static std::int64_t readInt(llvm::StringRef uniq, std::size_t &i,
   for (i = init; i < end && uniq[i] >= '0' && uniq[i] <= '9'; ++i) {
     // do nothing
   }
-  std::int64_t result = BAD_VALUE;
+  std::int64_t result = badValue;
   if (uniq.substr(init, i - init).getAsInteger(10, result))
-    return BAD_VALUE;
+    return badValue;
   return result;
 }
 
@@ -223,10 +223,10 @@ llvm::StringRef fir::NameUniquer::doProgramEntry() {
 std::pair<fir::NameUniquer::NameKind, fir::NameUniquer::DeconstructedName>
 fir::NameUniquer::deconstruct(llvm::StringRef uniq) {
   if (uniq.startswith("_Q")) {
-    llvm::SmallVector<std::string, 4> modules;
+    llvm::SmallVector<std::string> modules;
     llvm::Optional<std::string> host;
     std::string name;
-    llvm::SmallVector<std::int64_t, 8> kinds;
+    llvm::SmallVector<std::int64_t> kinds;
     NameKind nk = NameKind::NOT_UNIQUED;
     for (std::size_t i = 2, end{uniq.size()}; i != end;) {
       switch (uniq[i]) {

diff  --git a/flang/lib/Optimizer/Support/KindMapping.cpp b/flang/lib/Optimizer/Support/KindMapping.cpp
index a8abcb24073a6..d22a438e3b812 100644
--- a/flang/lib/Optimizer/Support/KindMapping.cpp
+++ b/flang/lib/Optimizer/Support/KindMapping.cpp
@@ -49,8 +49,8 @@ static constexpr const char *kwPPCFP128 = "PPC_FP128";
 /// Integral types default to the kind value being the size of the value in
 /// bytes. The default is to scale from bytes to bits.
 static Bitsize defaultScalingKind(KindTy kind) {
-  const unsigned BITS_IN_BYTE = 8;
-  return kind * BITS_IN_BYTE;
+  const unsigned bitsInByte = 8;
+  return kind * bitsInByte;
 }
 
 /// Floating-point types default to the kind value being the size of the value


        


More information about the flang-commits mailing list