-
Notifications
You must be signed in to change notification settings - Fork 49
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
Гущин А.А. 381806-3 #42
base: master
Are you sure you want to change the base?
Conversation
bool FnToFnCast = | ||
isFunction(SourceTypeAsWritten) && isFunction(DestTypeAsWritten); | ||
|
||
if (CastExpr->getCastKind() == CK_NoOp && !FnToFnCast && |
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.
Please describe what this check does.
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.
Здесь проверка на приведение к тому же типу. CastExpr->getCastKind() == CK_NoOp означает, что приведение не влияет на сам тип, а только на спецификаторы типов и noexcept.
!FnToFnCast проверяет на то, что приведение не является приведением функции к функции. Такие приведения могут быть нужны, чтобы явно разрешать перегрузки функций.
SourceTypeAsWritten == DestTypeAsWritten проверяем, что source и destination типы совпадают. По-хорошему такое приведение нужно убирать, так как оно избыточное, но в данном случае сделал просто return
return; | ||
} | ||
|
||
if (!match(expr(hasAncestor(linkageSpecDecl())), *CastExpr, *Result.Context) |
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.
Please describe what this check does.
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.
Это проверка на extern "C" блоки. Если приведение находится в таком блоке, то его не нужно заменять
|
||
SourceManager &SM = *Result.SourceManager; | ||
|
||
if (SM.getFilename(SM.getSpellingLoc(CastExpr->getBeginLoc())).endswith(".c")) |
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.
Please describe what this check does.
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.
Проверка на расширение файла, в котором находится приведение. Если мы делаем проход и у файла оказалось расширение .c, это означает, что проверяемое приведение находится в файле языка C. Такие приведения заменять не нужно.
No description provided.