NFC: Remove unnecessary context parameters from several Location getters.

The context can be recovered by other means in these methods and doesn't need to be passed explicitly.

PiperOrigin-RevId: 265532956
This commit is contained in:
River Riddle 2019-08-26 13:53:22 -07:00 committed by A. Unique TensorFlower
parent cb8c451541
commit 23251f9f3a
3 changed files with 16 additions and 20 deletions

View File

@ -109,13 +109,12 @@ public:
using Base::Base;
/// Return a uniqued call location object.
static Location get(Location callee, Location caller, MLIRContext *context);
static Location get(Location callee, Location caller);
/// 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 Location get(Location name, ArrayRef<Location> frames,
MLIRContext *context);
static Location get(Location name, ArrayRef<Location> frames);
/// The concrete location information this object presents.
Location getCallee() const;
@ -191,7 +190,7 @@ public:
/// Return a uniqued name location object. The child location must not be
/// another NameLoc.
static Location get(Identifier name, Location child, MLIRContext *context);
static Location get(Identifier name, Location child);
/// Return a uniqued name location object with an unknown child.
static Location get(Identifier name, MLIRContext *context);

View File

@ -26,19 +26,17 @@ using namespace mlir::detail;
// CallSiteLoc
//===----------------------------------------------------------------------===//
Location CallSiteLoc::get(Location callee, Location caller,
MLIRContext *context) {
return Base::get(context, StandardAttributes::CallSiteLocation, callee,
caller);
Location CallSiteLoc::get(Location callee, Location caller) {
return Base::get(callee->getContext(), StandardAttributes::CallSiteLocation,
callee, caller);
}
Location CallSiteLoc::get(Location name, ArrayRef<Location> frames,
MLIRContext *context) {
assert(!frames.empty() && "required at least 1 frames");
Location CallSiteLoc::get(Location name, ArrayRef<Location> frames) {
assert(!frames.empty() && "required at least 1 call frame");
Location caller = frames.back();
for (auto frame : llvm::reverse(frames.drop_back()))
caller = CallSiteLoc::get(frame, caller, context);
return CallSiteLoc::get(name, caller, context);
caller = CallSiteLoc::get(frame, caller);
return CallSiteLoc::get(name, caller);
}
Location CallSiteLoc::getCallee() const { return getImpl()->callee; }
@ -109,14 +107,15 @@ Attribute FusedLoc::getMetadata() const { return getImpl()->metadata; }
// NameLoc
//===----------------------------------------------------------------------===//
Location NameLoc::get(Identifier name, Location child, MLIRContext *context) {
Location NameLoc::get(Identifier name, Location child) {
assert(!child.isa<NameLoc>() &&
"a NameLoc cannot be used as a child of another NameLoc");
return Base::get(context, StandardAttributes::NameLocation, name, child);
return Base::get(child->getContext(), StandardAttributes::NameLocation, name,
child);
}
Location NameLoc::get(Identifier name, MLIRContext *context) {
return get(name, UnknownLoc::get(context), context);
return get(name, UnknownLoc::get(context));
}
/// Return the name identifier.

View File

@ -1692,8 +1692,6 @@ ParseResult Parser::parseLocation(LocationAttr &loc) {
/// unknown-location ::= 'unknown'
///
ParseResult Parser::parseCallSiteLocation(LocationAttr &loc) {
auto *ctx = getContext();
consumeToken(Token::bare_identifier);
// Parse the '('.
@ -1721,7 +1719,7 @@ ParseResult Parser::parseCallSiteLocation(LocationAttr &loc) {
return failure();
// Return the callsite location.
loc = CallSiteLoc::get(calleeLoc, callerLoc, ctx);
loc = CallSiteLoc::get(calleeLoc, callerLoc);
return success();
}
@ -1805,7 +1803,7 @@ ParseResult Parser::parseNameOrFileLineColLocation(LocationAttr &loc) {
if (childLoc.isa<NameLoc>())
return emitError(childSourceLoc,
"child of NameLoc cannot be another NameLoc");
loc = NameLoc::get(Identifier::get(str, ctx), childLoc, ctx);
loc = NameLoc::get(Identifier::get(str, ctx), childLoc);
// Parse the closing ')'.
if (parseToken(Token::r_paren,