Re: [cfe-users] uniquely identifying names
Maybe I could expand a name into its full name and use that. e.g.: namespace bla { class myclass { void mymethod() { } } } then the full name of mymethod would be bla::myclass::mymethod would be unique enough to me (including filename). Can I somehow get this out of it? On Fri, Aug 26, 2016 at 03:33:20PM +, David Blaikie wrote: > There's no structural identity of code in Clang that I know of - I know > someone's building a tool for doing structural similarity for things like > plagiarism detection (I think there are some patches on the clang mailing > list). > > But if you only need identity within a single process, the pointer value of > the pointer to any AST construct is a unique identity you can use. > > (line/file/column isn't sufficiently unique - you could have a file that is > included under different macro situations and each time it defines a > different function, but all those functions would appear to be defined on > the same line/file of that included file - or a macro that defines multiple > functions - both can be resolved by looking at the more complete location > information (including macro locations, etc)) > > On Fri, Aug 26, 2016 at 5:11 AM folkert via cfe-users < > cfe-users@lists.llvm.org> wrote: > > > Hi, > > > > The Sun java compiler allows you to (from java) walk the AST and > > investigate it. Each token is stored in an object. Each object has a > > hash() method which uniquely identifies it. > > > > Now I was wondering: can I do so with the LLVM tooling as well? I could > > of course if I want to identify e.g. a function name just pick the line- > > and column number and maybe include the function name itself as well but > > that would constantly change when lines are added and/or removed. > > > > Any suggestions? > > > > > > regards, > > > > Folkert van Heusden > > > > -- > > - > > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com > > ___ > > cfe-users mailing list > > cfe-users@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > > Folkert van Heusden -- Always wondered what the latency of your webserver is? Or how much more latency you get when you go through a proxy server/tor? The numbers tell the tale and with HTTPing you know them! http://www.vanheusden.com/httping/ --- Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] uniquely identifying names
Do you want to identify the same entity across a valid program's various source files? Across changes to that program? (what changes?) If you want to do the former, then producing the mangled name of the entity is probably what you want. (some part of the ABI code in Clang could give you that, I would assume - but not sure exactly where) On Tue, Aug 30, 2016 at 2:33 AM folkert wrote: > Maybe I could expand a name into its full name and use that. > e.g.: > > namespace bla { class myclass { void mymethod() { } } } > > then the full name of mymethod would be bla::myclass::mymethod would be > unique enough to me (including filename). > Can I somehow get this out of it? > > On Fri, Aug 26, 2016 at 03:33:20PM +, David Blaikie wrote: > > There's no structural identity of code in Clang that I know of - I know > > someone's building a tool for doing structural similarity for things like > > plagiarism detection (I think there are some patches on the clang mailing > > list). > > > > But if you only need identity within a single process, the pointer value > of > > the pointer to any AST construct is a unique identity you can use. > > > > (line/file/column isn't sufficiently unique - you could have a file that > is > > included under different macro situations and each time it defines a > > different function, but all those functions would appear to be defined on > > the same line/file of that included file - or a macro that defines > multiple > > functions - both can be resolved by looking at the more complete location > > information (including macro locations, etc)) > > > > On Fri, Aug 26, 2016 at 5:11 AM folkert via cfe-users < > > cfe-users@lists.llvm.org> wrote: > > > > > Hi, > > > > > > The Sun java compiler allows you to (from java) walk the AST and > > > investigate it. Each token is stored in an object. Each object has a > > > hash() method which uniquely identifies it. > > > > > > Now I was wondering: can I do so with the LLVM tooling as well? I could > > > of course if I want to identify e.g. a function name just pick the > line- > > > and column number and maybe include the function name itself as well > but > > > that would constantly change when lines are added and/or removed. > > > > > > Any suggestions? > > > > > > > > > regards, > > > > > > Folkert van Heusden > > > > > > -- > > > - > > > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com > > > ___ > > > cfe-users mailing list > > > cfe-users@lists.llvm.org > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > > > > > > Folkert van Heusden > > -- > Always wondered what the latency of your webserver is? Or how much more > latency you get when you go through a proxy server/tor? The numbers > tell the tale and with HTTPing you know them! > http://www.vanheusden.com/httping/ > --- > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com > ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] libclang: Spelling on typedefs lacks namespaces
Hi Hope I picked the right place for this kind of problem, if not please let me know. I'm using libclang to parse header files and generate code from them. I found that clang_getTypeSpelling() usually includes the namespace(s) a type was declared in. However with the exception being typedefs (and same for "using A = B"). Not sure if this is a bug or intended behavior, but it seems at least inconsistent. I also couldn't really find a good workaround for this. I'd have to manually figure out all typedefs (not just pure typedefs, they could also be template parameters or whatever) and then their originating namespaces. This sounds a bit cumbersome and not really straight forward. Minimal example: namespace foo { class Bar { }; typedef Bar BarDef; } clang_getTypeSpelling on "Bar" (kind "Record") gives: "foo::Bar" clang_getTypeSpelling on "BarDef" (kind "Typedef") gives: "BarDef" (<== missing "foo::") Any idea how to solve this problem? Am I missing something? Thanks Michael ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] uniquely identifying names
I don't know which API you're using, but clang::NamedDecl::getQualifiedNameAsString seems to do what you want. > Le 30 août 2016 à 17:40, David Blaikie via cfe-users > a écrit : > > Do you want to identify the same entity across a valid program's various > source files? Across changes to that program? (what changes?) > > If you want to do the former, then producing the mangled name of the entity > is probably what you want. (some part of the ABI code in Clang could give you > that, I would assume - but not sure exactly where) > >> On Tue, Aug 30, 2016 at 2:33 AM folkert wrote: >> Maybe I could expand a name into its full name and use that. >> e.g.: >> >> namespace bla { class myclass { void mymethod() { } } } >> >> then the full name of mymethod would be bla::myclass::mymethod would be >> unique enough to me (including filename). >> Can I somehow get this out of it? >> >> On Fri, Aug 26, 2016 at 03:33:20PM +, David Blaikie wrote: >> > There's no structural identity of code in Clang that I know of - I know >> > someone's building a tool for doing structural similarity for things like >> > plagiarism detection (I think there are some patches on the clang mailing >> > list). >> > >> > But if you only need identity within a single process, the pointer value of >> > the pointer to any AST construct is a unique identity you can use. >> > >> > (line/file/column isn't sufficiently unique - you could have a file that is >> > included under different macro situations and each time it defines a >> > different function, but all those functions would appear to be defined on >> > the same line/file of that included file - or a macro that defines multiple >> > functions - both can be resolved by looking at the more complete location >> > information (including macro locations, etc)) >> > >> > On Fri, Aug 26, 2016 at 5:11 AM folkert via cfe-users < >> > cfe-users@lists.llvm.org> wrote: >> > >> > > Hi, >> > > >> > > The Sun java compiler allows you to (from java) walk the AST and >> > > investigate it. Each token is stored in an object. Each object has a >> > > hash() method which uniquely identifies it. >> > > >> > > Now I was wondering: can I do so with the LLVM tooling as well? I could >> > > of course if I want to identify e.g. a function name just pick the line- >> > > and column number and maybe include the function name itself as well but >> > > that would constantly change when lines are added and/or removed. >> > > >> > > Any suggestions? >> > > >> > > >> > > regards, >> > > >> > > Folkert van Heusden >> > > >> > > -- >> > > - >> > > Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com >> > > ___ >> > > cfe-users mailing list >> > > cfe-users@lists.llvm.org >> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users >> > > >> >> >> Folkert van Heusden >> >> -- >> Always wondered what the latency of your webserver is? Or how much more >> latency you get when you go through a proxy server/tor? The numbers >> tell the tale and with HTTPing you know them! >> http://www.vanheusden.com/httping/ >> --- >> Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users