[flang][nfc] Tidy up in CodeGen.cpp and TypeConverter.h
authorAndrzej Warzynski <andrzej.warzynski@arm.com>
Wed, 10 Nov 2021 15:24:39 +0000 (15:24 +0000)
committerAndrzej Warzynski <andrzej.warzynski@arm.com>
Thu, 11 Nov 2021 10:08:55 +0000 (10:08 +0000)
Some header `#include`s that belong in TypeConverter.h rather than in
CodeGen.cpp are moved accordingly. As TypeConverter.h is currently only
used in CodeGen.cpp, this wouldn't cause any build issues (ultimately,
all the required headers are included). However, this would become a problem
when including TypeConverter.h elsewhere.

Also, from [1], "(...) include all of the header files that you are
using ". This is currently not the case in TypeConverter.h and hence the
`#include`s should be moved.

I've also added missing namespace qualifiers in a few places in
TypeConverter.h

[1] https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible

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

flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/TypeConverter.h

index 9c9fcb204605069a12cc50c17023abf388245a23..6018429ac51cd156c0c0489e1747c91b4fa4d991 100644 (file)
 #include "PassDetail.h"
 #include "flang/ISO_Fortran_binding.h"
 #include "flang/Optimizer/Dialect/FIROps.h"
-#include "flang/Optimizer/Dialect/FIRType.h"
-#include "flang/Optimizer/Support/FIRContext.h"
 #include "mlir/Conversion/ArithmeticToLLVM/ArithmeticToLLVM.h"
 #include "mlir/Conversion/LLVMCommon/Pattern.h"
-#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Matchers.h"
index 859074e55d5a5fcce21a85649bcedf46b1528ee4..a9129953797e9dcf0fdc3b77594fc2c6efb90e12 100644 (file)
 #include "DescriptorModel.h"
 #include "Target.h"
 #include "flang/Lower/Todo.h" // remove when TODO's are done
+#include "flang/Optimizer/Dialect/FIRType.h"
 #include "flang/Optimizer/Support/FIRContext.h"
 #include "flang/Optimizer/Support/KindMapping.h"
-#include "llvm/ADT/StringMap.h"
+#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "llvm/Support/Debug.h"
 
 // Position of the different values in a `fir.box`.
@@ -111,7 +112,7 @@ public:
   // the addendum defined in descriptor.h.
   mlir::Type convertBoxType(BoxType box, int rank = unknownRank()) {
     // (base_addr*, elem_len, version, rank, type, attribute, f18Addendum, [dim]
-    SmallVector<mlir::Type> dataDescFields;
+    llvm::SmallVector<mlir::Type> dataDescFields;
     mlir::Type ele = box.getEleTy();
     // remove fir.heap/fir.ref/fir.ptr
     if (auto removeIndirection = fir::dyn_cast_ptrEleTy(ele))
@@ -269,7 +270,7 @@ public:
     case llvm::Type::TypeID::FP128TyID:
       return mlir::FloatType::getF128(&getContext());
     default:
-      emitError(UnknownLoc::get(&getContext()))
+      mlir::emitError(mlir::UnknownLoc::get(&getContext()))
           << "unsupported type: !fir.real<" << kind << ">";
       return {};
     }