Skip to content

[lldb][DataFormatter] Fix format specifiers in LibCxxSliceArray summary provider #85763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Michael137
Copy link
Member

This caused following warnings in an LLDB build:

[237/1072] Building CXX object tools/l...lusLanguage.dir/LibCxxSliceArray.cpp.o
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:53: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                         ~~~~~~~~~                   ^~~~~~
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:61: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                                          ~~~~~~~~~          ^~~~
2 warnings generated.

This patch simply changes the format specifiers to use the %zu for size_ts.

…ry providers

This caused following warnings in an LLDB build:
```
[237/1072] Building CXX object tools/l...lusLanguage.dir/LibCxxSliceArray.cpp.o
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:53: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                         ~~~~~~~~~                   ^~~~~~
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:61: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                                          ~~~~~~~~~          ^~~~
2 warnings generated.
```

This patch simply changes the format specifiers to use the `%zu` for
`size_t`s.
@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2024

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

This caused following warnings in an LLDB build:

[237/1072] Building CXX object tools/l...lusLanguage.dir/LibCxxSliceArray.cpp.o
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:53: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                         ~~~~~~~~~                   ^~~~~~
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:61: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                                          ~~~~~~~~~          ^~~~
2 warnings generated.

This patch simply changes the format specifiers to use the %zu for size_ts.


Full diff: https://github.com/llvm/llvm-project/pull/85763.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp (+1-1)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
index 323de11b1c97c9..32e67d2e38c5d3 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
@@ -35,7 +35,7 @@ bool LibcxxStdSliceArraySummaryProvider(ValueObject &valobj, Stream &stream,
     return false;
   const size_t stride = ptr_sp->GetValueAsUnsigned(0);
 
-  stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
+  stream.Printf("stride=%zu size=%zu", stride, size);
 
   return true;
 }

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware LLDB's print accepts %zu, thanks for the fix!

@Michael137 Michael137 merged commit 7edfbf2 into llvm:main Mar 19, 2024
chencha3 pushed a commit to chencha3/llvm-project that referenced this pull request Mar 23, 2024
…ry provider (llvm#85763)

This caused following warnings in an LLDB build:
```
[237/1072] Building CXX object tools/l...lusLanguage.dir/LibCxxSliceArray.cpp.o
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:53: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                         ~~~~~~~~~                   ^~~~~~
/Volumes/Data/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp:38:61: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
   38 |   stream.Printf("stride=%" PRIu64 " size=%" PRIu64, stride, size);
      |                                          ~~~~~~~~~          ^~~~
2 warnings generated.
```

This patch simply changes the format specifiers to use the `%zu` for
`size_t`s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants