[PATCH] D36688: [clang-diff] Fix matching for unnamed NamedDecs

Johannes Altmanninger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 5 11:22:08 PST 2017


johannes updated this revision to Diff 121649.
johannes added a comment.

update


https://reviews.llvm.org/D36688

Files:
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-heuristics.cpp


Index: test/Tooling/clang-diff-heuristics.cpp
===================================================================
--- test/Tooling/clang-diff-heuristics.cpp
+++ test/Tooling/clang-diff-heuristics.cpp
@@ -10,6 +10,8 @@
 
 void f2(int) {;}
 
+class C3 { C3(); };
+
 #else
 
 // same parents, same value
@@ -22,4 +24,8 @@
 // CHECK: Match CompoundStmt
 void f2() {}
 
+// same parents, same identifier
+// CHECK: Match CXXConstructorDecl(9) to CXXConstructorDecl(6)
+class C3 { C3(int); };
+
 #endif
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===================================================================
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -607,6 +607,8 @@
   if (auto *ND = ASTNode.get<NamedDecl>()) {
     if (ND->getDeclName().isIdentifier())
       return ND->getQualifiedNameAsString();
+    else
+      return std::string();
   }
   return llvm::None;
 }
@@ -617,6 +619,8 @@
   if (auto *ND = ASTNode.get<NamedDecl>()) {
     if (ND->getDeclName().isIdentifier())
       return ND->getName();
+    else
+      return StringRef();
   }
   return llvm::None;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36688.121649.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171105/36b15fad/attachment.bin>


More information about the cfe-commits mailing list