On Mon, Nov 13, 2023 at 4:28 AM Aaron Ballman <aa...@aaronballman.com> wrote:
> On Sun, Nov 12, 2023 at 11:42 PM David Blaikie <dblai...@gmail.com> wrote: > > > > Any chance this could/should reference the length by name, rather than > by casts and pointer math? (so it's resilient to at least some changes to > StringLiteral/StringRef?) Or is this the preferred way to write Natvis > visualizers, so they're resilient to missing debug info or something? > > There's no name to refer to -- all of this data is stored in an > llvm::TrailingObjects object which stores the data by offset (and > MSVC's debugger does not allow calling functions from NATVIS so I > can't use any of the accessors). > Ah, right, sorry - makes sense. I got clang::StringLiteral mixed up with llvm::StringLiteral. > > ~Aaron > > > > > On Sun, Nov 12, 2023 at 6:22 AM Aaron Ballman via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> > >> > >> Author: Aaron Ballman > >> Date: 2023-11-12T09:22:15-05:00 > >> New Revision: 8569465adf5e6c792e88be56b0e6b24f1c74e633 > >> > >> URL: > https://github.com/llvm/llvm-project/commit/8569465adf5e6c792e88be56b0e6b24f1c74e633 > >> DIFF: > https://github.com/llvm/llvm-project/commit/8569465adf5e6c792e88be56b0e6b24f1c74e633.diff > >> > >> LOG: Add a Clang NATVIS visualizer for StringLiteral > >> > >> Added: > >> > >> > >> Modified: > >> clang/utils/ClangVisualizers/clang.natvis > >> > >> Removed: > >> > >> > >> > >> > ################################################################################ > >> diff --git a/clang/utils/ClangVisualizers/clang.natvis > b/clang/utils/ClangVisualizers/clang.natvis > >> index 9faaa8a8bba8cf0..0c09d3480b07a9a 100644 > >> --- a/clang/utils/ClangVisualizers/clang.natvis > >> +++ b/clang/utils/ClangVisualizers/clang.natvis > >> @@ -1000,8 +1000,15 @@ For later versions of Visual Studio, no setup is > required--> > >> </Expand> > >> </Type> > >> <Type Name="clang::Expr"> > >> + <DisplayString > Condition="StmtBits.sClass==clang::Stmt::StmtClass::StringLiteralClass" > IncludeView="poly">{*(clang::StringLiteral *)this}</DisplayString> > >> <DisplayString>Expression of class > {(clang::Stmt::StmtClass)StmtBits.sClass,en} and type > {TR,view(cpp)}</DisplayString> > >> </Type> > >> + <Type Name="clang::StringLiteral"> > >> + <Expand> > >> + <Item Name="Length">*(unsigned *)(((clang::StringLiteral > *)this)+1)</Item> > >> + <Item Name="Data" > Condition="StringLiteralBits.NumConcatenated==1">(const char > *)(((clang::StringLiteral *)this)+1)+4+4,[*(unsigned > *)(((clang::StringLiteral *)this)+1)]s8</Item> > >> + </Expand> > >> + </Type> > >> <Type Name="clang::DeclAccessPair"> > >> <DisplayString IncludeView="access" Condition="(Ptr&Mask) == > clang::AS_public">public</DisplayString> > >> <DisplayString IncludeView="access" Condition="(Ptr&Mask) == > clang::AS_protected">protected</DisplayString> > >> > >> > >> > >> _______________________________________________ > >> cfe-commits mailing list > >> cfe-commits@lists.llvm.org > >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits