<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">That’s a good idea, if you don’t get to it I’ll look into it at some point later on but it will probably not be soon.</div><br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2017, at 9:10 AM, Alex L <<a href="mailto:arphaman@gmail.com" class="">arphaman@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On 10 May 2017 at 16:10, Argyrios Kyrtzidis via cfe-commits<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Author: akirtzidis<br class="">Date: Wed May 10 10:10:36 2017<br class="">New Revision: 302677<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=302677&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project?rev=302677&view=rev</a><br class="">Log:<br class="">[libclang] Introduce clang_Cursor_isExternalSymbol that provides info about decls marked with external_source_symbol attribute<br class=""><br class="">Modified:<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/include/clang-c/<wbr class="">Index.h<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/test/Index/get-<wbr class="">cursor.m<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/tools/c-index-test/<wbr class="">c-index-test.c<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/tools/libclang/<wbr class="">CIndex.cpp<br class=""> <span class="Apple-converted-space"> </span>cfe/trunk/tools/libclang/<wbr class="">libclang.exports<br class=""><br class="">Modified: cfe/trunk/include/clang-c/<wbr class="">Index.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=302677&r1=302676&r2=302677&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/include/<wbr class="">clang-c/Index.h?rev=302677&r1=<wbr class="">302676&r2=302677&view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/include/clang-c/<wbr class="">Index.h (original)<br class="">+++ cfe/trunk/include/clang-c/<wbr class="">Index.h Wed May 10 10:10:36 2017<br class="">@@ -32,7 +32,7 @@<br class=""> <span class="Apple-converted-space"> </span>* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.<br class=""> <span class="Apple-converted-space"> </span>*/<br class=""> #define CINDEX_VERSION_MAJOR 0<br class="">-#define CINDEX_VERSION_MINOR 38<br class="">+#define CINDEX_VERSION_MINOR 39<br class=""><br class=""> #define CINDEX_VERSION_ENCODE(major, minor) ( \<br class=""> ((major) * 10000) \<br class="">@@ -4081,6 +4081,23 @@ CINDEX_LINKAGE unsigned clang_Cursor_isO<br class=""> CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(<wbr class="">CXCursor C);<br class=""><br class=""> /**<br class="">+ * \brief Returns non-zero if the given cursor points to a symbol marked with<br class="">+ * external_source_symbol attribute.<br class="">+ *<br class="">+ * \param language If non-NULL, and the attribute is present, will be set to<br class="">+ * the 'language' string from the attribute.<br class="">+ *<br class="">+ * \param definedIn If non-NULL, and the attribute is present, will be set to<br class="">+ * the 'definedIn' string from the attribute.<br class="">+ *<br class="">+ * \param isGenerated If non-NULL, and the attribute is present, will be set to<br class="">+ * non-zero is the 'generated_declaration' is set in the attribute.<br class="">+ */<br class="">+CINDEX_LINKAGE unsigned clang_Cursor_isExternalSymbol(<wbr class="">CXCursor C,<br class="">+ CXString *language, CXString *definedIn,<br class="">+ unsigned *isGenerated);<br class="">+<br class="">+/**<br class=""> <span class="Apple-converted-space"> </span>* \brief Given a cursor that represents a declaration, return the associated<br class=""> <span class="Apple-converted-space"> </span>* comment's source range. The range may include multiple consecutive comments<br class=""> <span class="Apple-converted-space"> </span>* with whitespace in between.<br class=""><br class="">Modified: cfe/trunk/test/Index/get-<wbr class="">cursor.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.m?rev=302677&r1=302676&r2=302677&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/test/Index/<wbr class="">get-cursor.m?rev=302677&r1=<wbr class="">302676&r2=302677&view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/test/Index/get-<wbr class="">cursor.m (original)<br class="">+++ cfe/trunk/test/Index/get-<wbr class="">cursor.m Wed May 10 10:10:36 2017<br class="">@@ -154,6 +154,12 @@ SomeT someVar;<br class=""> typedef MY_TYPE2(SomeT2) { int x; };<br class=""> SomeT2 someVar2;<br class=""><br class="">+#define GEN_DECL(mod_name) __attribute__((external_<wbr class="">source_symbol(language="Swift"<wbr class="">, defined_in=mod_name, generated_declaration)))<br class="">+<br class="">+GEN_DECL("some_module")<br class="">+@interface ExtCls<br class="">+-(void)method;<br class="">+@end<br class=""><br class=""> // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s<br class=""> // CHECK-PROP: ObjCPropertyDecl=foo1:4:26<br class="">@@ -226,3 +232,8 @@ SomeT2 someVar2;<br class=""> // CHECK-TRANSPARENT: 147:1 TypeRef=TokenPaste_t:144:9 Extent=[147:1 - 147:13] Spelling=TokenPaste_t ([147:1 - 147:13])<br class=""> // CHECK-TRANSPARENT: 151:1 TypeRef=SomeT:150:17 (Transparent: struct SomeT) Extent=[151:1 - 151:6] Spelling=SomeT ([151:1 - 151:6])<br class=""> // CHECK-TRANSPARENT: 155:1 TypeRef=SomeT2:154:18 Extent=[155:1 - 155:7] Spelling=SomeT2 ([155:1 - 155:7])<br class="">+<br class="">+// RUN: c-index-test -cursor-at=%s:160:12 -cursor-at=%s:161:8 %s | FileCheck -check-prefix=CHECK-EXTERNAL %s<br class="">+// CHECK-EXTERNAL: 160:12 ObjCInterfaceDecl=ExtCls:160:<wbr class="">12 (external lang: Swift, defined: some_module, gen: 1)<br class="">+// CHECK-EXTERNAL: 161:8 ObjCInstanceMethodDecl=method:<wbr class="">161:8 (external lang: Swift, defined: some_module, gen: 1)<br class="">+C<br class="">\ No newline at end of file<br class=""><br class="">Modified: cfe/trunk/tools/c-index-test/<wbr class="">c-index-test.c<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=302677&r1=302676&r2=302677&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/tools/c-<wbr class="">index-test/c-index-test.c?rev=<wbr class="">302677&r1=302676&r2=302677&<wbr class="">view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/tools/c-index-test/<wbr class="">c-index-test.c (original)<br class="">+++ cfe/trunk/tools/c-index-test/<wbr class="">c-index-test.c Wed May 10 10:10:36 2017<br class="">@@ -809,6 +809,19 @@ static void PrintCursor(CXCursor Cursor,<br class=""> if (clang_Cursor_isObjCOptional(<wbr class="">Cursor))<br class=""> printf(" (@optional)");<br class=""><br class="">+ {<br class="">+ CXString language;<br class="">+ CXString definedIn;<br class="">+ unsigned generated;<br class="">+ if (clang_Cursor_<wbr class="">isExternalSymbol(Cursor, &language, &definedIn,<br class="">+ &generated)) {<br class="">+ printf(" (external lang: %s, defined: %s, gen: %d)",<br class="">+ clang_getCString(language), clang_getCString(definedIn), generated);<br class="">+ clang_disposeString(language);<br class="">+ clang_disposeString(definedIn)<wbr class="">;<br class="">+ }<br class="">+ }<br class="">+<br class=""> if (Cursor.kind == CXCursor_<wbr class="">IBOutletCollectionAttr) {<br class=""> CXType T =<br class=""> clang_getCanonicalType(clang_<wbr class="">getIBOutletCollectionType(<wbr class="">Cursor));<br class=""><br class="">Modified: cfe/trunk/tools/libclang/<wbr class="">CIndex.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=302677&r1=302676&r2=302677&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/tools/<wbr class="">libclang/CIndex.cpp?rev=<wbr class="">302677&r1=302676&r2=302677&<wbr class="">view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/tools/libclang/<wbr class="">CIndex.cpp (original)<br class="">+++ cfe/trunk/tools/libclang/<wbr class="">CIndex.cpp Wed May 10 10:10:36 2017<br class="">@@ -7479,6 +7479,35 @@ unsigned clang_Cursor_isVariadic(<wbr class="">CXCurso<br class=""> return 0;<br class=""> }<br class=""><br class="">+unsigned clang_Cursor_isExternalSymbol(<wbr class="">CXCursor C,<br class="">+ CXString *language, CXString *definedIn,<br class="">+ unsigned *isGenerated) {<br class="">+ if (!clang_isDeclaration(C.kind))<br class="">+ return 0;<br class="">+<br class="">+ const Decl *D = getCursorDecl(C);<br class="">+<br class="">+ auto getExternalSymAttr = [](const Decl *D) -> ExternalSourceSymbolAttr* {<br class="">+ if (auto *attr = D->getAttr<<wbr class="">ExternalSourceSymbolAttr>())<br class="">+ return attr;<br class="">+ if (auto *dcd = dyn_cast<Decl>(D-><wbr class="">getDeclContext())) {<br class="">+ if (auto *attr = dcd->getAttr<<wbr class="">ExternalSourceSymbolAttr>())<br class="">+ return attr;<br class="">+ }<br class="">+ return nullptr;<br class="">+ };<br class=""></blockquote><div class=""><br class=""></div><div class="">I think this pattern is used in the indexing code as well. We should probably create a method in Decl that does this search for ExternalSourceSymbol attribute.</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">+ if (auto *attr = getExternalSymAttr(D)) {<br class="">+ if (language)<br class="">+ *language = cxstring::createDup(attr-><wbr class="">getLanguage());<br class="">+ if (definedIn)<br class="">+ *definedIn = cxstring::createDup(attr-><wbr class="">getDefinedIn());<br class="">+ if (isGenerated)<br class="">+ *isGenerated = attr->getGeneratedDeclaration(<wbr class="">);<br class="">+ return 1;<br class="">+ }<br class="">+ return 0;<br class="">+}<br class="">+<br class=""> CXSourceRange clang_Cursor_getCommentRange(<wbr class="">CXCursor C) {<br class=""> if (!clang_isDeclaration(C.kind))<br class=""> return clang_getNullRange();<br class=""><br class="">Modified: cfe/trunk/tools/libclang/<wbr class="">libclang.exports<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=302677&r1=302676&r2=302677&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/cfe/trunk/tools/<wbr class="">libclang/libclang.exports?rev=<wbr class="">302677&r1=302676&r2=302677&<wbr class="">view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- cfe/trunk/tools/libclang/<wbr class="">libclang.exports (original)<br class="">+++ cfe/trunk/tools/libclang/<wbr class="">libclang.exports Wed May 10 10:10:36 2017<br class="">@@ -35,6 +35,7 @@ clang_Cursor_getReceiverType<br class=""> clang_Cursor_isAnonymous<br class=""> clang_Cursor_isBitField<br class=""> clang_Cursor_isDynamicCall<br class="">+clang_Cursor_isExternalSymbol<br class=""> clang_Cursor_isNull<br class=""> clang_Cursor_isObjCOptional<br class=""> clang_Cursor_isVariadic<br class=""><br class=""><br class="">______________________________<wbr class="">_________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-commits</a></blockquote></div></div></blockquote></div><br class=""></body></html>