This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix Clang-tidy modernize-use-auto in some files in lib/AST; other minor cleanups.
AbandonedPublic

Authored by Eugene.Zelenko on Nov 10 2015, 6:11 PM.

Details

Summary

I checked this patch on my own build on RHEL 6. Regressions were OK.

Diff Detail

Event Timeline

Eugene.Zelenko retitled this revision from to [Clang] Fix Clang-tidy modernize-use-auto in some files in lib/AST; other minor cleanups..
Eugene.Zelenko updated this object.
Eugene.Zelenko added reviewers: hans, aaron.ballman.
Eugene.Zelenko set the repository for this revision to rL LLVM.
Eugene.Zelenko added a subscriber: cfe-commits.
hans edited edge metadata.Nov 11 2015, 12:00 AM

Like the other patch, I'm not sure that using auto in all these places help readability.

aaron.ballman edited edge metadata.Nov 11 2015, 8:00 AM
In D14560#286819, @hans wrote:

Like the other patch, I'm not sure that using auto in all these places help readability.

I share these concerns.

aaron.ballman added inline comments.Nov 11 2015, 8:12 AM
lib/AST/ASTContext.cpp
3857

This one may be an improvement.

4366

Same with this one.

7930

This is... interesting. Explicitly defaulting an out-of-line function definition is not something I've ever encountered before. What benefit does this provide?

8519

Same question applies here.

lib/AST/ASTImporter.cpp
5326

This may be an improvement.

5348

Similar out-of-line question here.

lib/AST/CommentSema.cpp
268

This is an improvement.

304

As is this one.

357

Good catch on removing this one!

I'm adept of consistency :-) It's also easier to fix all similar patterns in code then do such cleanups selectively. Actually, similar fixes were made recently in Decl.cpp when casts were involved, but not new.

lib/AST/ASTContext.cpp
7930

It's explicitly tells that destructor has default implementation.

aaron.ballman added inline comments.Nov 12 2015, 6:36 AM
lib/AST/ASTContext.cpp
7930

I'm not certain this is an improvement. Using =default in the declaration is an improvement because it tells the compiler up front "this has the default implementation" and the compiler can benefit from that information in other ways. When it's on an out-of-line definition, it does say "this has the default implementation", but it doesn't give the compiler any benefit over {}, so the only benefit is up to the reader of the code. I think someone can read {} to easily tell it is the default behavior, it is considerably shorter, and it doesn't cause anyone's eyes to trip over it wondering about the construct.

Eugene.Zelenko abandoned this revision.Nov 20 2015, 5:18 PM