[all-commits] [llvm/llvm-project] bcd8e6: [llvm][Support] formatv: non-negative-plus for int...

Konrad Kleine via All-commits all-commits at lists.llvm.org
Thu Mar 12 05:02:35 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bcd8e64884f3bc167757dd68990045b45b329015
      https://github.com/llvm/llvm-project/commit/bcd8e64884f3bc167757dd68990045b45b329015
  Author: Konrad Kleine <kkleine at redhat.com>
  Date:   2026-03-12 (Thu, 12 Mar 2026)

  Changed paths:
    M llvm/include/llvm/Support/FormatProviders.h
    M llvm/include/llvm/Support/NativeFormatting.h
    M llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp
    M llvm/lib/DebugInfo/DWARF/DWARFExpressionPrinter.cpp
    M llvm/lib/Support/NativeFormatting.cpp
    M llvm/unittests/Support/FormatVariadicTest.cpp

  Log Message:
  -----------
  [llvm][Support] formatv: non-negative-plus for integral numbers (#185008)

The older `format()` allows you to print a `+` sign for non-negative    
integral numbers upon request.                                          
                                                                        
Examples:                                                               
                                                                        
```c++                                                                  
format("%+d", 255); // -> "+255"                                        
format("%+d", -12); // -> "-12"                                         
```                                                                     
                                                                        
This change adds the ability to do the same with `formatv()`:           
                                                                        
```c++                                                                  
formatv("{0:+d}", 255); // -> "+255"                                    
formatv("{0:+d}", -12); // -> "-12"                                     
```                                                                     
                                                                        
The default behaviour is not changed. That means, for a format specifier
like "{0:d}" we still print the positive integer without a "+" prefix.  
                                                                        
The special case of "+0" is exactly like it is handled with `format()`: 
                                                                        
```c++                                                                  
format("%+d", 0); // -> "+0"                                            
```                                                                     
                                                                        
This work is related to #35980.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list