summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-03-27 16:14:44 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-27 16:14:44 +0200
commitb0485ecbf435dc984c8a1a0251279ce2bb502b37 (patch)
tree1693574eb764efbfb1d073d6cc145bb4cf5614c8
parent58c8c09f8d9aa87f5579063844be6779f0a2f9f6 (diff)
fix ctors
-rw-r--r--clang/rename.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/rename.cxx b/clang/rename.cxx
index 14bfc85..d777f76 100644
--- a/clang/rename.cxx
+++ b/clang/rename.cxx
@@ -115,6 +115,21 @@ class RenameVisitor : public clang::RecursiveASTVisitor<RenameVisitor>
return aNewName.substr(0, nPos);
}
+ /// Get the local name part of a new name.
+ std::string GetLocalName(const std::string& rOldName)
+ {
+ auto it = mrRewriter.getNameMap().find(rOldName);
+ if (it == mrRewriter.getNameMap().end())
+ return std::string();
+
+ std::string aNewName = it->second;
+ std::string::size_type nPos = aNewName.find("::");
+ if (nPos == std::string::npos)
+ return aNewName;
+
+ return aNewName.substr(nPos + strlen("::"));
+ }
+
/// If a new name has a namespace part.
bool HasNamespace(const std::string& rOldName)
{
@@ -207,13 +222,15 @@ public:
* Foo::Foo(...) {}
* ^~~ Handles this.
*/
- RewriteText(pDecl->getLocStart(), pDecl->getNameAsString().length(), aName);
+ if (!HasNamespace(aName) || pDecl->isThisDeclarationADefinition())
+ RewriteText(pDecl->getLocStart(), aName.length(), aName);
/*
* Foo::Foo(...) {}
* ^~~ Handles this.
*/
- RewriteText(pDecl->getLocation(), pDecl->getNameAsString().length(), aName);
+ if (!HasNamespace(aName))
+ RewriteText(pDecl->getLocation(), aName.length(), aName);
return true;
}