This repository was archived by the owner on Jan 19, 2025. It is now read-only.
forked from NN-complr-tech/llvm
-
Notifications
You must be signed in to change notification settings - Fork 57
Savotina Valeria, Lab №1, var: 2. #27
Merged
m-ly4
merged 5 commits into
NN-complr-tech:course-spring-2024
from
Savotina:savotina_valeria
Mar 21, 2024
Merged
Savotina Valeria, Lab №1, var: 2. #27
m-ly4
merged 5 commits into
NN-complr-tech:course-spring-2024
from
Savotina:savotina_valeria
Mar 21, 2024
Conversation
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
m-ly4
suggested changes
Mar 18, 2024
aobolensk
reviewed
Mar 18, 2024
m-ly4
suggested changes
Mar 19, 2024
Comment on lines
14
to
25
if (decl->isFunctionOrFunctionTemplate()) { | ||
if (!decl->hasAttr<clang::AlwaysInlineAttr>()) { | ||
if (auto body = decl->getBody()) { | ||
if (!findСonditionalStatement(body)) { | ||
if (auto loc = decl->getSourceRange(); loc.isValid()) { | ||
decl->addAttr( | ||
clang::AlwaysInlineAttr::Create(*context, loc.getBegin())); | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
In LLVM it is customary to reduce nesting as much as possible:
Suggested change
if (decl->isFunctionOrFunctionTemplate()) { | |
if (!decl->hasAttr<clang::AlwaysInlineAttr>()) { | |
if (auto body = decl->getBody()) { | |
if (!findСonditionalStatement(body)) { | |
if (auto loc = decl->getSourceRange(); loc.isValid()) { | |
decl->addAttr( | |
clang::AlwaysInlineAttr::Create(*context, loc.getBegin())); | |
} | |
} | |
} | |
} | |
} | |
if (!decl->isFunctionOrFunctionTemplate()) | |
return true; | |
if (decl->hasAttr<clang::AlwaysInlineAttr>()) | |
return true; | |
if (auto body = decl->getBody()) { | |
if (findСonditionalStatement(body)) | |
return true; | |
if (auto loc = decl->getSourceRange(); loc.isValid()) | |
decl->addAttr( | |
clang::AlwaysInlineAttr::Create(*context, loc.getBegin())); | |
} |
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.
@m-ly4 ok, I see, thanks!
m-ly4
approved these changes
Mar 19, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The plugin allows all functions that don't have conditions (for example, if, do...while, etc.), add the
always_inline
attribute.