13 const clang::MacroDefinition ¯oDefinition,
clang::SourceRange sourceRange,
14 const clang::MacroArgs *macroArgs)
16 Q_UNUSED(macroDefinition);
18 const auto &sm = m_preprocessor.getSourceManager();
19 llvm::StringRef fileName = sm.getFilename(sourceRange.getBegin());
23 const QString funcName = QString::fromStdString(m_preprocessor.getSpelling(token));
24 switch (trFunctionAliasManager.trFunctionByName(funcName)) {
27 case TrFunctionAliasManager::Function_Q_DECLARE_TR_FUNCTIONS:
28 case TrFunctionAliasManager::Function_QT_TRANSLATE_N_NOOP:
29 case TrFunctionAliasManager::Function_QT_TRANSLATE_N_NOOP3:
30 case TrFunctionAliasManager::Function_QT_TRID_NOOP:
31 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP:
32 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP3:
33 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP_UTF8:
34 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP3_UTF8:
35 case TrFunctionAliasManager::Function_QT_TR_NOOP:
36 case TrFunctionAliasManager::Function_QT_TR_NOOP_UTF8:
37 case TrFunctionAliasManager::Function_QT_TR_N_NOOP:
38 qCDebug(lcClang) <<
"MacroExpands: Function name:" << funcName;
43 store.callType = QStringLiteral(
"MacroExpands");
44 store.funcName = funcName;
45 store.lupdateLocationFile = toQt(fileName);
46 store.lupdateInputFile = toQt(m_inputFile);
47 store.lupdateLocationLine = sm.getExpansionLineNumber(sourceRange.getBegin());
48 store.locationCol = sm.getExpansionColumnNumber(sourceRange.getBegin());
51 std::vector<QString> arguments(macroArgs->getNumMacroArguments());
52 for (
unsigned i = 0; i < macroArgs->getNumMacroArguments(); i++) {
53 auto preExpArguments =
const_cast<
clang::MacroArgs*>(macroArgs)->getPreExpArgument(i,
56 bool errorArgument =
false;
57 for (
const auto &preExpArgument : preExpArguments) {
58 const auto kind = preExpArgument.getKind();
59 switch (trFunctionAliasManager.trFunctionByName(funcName)) {
62 case TrFunctionAliasManager::Function_QT_TRANSLATE_N_NOOP:
63 case TrFunctionAliasManager::Function_QT_TRANSLATE_N_NOOP3:
64 case TrFunctionAliasManager::Function_QT_TRID_NOOP:
65 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP:
66 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP3:
67 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP_UTF8:
68 case TrFunctionAliasManager::Function_QT_TRANSLATE_NOOP3_UTF8:
69 case TrFunctionAliasManager::Function_QT_TR_NOOP_UTF8:
70 case TrFunctionAliasManager::Function_QT_TR_NOOP:
71 case TrFunctionAliasManager::Function_QT_TR_N_NOOP:
72 if (!clang::tok::isStringLiteral(kind))
78 if (clang::tok::isStringLiteral(kind))
79 temp += LupdatePrivate::cleanQuote(m_preprocessor.getSpelling(preExpArgument));
81 temp += QString::fromStdString(m_preprocessor.getSpelling(preExpArgument));
84 qCDebug(lcClang) <<
"*********** macro argument : " << temp;
86 storeMacroArguments(arguments, &store);
89 m_ppStores.emplace_back(std::move(store));
133 clang::SourceLocation endifLoc)
137 const auto &sm = m_preprocessor.getSourceManager();
138 llvm::StringRef fileName = sm.getFilename(sourceRange.getBegin());
143 const char *begin = sm.getCharacterData(sourceRange.getBegin());
144 const char *end = sm.getCharacterData(sourceRange.getEnd());
145 llvm::StringRef skippedText = llvm::StringRef(begin, end - begin);
147 qCDebug(lcClang) <<
"SourceRangeSkipped: skipped text:" << QString::fromStdString(skippedText.str());
148 unsigned int beginLine = sm.getExpansionLineNumber(sourceRange.getBegin());
149 unsigned int endLine = sm.getExpansionLineNumber(sourceRange.getEnd());
150 qWarning(
"%s Code with translation information has been skipped "
151 "between lines %d and %d",
152 fileName.str().c_str(), beginLine, endLine);
void InclusionDirective(clang::SourceLocation, const clang::Token &, clang::StringRef, bool, clang::CharSourceRange, const clang::FileEntry *file, clang::StringRef, clang::StringRef, const clang::Module *, clang::SrcMgr::CharacteristicKind) override