NFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'.
PiperOrigin-RevId: 255078768
diff --git a/examples/toy/Ch2/mlir/MLIRGen.cpp b/examples/toy/Ch2/mlir/MLIRGen.cpp
index 1abcc97..f4ad20f 100644
--- a/examples/toy/Ch2/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch2/mlir/MLIRGen.cpp
@@ -113,7 +113,7 @@
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
/// Helper conversion for a Toy AST location to an MLIR location.
- mlir::FileLineColLoc loc(Location loc) {
+ mlir::Location loc(Location loc) {
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
loc.line, loc.col, &context);
}
diff --git a/examples/toy/Ch3/mlir/MLIRGen.cpp b/examples/toy/Ch3/mlir/MLIRGen.cpp
index 1aa57c1..715f401 100644
--- a/examples/toy/Ch3/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch3/mlir/MLIRGen.cpp
@@ -114,7 +114,7 @@
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
/// Helper conversion for a Toy AST location to an MLIR location.
- mlir::FileLineColLoc loc(Location loc) {
+ mlir::Location loc(Location loc) {
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
loc.line, loc.col, &context);
}
diff --git a/examples/toy/Ch4/mlir/MLIRGen.cpp b/examples/toy/Ch4/mlir/MLIRGen.cpp
index 16542e9..03049ed 100644
--- a/examples/toy/Ch4/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch4/mlir/MLIRGen.cpp
@@ -114,7 +114,7 @@
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
/// Helper conversion for a Toy AST location to an MLIR location.
- mlir::FileLineColLoc loc(Location loc) {
+ mlir::Location loc(Location loc) {
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
loc.line, loc.col, &context);
}
diff --git a/examples/toy/Ch5/mlir/MLIRGen.cpp b/examples/toy/Ch5/mlir/MLIRGen.cpp
index 16542e9..03049ed 100644
--- a/examples/toy/Ch5/mlir/MLIRGen.cpp
+++ b/examples/toy/Ch5/mlir/MLIRGen.cpp
@@ -114,7 +114,7 @@
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
/// Helper conversion for a Toy AST location to an MLIR location.
- mlir::FileLineColLoc loc(Location loc) {
+ mlir::Location loc(Location loc) {
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
loc.line, loc.col, &context);
}
diff --git a/include/mlir/IR/Builders.h b/include/mlir/IR/Builders.h
index ce35336..b99f091 100644
--- a/include/mlir/IR/Builders.h
+++ b/include/mlir/IR/Builders.h
@@ -65,9 +65,9 @@
Module *createModule();
// Locations.
- UnknownLoc getUnknownLoc();
- FileLineColLoc getFileLineColLoc(Identifier filename, unsigned line,
- unsigned column);
+ Location getUnknownLoc();
+ Location getFileLineColLoc(Identifier filename, unsigned line,
+ unsigned column);
Location getFusedLoc(ArrayRef<Location> locs,
Attribute metadata = Attribute());
diff --git a/include/mlir/IR/Location.h b/include/mlir/IR/Location.h
index 0209356..32fe0f4 100644
--- a/include/mlir/IR/Location.h
+++ b/include/mlir/IR/Location.h
@@ -109,14 +109,13 @@
using Base::Base;
/// Return a uniqued call location object.
- static CallSiteLoc get(Location callee, Location caller,
- MLIRContext *context);
+ static Location get(Location callee, Location caller, MLIRContext *context);
/// Return a call site location which represents a name reference in one line
/// or a stack of frames. The input frames are ordered from innermost to
/// outermost.
- static CallSiteLoc get(Location name, ArrayRef<Location> frames,
- MLIRContext *context);
+ static Location get(Location name, ArrayRef<Location> frames,
+ MLIRContext *context);
/// The concrete location information this object presents.
Location getCallee() const;
@@ -140,10 +139,10 @@
using Base::Base;
/// Return a uniqued FileLineCol location object.
- static FileLineColLoc get(Identifier filename, unsigned line, unsigned column,
- MLIRContext *context);
- static FileLineColLoc get(StringRef filename, unsigned line, unsigned column,
- MLIRContext *context);
+ static Location get(Identifier filename, unsigned line, unsigned column,
+ MLIRContext *context);
+ static Location get(StringRef filename, unsigned line, unsigned column,
+ MLIRContext *context);
StringRef getFilename() const;
@@ -166,9 +165,9 @@
/// Return a uniqued Fused Location object. The first location in the list
/// will get precedence during diagnostic emission, with the rest being
/// displayed as supplementary "fused from here" style notes.
- static LocationAttr get(ArrayRef<Location> locs, Attribute metadata,
- MLIRContext *context);
- static LocationAttr get(ArrayRef<Location> locs, MLIRContext *context) {
+ static Location get(ArrayRef<Location> locs, Attribute metadata,
+ MLIRContext *context);
+ static Location get(ArrayRef<Location> locs, MLIRContext *context) {
return get(locs, Attribute(), context);
}
@@ -192,10 +191,10 @@
/// Return a uniqued name location object. The child location must not be
/// another NameLoc.
- static NameLoc get(Identifier name, Location child, MLIRContext *context);
+ static Location get(Identifier name, Location child, MLIRContext *context);
/// Return a uniqued name location object with an unknown child.
- static NameLoc get(Identifier name, MLIRContext *context);
+ static Location get(Identifier name, MLIRContext *context);
/// Return the name identifier.
Identifier getName() const;
@@ -216,7 +215,7 @@
using Base::Base;
/// Get an instance of the UnknownLoc.
- static UnknownLoc get(MLIRContext *context);
+ static Location get(MLIRContext *context);
/// Methods for support type inquiry through isa, cast, and dyn_cast.
static bool kindof(unsigned kind) {
diff --git a/lib/IR/Builders.cpp b/lib/IR/Builders.cpp
index e2c3a55..43e6a44 100644
--- a/lib/IR/Builders.cpp
+++ b/lib/IR/Builders.cpp
@@ -38,10 +38,10 @@
// Locations.
//===----------------------------------------------------------------------===//
-UnknownLoc Builder::getUnknownLoc() { return UnknownLoc::get(context); }
+Location Builder::getUnknownLoc() { return UnknownLoc::get(context); }
-FileLineColLoc Builder::getFileLineColLoc(Identifier filename, unsigned line,
- unsigned column) {
+Location Builder::getFileLineColLoc(Identifier filename, unsigned line,
+ unsigned column) {
return FileLineColLoc::get(filename, line, column, context);
}
diff --git a/lib/IR/Location.cpp b/lib/IR/Location.cpp
index eae46fa..83b579c 100644
--- a/lib/IR/Location.cpp
+++ b/lib/IR/Location.cpp
@@ -26,14 +26,14 @@
// CallSiteLoc
//===----------------------------------------------------------------------===//
-CallSiteLoc CallSiteLoc::get(Location callee, Location caller,
- MLIRContext *context) {
+Location CallSiteLoc::get(Location callee, Location caller,
+ MLIRContext *context) {
return Base::get(context, StandardAttributes::CallSiteLocation, callee,
caller);
}
-CallSiteLoc CallSiteLoc::get(Location name, ArrayRef<Location> frames,
- MLIRContext *context) {
+Location CallSiteLoc::get(Location name, ArrayRef<Location> frames,
+ MLIRContext *context) {
assert(!frames.empty() && "required at least 1 frames");
Location caller = frames.back();
for (auto frame : llvm::reverse(frames.drop_back()))
@@ -49,14 +49,14 @@
// FileLineColLoc
//===----------------------------------------------------------------------===//
-FileLineColLoc FileLineColLoc::get(Identifier filename, unsigned line,
- unsigned column, MLIRContext *context) {
+Location FileLineColLoc::get(Identifier filename, unsigned line,
+ unsigned column, MLIRContext *context) {
return Base::get(context, StandardAttributes::FileLineColLocation, filename,
line, column);
}
-FileLineColLoc FileLineColLoc::get(StringRef filename, unsigned line,
- unsigned column, MLIRContext *context) {
+Location FileLineColLoc::get(StringRef filename, unsigned line, unsigned column,
+ MLIRContext *context) {
return get(Identifier::get(filename.empty() ? "-" : filename, context), line,
column, context);
}
@@ -69,8 +69,8 @@
// FusedLoc
//===----------------------------------------------------------------------===//
-LocationAttr FusedLoc::get(ArrayRef<Location> locs, Attribute metadata,
- MLIRContext *context) {
+Location FusedLoc::get(ArrayRef<Location> locs, Attribute metadata,
+ MLIRContext *context) {
// Unique the set of locations to be fused.
llvm::SmallSetVector<Location, 4> decomposedLocs;
for (auto loc : locs) {
@@ -109,13 +109,13 @@
// NameLoc
//===----------------------------------------------------------------------===//
-NameLoc NameLoc::get(Identifier name, Location child, MLIRContext *context) {
+Location NameLoc::get(Identifier name, Location child, MLIRContext *context) {
assert(!child.isa<NameLoc>() &&
"a NameLoc cannot be used as a child of another NameLoc");
return Base::get(context, StandardAttributes::NameLocation, name, child);
}
-NameLoc NameLoc::get(Identifier name, MLIRContext *context) {
+Location NameLoc::get(Identifier name, MLIRContext *context) {
return get(name, UnknownLoc::get(context), context);
}
diff --git a/lib/IR/MLIRContext.cpp b/lib/IR/MLIRContext.cpp
index 04a01c4..63206c3 100644
--- a/lib/IR/MLIRContext.cpp
+++ b/lib/IR/MLIRContext.cpp
@@ -592,7 +592,7 @@
return context->getImpl().unitAttr;
}
-UnknownLoc UnknownLoc::get(MLIRContext *context) {
+Location UnknownLoc::get(MLIRContext *context) {
return context->getImpl().unknownLocAttr;
}
diff --git a/lib/SPIRV/Serialization/Deserializer.cpp b/lib/SPIRV/Serialization/Deserializer.cpp
index 8341c88..f55805d 100644
--- a/lib/SPIRV/Serialization/Deserializer.cpp
+++ b/lib/SPIRV/Serialization/Deserializer.cpp
@@ -77,7 +77,7 @@
MLIRContext *context;
// TODO(antiagainst): create Location subclass for binary blob
- UnknownLoc unknownLoc;
+ Location unknownLoc;
/// The SPIR-V ModuleOp.
Optional<spirv::ModuleOp> module;
diff --git a/lib/Transforms/DialectConversion.cpp b/lib/Transforms/DialectConversion.cpp
index fee08e4..673544d 100644
--- a/lib/Transforms/DialectConversion.cpp
+++ b/lib/Transforms/DialectConversion.cpp
@@ -89,7 +89,7 @@
/// An instance of the unknown location that is used when generating
/// producers.
- UnknownLoc loc;
+ Location loc;
};
constexpr StringLiteral ArgConverter::kCastName;
diff --git a/lib/Transforms/StripDebugInfo.cpp b/lib/Transforms/StripDebugInfo.cpp
index 1691976..f97f549 100644
--- a/lib/Transforms/StripDebugInfo.cpp
+++ b/lib/Transforms/StripDebugInfo.cpp
@@ -30,7 +30,7 @@
void StripDebugInfo::runOnFunction() {
Function &func = getFunction();
- UnknownLoc unknownLoc = UnknownLoc::get(&getContext());
+ auto unknownLoc = UnknownLoc::get(&getContext());
// Strip the debug info from the function and its operations.
func.setLoc(unknownLoc);