diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp | 4 | ||||
| -rw-r--r-- | clang/test/clang-rename/ForwardClassDecl.cpp | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp index b60616ecc87..e26248f50c2 100644 --- a/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp +++ b/clang/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp @@ -102,6 +102,10 @@ public: private: void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) { + if (!RecordDecl->getDefinition()) { + USRSet.insert(getUSRForDecl(RecordDecl)); + return; + } RecordDecl = RecordDecl->getDefinition(); if (const auto *ClassTemplateSpecDecl = dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl)) diff --git a/clang/test/clang-rename/ForwardClassDecl.cpp b/clang/test/clang-rename/ForwardClassDecl.cpp new file mode 100644 index 00000000000..ef731a16d6e --- /dev/null +++ b/clang/test/clang-rename/ForwardClassDecl.cpp @@ -0,0 +1,4 @@ +class Foo; // CHECK: class Bar; +Foo *f(); // CHECK: Bar *f(); + +// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s |

