Re: [cfe-users] Should clang++ -g produce debugging info for all types?
On Thu, Jul 25, 2019 at 8:35 PM David Blaikie wrote: > No, it shouldn't - clang attempts to avoid emitting duplicate debug info > across the program (it assumes you built the whole program and all libraries > with debug info), gcc assumes the same thing though in slightly > different/fewer ways. > > The solution is to install the -dbg build of your libstdc++ package (assuming > you're using libstdc++), it will include debug info for the standard library, > including std::string. Thanks for the pointer. Based on what you told me, I was able to dig deeper and found these relevant links: https://bugs.llvm.org/show_bug.cgi?id=24202#c1 https://stackoverflow.com/questions/41745527/cannot-view-stdstring-when-compiled-with-clang I installed the debug version of libstd++ on my Fedora system with "dnf debuginfo-install libstdc++" and I now see a debug version of libstdc++: $ file /usr/lib/debug/lib64/libstdc++.so.6.0.26-9.1.1-1.fc30.x86_64.debug /usr/lib/debug/lib64/libstdc++.so.6.0.26-9.1.1-1.fc30.x86_64.debug: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=3b2e1aaafd0cb7e1ebd75627d4cde2504c927159, with debug_info, not stripped I don't have things working though. I still don't see std::string info when debugging. My executable is linked against the non-debug version: $ ldd a.out linux-vdso.so.1 (0x7ffec03fe000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x7f2fccd31000) libm.so.6 => /lib64/libm.so.6 (0x7f2fccbeb000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x7f2fccbd1000) libc.so.6 => /lib64/libc.so.6 (0x7f2fcca0b000) /lib64/ld-linux-x86-64.so.2 (0x7f2fccf45000) Is that my problem? Or does LLDB somehow know to use the version in /usr/lib/debug/lib64? I'm also puzzled about why the debug version was put in /usr/lib and not /usr/lib64. ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] [clang-format] Trailing return type
On Mon, 5 Nov 2018 at 19:27, Mateusz Loskot wrote: > On Fri, 2 Nov 2018 at 06:11, Owen Pan wrote: > > I noticed one issue which I wonder if it does qualify for a bug report: > > TL;TR: arrow followed by typename keyword is not handled > > Before: > > template > auto bbb(detail::base& p) -> typename > std::add_lvalue_reference::type; > > After: > > template > auto bbb(detail::base &p) -> > typename std::add_lvalue_reference::type; FYI, I've reported it as a bug (took me a while!) https://bugs.llvm.org/show_bug.cgi?id=42835 Best regards, -- Mateusz Loskot, http://mateusz.loskot.net ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] [clang-format] Trailing return type
On Wed, 31 Jul 2019 at 00:14, Mateusz Loskot wrote: > On Mon, 5 Nov 2018 at 19:27, Mateusz Loskot wrote: > > On Fri, 2 Nov 2018 at 06:11, Owen Pan wrote: > > > > I noticed one issue which I wonder if it does qualify for a bug report: > > > > TL;TR: arrow followed by typename keyword is not handled > > > > Before: > > > > template > > auto bbb(detail::base& p) -> typename > > std::add_lvalue_reference::type; > > > > After: > > > > template > > auto bbb(detail::base &p) -> > > typename std::add_lvalue_reference::type; > > FYI, I've reported it as a bug (took me a while!) > > https://bugs.llvm.org/show_bug.cgi?id=42835 Looks like thread inter-linking as not quite worked, so here is old thread http://lists.llvm.org/pipermail/cfe-users/2018-November/001421.html Best regards, -- Mateusz Loskot, http://mateusz.loskot.net ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
[cfe-users] AST Recursive Visitor- Statements (Stmt *)
Hello Clangers, I'm new to clang. I'm writing an AST Consumer plug-in to visit the statements node and record the data in one of my table with line numbers. I've this function callback ready: *VisitStmt(Stmt *S)*. My question is how could I traverse If, while, for loop, boolean and Unary Operators- inside this function. Thanks and Regards. ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] AST Recursive Visitor- Statements (Stmt *)
Hi Ayush, First, you need to know the classes associated with each of your target AST nodes. These are IfStmt, WhileStmt, ForStmt, BinaryOperator, and UnaryOperator. Each of these are sub-classes of Stmt. IfStmt, WhileStmt, ForStmt and direct sub-classes while BinaryOperator and UnaryOperator are sub-classes of Expr, which is a sub-class of ValueStmt, which is a sub-class of Stmt. There's also two other related classes, CXXForRangeStmt and DoStmt, which represent ranged-based for-loops and do/while loops. Second, pointers can be changed between classes with the cast and dyn_cast functions and Stmt::getStmtClass() will tell the type of the Stmt. They are used as follows: void VisitStmt(Stmt *S) { if (BinaryOperator *BO = dyn_cast(S)) { // Process BinaryOperator here } else if (UnaryOperator *UO = dyn_cast(S)) { ... } // other checks here } void VisitStmt(Stmt *S) { switch (S->getStmtClass()) { case Stmt::BinaryOperatorClass: { BinaryOperator *BO = cast(S); // Process BinaryOperator here } case Stmt::UnaryOperatorClass: { UnaryOperator *UO = cast(S); } // Other cases here } } The difference between cast and dyn_cast is that cast expects the pointer is the correct type without checking while dyn_cast does check the target type and returns a null pointer on a type mismatch. Chains of dyn_cast's are used if the list of nodes is short while using a switch on Stmt::getStmtClass() is used when checking a lot of node types. There's also a third way. Since you are already using a visitor, the visitor will have a visit function for each AST node. Instead of writing just VisitStmt, you will write a VisitBinaryOperator(BinaryOperator *), VisitUnaryOperator(UnaryOperator *), and so on for each one you're interested in. Hope this is enough to get you started. On Tue, Jul 30, 2019 at 4:25 PM Ayush Mittal via cfe-users < cfe-users@lists.llvm.org> wrote: > Hello Clangers, > > I'm new to clang. I'm writing an AST Consumer plug-in to visit the > statements node and record the data in one of my table with line numbers. > I've this function callback ready: *VisitStmt(Stmt *S)*. My question is > how could I traverse If, while, for loop, boolean and Unary Operators- > inside this function. > > Thanks and Regards. > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > ___ cfe-users mailing list cfe-users@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users