diff options
| author | Kirill Bobyrev <omtcyfz@gmail.com> | 2016-08-15 23:20:05 +0000 |
|---|---|---|
| committer | Kirill Bobyrev <omtcyfz@gmail.com> | 2016-08-15 23:20:05 +0000 |
| commit | 6b7d8c294429c25e225b87769e4381659dc3bbb0 (patch) | |
| tree | 826bdb19af688d7e3de97e8bba27cf08434f1701 /clang-tools-extra/clang-rename/USRLocFinder.cpp | |
| parent | 18e2d82297ec692c015bd1f22758913b6dd3c508 (diff) | |
| download | bcm5719-llvm-6b7d8c294429c25e225b87769e4381659dc3bbb0.tar.gz bcm5719-llvm-6b7d8c294429c25e225b87769e4381659dc3bbb0.zip | |
[clang-rename] cleanup `auto` usages
As Alexander pointed out, LLVM Coding Standards are more conservative about
using auto, i.e. it should be used in the following situations:
* When the type is obvious, i.e. explicitly mentioned in the same expression.
For example `if (const clang::FieldDecl *FieldDecl = Initializer->getMember())`.
* When the type is totally non-obvious and one iterates over something. For
example
`for (const auto &CurrDecl : Context.getTranslationUnitDecl()->decls())`.
Otherwise the type should be explicitly stated.
Reviewers: alexfh
Differential Revision: https://reviews.llvm.org/D23397
llvm-svn: 278760
Diffstat (limited to 'clang-tools-extra/clang-rename/USRLocFinder.cpp')
| -rw-r--r-- | clang-tools-extra/clang-rename/USRLocFinder.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-rename/USRLocFinder.cpp b/clang-tools-extra/clang-rename/USRLocFinder.cpp index 8d4c7e42360..c7ce5338d07 100644 --- a/clang-tools-extra/clang-rename/USRLocFinder.cpp +++ b/clang-tools-extra/clang-rename/USRLocFinder.cpp @@ -67,7 +67,7 @@ public: // Expression visitors: bool VisitDeclRefExpr(const DeclRefExpr *Expr) { - const auto *Decl = Expr->getFoundDecl(); + const NamedDecl *Decl = Expr->getFoundDecl(); if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) { const SourceManager &Manager = Decl->getASTContext().getSourceManager(); @@ -79,7 +79,7 @@ public: } bool VisitMemberExpr(const MemberExpr *Expr) { - const auto *Decl = Expr->getFoundDecl().getDecl(); + const NamedDecl *Decl = Expr->getFoundDecl().getDecl(); if (USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) { const SourceManager &Manager = Decl->getASTContext().getSourceManager(); SourceLocation Location = Manager.getSpellingLoc(Expr->getMemberLoc()); @@ -116,7 +116,8 @@ public: // Namespace traversal: void handleNestedNameSpecifierLoc(NestedNameSpecifierLoc NameLoc) { while (NameLoc) { - const auto *Decl = NameLoc.getNestedNameSpecifier()->getAsNamespace(); + const NamespaceDecl *Decl = + NameLoc.getNestedNameSpecifier()->getAsNamespace(); if (Decl && USRSet.find(getUSRForDecl(Decl)) != USRSet.end()) { checkAndAddLocation(NameLoc.getLocalBeginLoc()); } @@ -126,8 +127,8 @@ public: private: void checkAndAddLocation(SourceLocation Loc) { - const auto BeginLoc = Loc; - const auto EndLoc = Lexer::getLocForEndOfToken( + const SourceLocation BeginLoc = Loc; + const SourceLocation EndLoc = Lexer::getLocForEndOfToken( BeginLoc, 0, Context.getSourceManager(), Context.getLangOpts()); StringRef TokenName = Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc), |

