Skip to content
Snippets Groups Projects
  • Alexander Shaposhnikov's avatar
    97a93ed9
    [clang] Fix format specifiers fixits · 97a93ed9
    Alexander Shaposhnikov authored
    This diff fixes printf "fixits" in the case when there is 
    a wrapping macro and the format string needs multiple replacements. 
    In the presence of a macro there is an extra logic in EditedSource.cpp
    to handle multiple uses of the same macro argument 
    (see the old comment inside EditedSource::canInsertInOffset)
    which was mistriggerred when the argument was used only once 
    but required multiple adjustments), as a result the "fixit" 
    was breaking down the format string
    by dropping the second format specifier, i.e. 
    Log1("test 4: %s %s", getNSInteger(), getNSInteger()) 
    was getting replaced with 
    Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) 
    (if one removed the macro and used printf directly it would work fine).
    In this diff we track the location where the macro argument is used and 
    (as it was before) the modifications originating from all the locations 
    except the first one are rejected, but multiple changes are allowed.
    
    Test plan: make check-all
    
    Differential revision: https://reviews.llvm.org/D33976
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305018 91177308-0d34-0410-b5e6-96231b3b80d8
    97a93ed9
    History
    [clang] Fix format specifiers fixits
    Alexander Shaposhnikov authored
    This diff fixes printf "fixits" in the case when there is 
    a wrapping macro and the format string needs multiple replacements. 
    In the presence of a macro there is an extra logic in EditedSource.cpp
    to handle multiple uses of the same macro argument 
    (see the old comment inside EditedSource::canInsertInOffset)
    which was mistriggerred when the argument was used only once 
    but required multiple adjustments), as a result the "fixit" 
    was breaking down the format string
    by dropping the second format specifier, i.e. 
    Log1("test 4: %s %s", getNSInteger(), getNSInteger()) 
    was getting replaced with 
    Log1("test 4: %ld ", (long)getNSInteger(), (long)getNSInteger()) 
    (if one removed the macro and used printf directly it would work fine).
    In this diff we track the location where the macro argument is used and 
    (as it was before) the modifications originating from all the locations 
    except the first one are rejected, but multiple changes are allowed.
    
    Test plan: make check-all
    
    Differential revision: https://reviews.llvm.org/D33976
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305018 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.