-
Notifications
You must be signed in to change notification settings - Fork 14.5k
WIP: Extend SourceLocation to 64 bits. #146314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
7346173
5a2700e
755e671
68ffab3
b1f6205
86f0440
9dbf694
da34ffe
6be8784
c5a21c5
7f125a0
9845547
4794062
25aa128
3527a02
31c773f
e63c988
9dd6cdf
181420a
51c4afc
4379826
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -682,6 +682,11 @@ class DeclarationNameTable { | |
DeclarationName getCXXLiteralOperatorName(const IdentifierInfo *II); | ||
}; | ||
|
||
struct CXXOperatorSourceInfo { | ||
SourceLocation::UIntTy BeginOpNameLoc; | ||
SourceLocation::UIntTy EndOpNameLoc; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why this is ::UIntTy instead of just the source location? I realize it was before, but now that we're indirecting the object, I wonder if the original reason still exists. |
||
}; | ||
|
||
/// DeclarationNameLoc - Additional source/type location info | ||
/// for a declaration name. Needs a DeclarationName in order | ||
/// to be interpreted correctly. | ||
|
@@ -698,8 +703,7 @@ class DeclarationNameLoc { | |
|
||
// The location (if any) of the operator keyword is stored elsewhere. | ||
struct CXXOpName { | ||
SourceLocation::UIntTy BeginOpNameLoc; | ||
SourceLocation::UIntTy EndOpNameLoc; | ||
CXXOperatorSourceInfo* OInfo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much does this indirection save perf wise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the performance impact on this indirection -- this is for the C++ operation call, which is rare in practice (the perf here https://llvm-compile-time-tracker.com/compare.php?from=ff5a67315305f59f91041bad8b905e161b872442&to=38c519de69b127faa823078d3faff5670bc60209&stat=instructions:u) |
||
}; | ||
|
||
// The location (if any) of the operator keyword is stored elsewhere. | ||
|
@@ -719,11 +723,6 @@ class DeclarationNameLoc { | |
|
||
void setNamedTypeLoc(TypeSourceInfo *TInfo) { NamedType.TInfo = TInfo; } | ||
|
||
void setCXXOperatorNameRange(SourceRange Range) { | ||
CXXOperatorName.BeginOpNameLoc = Range.getBegin().getRawEncoding(); | ||
CXXOperatorName.EndOpNameLoc = Range.getEnd().getRawEncoding(); | ||
} | ||
|
||
void setCXXLiteralOperatorNameLoc(SourceLocation Loc) { | ||
CXXLiteralOperatorName.OpNameLoc = Loc.getRawEncoding(); | ||
} | ||
|
@@ -739,12 +738,18 @@ class DeclarationNameLoc { | |
|
||
/// Return the beginning location of the getCXXOperatorNameRange() range. | ||
SourceLocation getCXXOperatorNameBeginLoc() const { | ||
return SourceLocation::getFromRawEncoding(CXXOperatorName.BeginOpNameLoc); | ||
if (!CXXOperatorName.OInfo) | ||
return {}; | ||
return SourceLocation::getFromRawEncoding( | ||
CXXOperatorName.OInfo->BeginOpNameLoc); | ||
} | ||
|
||
/// Return the end location of the getCXXOperatorNameRange() range. | ||
SourceLocation getCXXOperatorNameEndLoc() const { | ||
return SourceLocation::getFromRawEncoding(CXXOperatorName.EndOpNameLoc); | ||
if (!CXXOperatorName.OInfo) | ||
return {}; | ||
return SourceLocation::getFromRawEncoding( | ||
CXXOperatorName.OInfo->EndOpNameLoc); | ||
} | ||
|
||
/// Return the range of the operator name (without the operator keyword). | ||
|
@@ -769,17 +774,12 @@ class DeclarationNameLoc { | |
DNL.setNamedTypeLoc(TInfo); | ||
return DNL; | ||
} | ||
|
||
/// Construct location information for a non-literal C++ operator. | ||
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, | ||
SourceLocation EndLoc) { | ||
return makeCXXOperatorNameLoc(SourceRange(BeginLoc, EndLoc)); | ||
} | ||
|
||
|
||
/// Construct location information for a non-literal C++ operator. | ||
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceRange Range) { | ||
static DeclarationNameLoc | ||
makeCXXOperatorNameLoc(CXXOperatorSourceInfo *OInfo) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a weird function to exist... am I correct in that it is only called 1x? I find myself thinkin perhaps we should just inline it manually. |
||
DeclarationNameLoc DNL; | ||
DNL.setCXXOperatorNameRange(Range); | ||
DNL.CXXOperatorName.OInfo = OInfo; | ||
return DNL; | ||
} | ||
|
||
|
@@ -839,7 +839,7 @@ struct DeclarationNameInfo { | |
return nullptr; | ||
return LocInfo.getNamedTypeInfo(); | ||
} | ||
|
||
/// setNamedTypeInfo - Sets the source type info associated to | ||
/// the name. Assumes it is a constructor, destructor or conversion. | ||
void setNamedTypeInfo(TypeSourceInfo *TInfo) { | ||
|
@@ -849,6 +849,13 @@ struct DeclarationNameInfo { | |
LocInfo = DeclarationNameLoc::makeNamedTypeLoc(TInfo); | ||
} | ||
|
||
/// Sets the range of the operator name (without the operator keyword). | ||
/// Assumes it is a C++ operator. | ||
void setCXXOperatorNameInfo(CXXOperatorSourceInfo *OInfo) { | ||
assert(Name.getNameKind() == DeclarationName::CXXOperatorName); | ||
LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(OInfo); | ||
} | ||
|
||
/// getCXXOperatorNameRange - Gets the range of the operator name | ||
/// (without the operator keyword). Assumes it is a (non-literal) operator. | ||
SourceRange getCXXOperatorNameRange() const { | ||
|
@@ -857,13 +864,6 @@ struct DeclarationNameInfo { | |
return LocInfo.getCXXOperatorNameRange(); | ||
} | ||
|
||
/// setCXXOperatorNameRange - Sets the range of the operator name | ||
/// (without the operator keyword). Assumes it is a C++ operator. | ||
void setCXXOperatorNameRange(SourceRange R) { | ||
assert(Name.getNameKind() == DeclarationName::CXXOperatorName); | ||
LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(R); | ||
} | ||
|
||
/// getCXXLiteralOperatorNameLoc - Returns the location of the literal | ||
/// operator name (not the operator keyword). | ||
/// Assumes it is a literal operator. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have sworn I just saw this structure created/modified in another patch about a week ago? Does this need a rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting -- this patch was rebased recently on top of 0b6ddb0 (from 4 days ago), and I don't recall any issues during the rebase.