-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Clang] Optimize some getBeginLoc
implementations
#141058
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
Open
cor3ntin
wants to merge
12
commits into
llvm:main
Choose a base branch
from
cor3ntin:corentin/optimize_get_callee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
381c221
try optimize
cor3ntin 16077ed
remove call to getCalleeDecl
cor3ntin fb437b0
Optimize another getBeginLoc
cor3ntin dc33c5a
Try more optimizations
cor3ntin 21cf4b4
cache begin in callexpr
cor3ntin 7472299
revert changes to explicit object member functions
cor3ntin 99d11a5
reset the cache when setting deducing this functions
cor3ntin fd4aaf5
cleanups
cor3ntin 63a8b54
Storing the endloc is not necessary (and was done incorrectly)
cor3ntin 3c34d90
Address aaron's feedback
cor3ntin fd278cd
Address more feedback
cor3ntin 8826a4b
formaatting
cor3ntin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,7 +283,9 @@ class NestedNameSpecifierLoc { | |
/// For example, if this instance refers to a nested-name-specifier | ||
/// \c \::std::vector<int>::, the returned source range would cover | ||
/// from the initial '::' to the last '::'. | ||
SourceRange getSourceRange() const LLVM_READONLY; | ||
SourceRange getSourceRange() const LLVM_READONLY { | ||
return SourceRange(getBeginLoc(), getEndLoc()); | ||
} | ||
|
||
/// Retrieve the source range covering just the last part of | ||
/// this nested-name-specifier, not including the prefix. | ||
|
@@ -296,14 +298,18 @@ class NestedNameSpecifierLoc { | |
/// Retrieve the location of the beginning of this | ||
/// nested-name-specifier. | ||
SourceLocation getBeginLoc() const { | ||
return getSourceRange().getBegin(); | ||
if (!Qualifier) | ||
return SourceLocation(); | ||
|
||
NestedNameSpecifierLoc First = *this; | ||
while (NestedNameSpecifierLoc Prefix = First.getPrefix()) | ||
First = Prefix; | ||
return First.getLocalSourceRange().getBegin(); | ||
Comment on lines
+301
to
+307
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 didn't see the differences of changes on these functions... Are they related? |
||
} | ||
|
||
/// Retrieve the location of the end of this | ||
/// nested-name-specifier. | ||
SourceLocation getEndLoc() const { | ||
return getSourceRange().getEnd(); | ||
} | ||
SourceLocation getEndLoc() const { return getLocalSourceRange().getEnd(); } | ||
|
||
/// Retrieve the location of the beginning of this | ||
/// component of the nested-name-specifier. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This works today, but we keep talking about moving to 64-bit source locations (and that's getting more important thanks to modules), what's the idea for in that situation? Grow the size of
CallExpr
?Uh oh!
There was an error while loading. Please reload this page.
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.
We have 4 bytes left now. But yeah, if we need more space, we would need a different strategy