Implement clang_getCanonicalCursor() in libclang, which does the obvious thing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119874 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 9137172..9116667 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -3717,6 +3717,16 @@
return clang_getCursorDefinition(C) == C;
}
+CXCursor clang_getCanonicalCursor(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return C;
+
+ if (Decl *D = getCursorDecl(C))
+ return MakeCXCursor(D->getCanonicalDecl(), getCursorTU(C));
+
+ return C;
+}
+
unsigned clang_getNumOverloadedDecls(CXCursor C) {
if (C.kind != CXCursor_OverloadedDeclRef)
return 0;
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 5e8abf2..e132f7f 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -32,6 +32,7 @@
_clang_formatDiagnostic
_clang_getCString
_clang_getCXXAccessSpecifier
+_clang_getCanonicalCursor
_clang_getCanonicalType
_clang_getClangVersion
_clang_getCompletionAvailability
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index ca9a9d1..fce89ca 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -32,6 +32,7 @@
clang_formatDiagnostic
clang_getCString
clang_getCXXAccessSpecifier
+clang_getCanonicalCursor
clang_getCanonicalType
clang_getClangVersion
clang_getCompletionAvailability