~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/libs/cplusplus/pp-engine.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
687
687
 * occurs inside the #ifndef block, but not nested inside other
688
688
 * #if/#ifdef/#ifndef blocks.
689
689
 *
690
 
 * This method tracks the state, and is called from \c updateIncludeGuardState
 
690
 * This function tracks the state, and is called from \c updateIncludeGuardState
691
691
 * which handles the most common no-op cases.
692
692
 *
693
693
 * @param hint indicates what kind of token is encountered in the input
857
857
        // to the macro that generated this token. In either case, the macro
858
858
        // that generated the token still needs to be blocked (!), which is
859
859
        // recorded in the token buffer. Removing the blocked macro and the
860
 
        // empty token buffer happens the next time that this method is called.
 
860
        // empty token buffer happens the next time that this function is called.
861
861
    } else {
862
862
        // No token buffer, so have the lexer scan the next token.
863
863
        tk->setSource(m_state.m_source);
1064
1064
            // This is not the most beautiful approach but it's quite reasonable. What we do here
1065
1065
            // is to create a fake identifier token which is only composed by whitespaces. It's
1066
1066
            // also not marked as expanded so it it can be treated as a regular token.
1067
 
            QByteArray content(idTk.f.length + computeDistance(idTk), ' ');
 
1067
            const QByteArray content(int(idTk.f.length + computeDistance(idTk)), ' ');
1068
1068
            PPToken fakeIdentifier = generateToken(T_IDENTIFIER,
1069
1069
                                                   content.constData(), content.length(),
1070
1070
                                                   idTk.lineno, false, false);
1131
1131
    for (size_t i = 0; i < bodySize && expanded.size() < MAX_TOKEN_EXPANSION_COUNT;
1132
1132
            ++i) {
1133
1133
        int expandedSize = expanded.size();
1134
 
        PPToken bodyTk = body.at(i);
 
1134
        PPToken bodyTk = body.at(int(i));
1135
1135
 
1136
1136
        if (bodyTk.is(T_IDENTIFIER)) {
1137
1137
            const ByteArrayRef id = bodyTk.asByteArrayRef();
1152
1152
 
1153
1153
                    const int actualsSize = actualsForThisParam.size();
1154
1154
 
1155
 
                    if (i > 0 && body[i - 1].is(T_POUND)) {
 
1155
                    if (i > 0 && body[int(i) - 1].is(T_POUND)) {
1156
1156
                        QByteArray enclosedString;
1157
1157
                        enclosedString.reserve(256);
1158
1158
 
1205
1205
            expanded.push_back(bodyTk);
1206
1206
        }
1207
1207
 
1208
 
        if (i > 1 && body[i - 1].is(T_POUND_POUND)) {
 
1208
        if (i > 1 && body[int(i) - 1].is(T_POUND_POUND)) {
1209
1209
            if (expandedSize < 1 || expanded.size() == expandedSize) //### TODO: [cpp.concat] placemarkers
1210
1210
                continue;
1211
1211
            const PPToken &leftTk = expanded[expandedSize - 1];
1414
1414
            unsigned trackedColumn = 0;
1415
1415
            if (tk.expanded() && !tk.generated()) {
1416
1416
                trackedLine = tk.lineno;
1417
 
                trackedColumn = computeDistance(tk, true);
 
1417
                trackedColumn = unsigned(computeDistance(tk, true));
1418
1418
            }
1419
1419
            m_state.m_expandedTokensInfo.append(qMakePair(trackedLine, trackedColumn));
1420
1420
        } else if (m_state.m_expansionStatus == JustFinishedExpansion) {
1862
1862
            else if (m_client && !wasSkipping && startSkipping)
1863
1863
                startSkippingBlocks(poundToken);
1864
1864
        }
1865
 
    }
1866
1865
#ifndef NO_DEBUG
1867
 
    else {
 
1866
    } else {
1868
1867
        std::cerr << "*** WARNING #else without #if" << std::endl;
 
1868
#endif // NO_DEBUG
1869
1869
    }
1870
 
#endif // NO_DEBUG
1871
1870
}
1872
1871
 
1873
1872
void Preprocessor::handleEndIfDirective(PPToken *tk, const PPToken &poundToken)
1930
1929
            startSkippingBlocks(*tk);
1931
1930
 
1932
1931
        lex(tk); // consume the identifier
1933
 
    }
1934
1932
#ifndef NO_DEBUG
1935
 
    else {
 
1933
    } else {
1936
1934
        std::cerr << "*** WARNING #ifdef without identifier" << std::endl;
 
1935
#endif // NO_DEBUG
1937
1936
    }
1938
 
#endif // NO_DEBUG
1939
1937
}
1940
1938
 
1941
1939
void Preprocessor::handleUndefDirective(PPToken *tk)
1948
1946
        if (m_client && macro)
1949
1947
            m_client->macroAdded(*macro);
1950
1948
        lex(tk); // consume macro name
1951
 
    }
1952
1949
#ifndef NO_DEBUG
1953
 
    else {
 
1950
    } else {
1954
1951
        std::cerr << "*** WARNING #undef without identifier" << std::endl;
 
1952
#endif // NO_DEBUG
1955
1953
    }
1956
 
#endif // NO_DEBUG
1957
1954
}
1958
1955
 
1959
1956
PPToken Preprocessor::generateToken(enum Kind kind,
1988
1985
        else if (kind == T_NUMERIC_LITERAL)
1989
1986
            tk.number = m_state.m_lexer->control()->numericLiteral(m_scratchBuffer.constData() + pos, length);
1990
1987
    }
1991
 
    tk.offset = pos;
 
1988
    tk.offset = unsigned(pos);
1992
1989
    tk.f.length = length;
1993
1990
    tk.f.generated = true;
1994
1991
    tk.f.expanded = true;