Changeset 243633 in webkit


Ignore:
Timestamp:
Mar 28, 2019 6:29:27 PM (5 years ago)
Author:
Fujii Hironori
Message:

Opcode.h(159,27): warning: adding 'unsigned int' to a string does not append to the string [-Wstring-plus-int]
https://bugs.webkit.org/show_bug.cgi?id=196343

Reviewed by Saam Barati.

Clang reports a compilation warning and recommend '&PADDING_STRING[PADDING_STRING_LENGTH]'
instead of 'PADDING_STRING + PADDING_STRING_LENGTH'.

  • bytecode/Opcode.cpp:

(JSC::padOpcodeName): Moved padOpcodeName from Opcode.h because
this function is used only in Opcode.cpp. Changed macros
PADDING_STRING and PADDING_STRING_LENGTH to simple variables.
(JSC::compareOpcodePairIndices): Replaced pair with std::pair.

  • bytecode/Opcode.h:

(JSC::padOpcodeName): Moved.

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r243626 r243633  
     12019-03-28  Fujii Hironori  <Hironori.Fujii@sony.com>
     2
     3        Opcode.h(159,27): warning: adding 'unsigned int' to a string does not append to the string [-Wstring-plus-int]
     4        https://bugs.webkit.org/show_bug.cgi?id=196343
     5
     6        Reviewed by Saam Barati.
     7
     8        Clang reports a compilation warning and recommend '&PADDING_STRING[PADDING_STRING_LENGTH]'
     9        instead of 'PADDING_STRING + PADDING_STRING_LENGTH'.
     10
     11        * bytecode/Opcode.cpp:
     12        (JSC::padOpcodeName): Moved padOpcodeName from Opcode.h because
     13        this function is used only in Opcode.cpp. Changed macros
     14        PADDING_STRING and PADDING_STRING_LENGTH to simple variables.
     15        (JSC::compareOpcodePairIndices): Replaced pair with std::pair.
     16        * bytecode/Opcode.h:
     17        (JSC::padOpcodeName): Moved.
     18
    1192019-03-28  Tadeu Zagallo  <tzagallo@apple.com>
    220
  • trunk/Source/JavaScriptCore/bytecode/Opcode.cpp

    r240335 r243633  
    5555#if ENABLE(OPCODE_STATS)
    5656
     57inline const char* padOpcodeName(OpcodeID op, unsigned width)
     58{
     59    auto padding = "                                ";
     60    auto paddingLength = strlen(padding);
     61    auto opcodeNameLength = strlen(opcodeNames[op]);
     62    if (opcodeNameLength >= width)
     63        return "";
     64    if (paddingLength + opcodeNameLength < width)
     65        return padding;
     66    return &padding[paddingLength + opcodeNameLength - width];
     67}
     68
    5769long long OpcodeStats::opcodeCounts[numOpcodeIDs];
    5870long long OpcodeStats::opcodePairCounts[numOpcodeIDs][numOpcodeIDs];
     
    8698static int compareOpcodePairIndices(const void* left, const void* right)
    8799{
    88     std::pair<int, int> leftPair = *(pair<int, int>*) left;
     100    std::pair<int, int> leftPair = *(std::pair<int, int>*) left;
    89101    long long leftValue = OpcodeStats::opcodePairCounts[leftPair.first][leftPair.second];
    90     std::pair<int, int> rightPair = *(pair<int, int>*) right;
     102    std::pair<int, int> rightPair = *(std::pair<int, int>*) right;
    91103    long long rightValue = OpcodeStats::opcodePairCounts[rightPair.first][rightPair.second];
    92104   
  • trunk/Source/JavaScriptCore/bytecode/Opcode.h

    r240335 r243633  
    148148#endif
    149149
    150 #define PADDING_STRING "                                "
    151 #define PADDING_STRING_LENGTH static_cast<unsigned>(strlen(PADDING_STRING))
    152 
    153150extern const char* const opcodeNames[];
    154 
    155 inline const char* padOpcodeName(OpcodeID op, unsigned width)
    156 {
    157     unsigned pad = width - strlen(opcodeNames[op]);
    158     pad = std::min(pad, PADDING_STRING_LENGTH);
    159     return PADDING_STRING + PADDING_STRING_LENGTH - pad;
    160 }
    161 
    162 #undef PADDING_STRING_LENGTH
    163 #undef PADDING_STRING
    164151
    165152#if ENABLE(OPCODE_STATS)
Note: See TracChangeset for help on using the changeset viewer.