17 if (!stmt || !context.isEmpty())
20 for (
auto it = stmt->child_begin() ; it !=stmt->child_end() ; it++) {
21 if (!context.isEmpty())
23 clang::Stmt *child = *it;
24 clang::StringLiteral *stringLit = llvm::dyn_cast_or_null<
clang::StringLiteral>(child);
26 context = toQt(stringLit->getString());
29 exploreChildrenForFirstStringLiteral(child, context);
48 bool tr_method_present =
false;
49 bool access_for_qobject =
false;
50 bool access_for_qdeclaretrfunction =
false;
52 for (
auto decl : recordDecl->decls()) {
53 clang::AccessSpecDecl *accessSpec = llvm::dyn_cast<clang::AccessSpecDecl>(decl);
54 clang::CXXMethodDecl *method = llvm::dyn_cast<clang::CXXMethodDecl>(decl);
56 if (!accessSpec && !method)
60 std::string name = method->getNameAsString();
62 tr_method_present =
true;
64 exploreChildrenForFirstStringLiteral(method->getBody(), context);
66 }
else if (accessSpec) {
67 if (!accessSpec->getBeginLoc().isValid())
69 QString location = QString::fromStdString(
70 sm.getSpellingLoc(accessSpec->getBeginLoc()).printToString(sm));
71 qsizetype indexLast = location.lastIndexOf(QLatin1String(
":"));
72 qsizetype indexBeforeLast = location.lastIndexOf(QLatin1String(
":"), indexLast-1);
73 location.truncate(indexBeforeLast);
74 const QString qtInstallDirPath = QLibraryInfo::path(QLibraryInfo::PrefixPath);
75 const QString accessForQDeclareTrFunctions = QStringLiteral(
"qcoreapplication.h");
76 const QString accessForQObject = QStringLiteral(
"qtmetamacros.h");
78 if (location.startsWith(qtInstallDirPath, Qt::CaseInsensitive)) {
79 if (location.endsWith(accessForQDeclareTrFunctions))
80 access_for_qdeclaretrfunction =
true;
81 if (location.endsWith(accessForQObject))
82 access_for_qobject =
true;
87 bool access_to_qtbase =
false;
89 if (context.isEmpty())
90 access_to_qtbase = access_for_qobject;
92 access_to_qtbase = access_for_qdeclaretrfunction;
94 return tr_method_present && access_to_qtbase;
101 if (isQObjectOrQDeclareTrFunctionMacroDeclared(recordDecl, context, sm)) {
102 return context.isEmpty() ? QString::fromStdString(recordDecl->getQualifiedNameAsString()) : context;
107
108
109
110
111
112
113
114
115
116
117
119 return exploreBases(recordDecl, sm);
127 for (
auto base : recordDecl->bases()) {
128 const clang::Type *type = base.getType().getTypePtrOrNull();
130 clang::CXXRecordDecl *baseDecl = type->getAsCXXRecordDecl();
133 context = lookForContext(baseDecl, sm);
134 if (!context.isEmpty())
155 clang::DeclContext *decl = namedDecl->getDeclContext();
159 qCDebug(lcClang) <<
"--------------------- decl kind name: " << decl->getDeclKindName();
161 clang::CXXRecordDecl *recordDecl = llvm::dyn_cast<
clang::CXXRecordDecl>(decl);
163 context = lookForContext(recordDecl, sm);
165 if (!context.isEmpty())
168 decl = decl->getParent();
175
176
177
178
179
180
181
182
195 llvm::raw_string_ostream tmp(context);
196 func->printQualifiedName(tmp);
199 context = func->getQualifiedNameAsString();
201 return QString::fromStdString(context.substr(0, context.find(
"::" + funcName, 0)));
204 static bool capture(
const QRegularExpression &exp,
const QString &line, QString *i, QString *c)
206 i->clear(), c->clear();
207 auto result = exp.match(line);
208 if (!result.hasMatch())
211 *i = result.captured(QLatin1String(
"identifier"));
212 *c = result.captured(QStringLiteral(
"comment")).trimmed();
214 if (*i == QLatin1String(
"%"))
217 return !c->isEmpty();
222 return source.contains(
"\"");
227 if (text.contains(llvm::StringRef(
"qtTrId(")))
229 if (text.contains(llvm::StringRef(
"tr(")))
231 if (text.contains(llvm::StringRef(
"trUtf8(")))
233 if (text.contains(llvm::StringRef(
"translate(")))
235 if (text.contains(llvm::StringRef(
"Q_DECLARE_TR_FUNCTIONS(")))
237 if (text.contains(llvm::StringRef(
"QT_TR_N_NOOP(")))
239 if (text.contains(llvm::StringRef(
"QT_TRID_N_NOOP(")))
241 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_N_NOOP(")))
243 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_N_NOOP3(")))
245 if (text.contains(llvm::StringRef(
"QT_TR_NOOP(")))
247 if (text.contains(llvm::StringRef(
"QT_TRID_NOOP(")))
249 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_NOOP(")))
251 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_NOOP3(")))
253 if (text.contains(llvm::StringRef(
"QT_TR_NOOP_UTF8(")))
255 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_NOOP_UTF8(")))
257 if (text.contains(llvm::StringRef(
"QT_TRANSLATE_NOOP3_UTF8(")))
263 const clang::SourceManager &sm)
265 clang::SourceLocation start = sourceRange.getBegin();
266 clang::SourceLocation end = sourceRange.getEnd();
267 return point == start || point == end || (sm.isBeforeInTranslationUnit(start, point)
268 && sm.isBeforeInTranslationUnit(point, end));
273 const clang::SourceManager &SM;
280 return SM.isBeforeInTranslationUnit(LHS.getBeginLoc(), RHS.getBeginLoc());
291
292
293
294
295
298 const auto fullLocation = m_context->getFullLoc(callExpression->getBeginLoc());
299 if (fullLocation.isInvalid())
301 clang::FunctionDecl *func = callExpression->getDirectCallee();
304 clang::QualType q = callExpression->getType();
305 if (!q.getTypePtrOrNull())
310 std::string Filename;
313 const auto funcName = QString::fromStdString(func->getNameInfo().getAsString());
316 switch (trFunctionAliasManager.trFunctionByName(funcName)) {
322 const auto &sm = m_context->getSourceManager();
323 const auto fileLoc = sm.getFileLoc(callExpression->getBeginLoc());
324 if (fileLoc.isInvalid() || !fileLoc.isFileID())
327 auto presumedLoc = sm.getPresumedLoc(fileLoc,
false);
328 if (presumedLoc.isInvalid())
330 info = { presumedLoc.getLine(), presumedLoc.getFilename() };
340 qCDebug(lcClang) <<
"************************** VisitCallExpr ****************";
344 store.callType = QStringLiteral(
"ASTRead_CallExpr");
345 store.funcName = funcName;
346 store.lupdateLocationFile = QString::fromStdString(info.Filename);
347 store.lupdateLocationLine = info.Line;
348 store.contextRetrieved = LupdatePrivate::contextForFunctionDecl(func, funcName.toStdString());
350 qCDebug(lcClang) <<
"CallType : ASTRead_CallExpr";
351 qCDebug(lcClang) <<
"Function name : " << store.funcName;
352 qCDebug(lcClang) <<
"File location : " << store.lupdateLocationFile;
353 qCDebug(lcClang) <<
"Line : " << store.lupdateLocationLine;
354 qCDebug(lcClang) <<
"Context retrieved : " << store.contextRetrieved;
358 const std::vector<QString> rawComments = rawCommentsForCallExpr(callExpression);
359 for (
const auto &rawComment : rawComments) {
360 setInfoFromRawComment(rawComment, &store);
361 qCDebug(lcClang) <<
"Raw comments :" << rawComment;
364 clang::LangOptions langOpts;
365 langOpts.CPlusPlus =
true;
366 clang::PrintingPolicy policy(langOpts);
367 std::vector<std::string> arguments(callExpression->getNumArgs(),
"");
368 for (
unsigned int i = 0; i < callExpression->getNumArgs(); i++) {
369 auto arg = callExpression->getArg(i);
370 llvm::raw_string_ostream temp(arguments[i]);
371 arg->printPretty(temp,
nullptr, policy);
375 switch (trFunctionAliasManager.trFunctionByName(funcName)) {
380 store.lupdateSource = LupdatePrivate::cleanQuote(arguments[0]);
381 store.lupdateComment = LupdatePrivate::cleanQuote(arguments[1]);
382 store.lupdatePlural = QString::fromStdString(arguments[2]);
383 qCDebug(lcClang) <<
"Source : " << store.lupdateSource;
384 qCDebug(lcClang) <<
"Comment : " << store.lupdateComment;
385 qCDebug(lcClang) <<
"Plural : " << store.lupdatePlural;
392 store.contextArg = LupdatePrivate::cleanQuote(arguments[0]);
393 store.lupdateSource = LupdatePrivate::cleanQuote(arguments[1]);
394 store.lupdateComment = LupdatePrivate::cleanQuote(arguments[2]);
395 store.lupdatePlural = QString::fromStdString(arguments[3]);
396 qCDebug(lcClang) <<
"Context Arg : " << store.contextArg;
397 qCDebug(lcClang) <<
"Source : " << store.lupdateSource;
398 qCDebug(lcClang) <<
"Comment : " << store.lupdateComment;
399 qCDebug(lcClang) <<
"Plural : " << store.lupdatePlural;
404 store.lupdateId = LupdatePrivate::cleanQuote(arguments[0]);
405 store.lupdatePlural = QString::fromStdString(arguments[1]);
406 qCDebug(lcClang) <<
"ID : " << store.lupdateId;
407 qCDebug(lcClang) <<
"Plural : " << store.lupdatePlural;
411 store.locationCol = 0;
412 m_trCalls.emplace_back(std::move(store));
418 auto &sourceMgr = m_context->getSourceManager();
419 processIsolatedComments(sourceMgr.getMainFileID()) ;
423
424
427 qCDebug(lcClang) <<
"==== processIsolatedComments ====";
428 auto &sourceMgr = m_context->getSourceManager();
431 const auto commentsInThisFile = m_context->Comments.getCommentsInFile(file);
432 if (!commentsInThisFile)
435 std::vector<clang::RawComment *> tmp;
436 for (
const auto &commentInFile : *commentsInThisFile)
437 tmp.emplace_back(commentInFile.second);
438 clang::ArrayRef<clang::RawComment *> rawComments = tmp;
441 clang::ArrayRef<
clang::RawComment *> rawComments = m_context->getRawCommentList().getComments();
445 if (rawComments.empty())
453 for (
const auto &rawComment : rawComments) {
454 if (!LupdatePrivate::isFileSignificant(sourceMgr.getFilename(rawComment->getBeginLoc()).str()))
459 TranslationRelatedStore store;
460 store.lupdateLocationLine = sourceMgr.getPresumedLoc(rawComment->getBeginLoc(),
false).getLine();
461 store.lupdateLocationFile = QString::fromStdString(
462 sourceMgr.getPresumedLoc(rawComment->getBeginLoc(),
false).getFilename());
463 QString comment = toQt(rawComment->getRawText(sourceMgr));
464 qCDebug(lcClang) <<
" raw Comment : \n" << comment;
465 setInfoFromRawComment(comment, &store);
470
471
472std::vector<QString>
LupdateVisitor::rawCommentsForCallExpr(
const clang::CallExpr *callExpr)
const
476 return rawCommentsFromSourceLocation(m_context->getFullLoc(callExpr->getBeginLoc()));
479std::vector<QString>
LupdateVisitor::rawCommentsFromSourceLocation(
480 clang::SourceLocation sourceLocation)
const
484 if (sourceLocation.isInvalid() || !sourceLocation.isFileID()) {
485 qCDebug(lcClang) <<
"The declaration does not map directly to a location in a file,"
489 auto &sourceMgr = m_context->getSourceManager();
492 const clang::FileID file = sourceMgr.getDecomposedLoc(sourceLocation).first;
493 const auto commentsInThisFile = m_context->Comments.getCommentsInFile(file);
494 if (!commentsInThisFile)
497 std::vector<clang::RawComment *> tmp;
498 for (
const auto &commentInFile : *commentsInThisFile)
499 tmp.emplace_back(commentInFile.second);
500 clang::ArrayRef<clang::RawComment *> rawComments = tmp;
502 clang::ArrayRef<
clang::RawComment *> rawComments = m_context->getRawCommentList().getComments();
506 if (rawComments.empty())
510 clang::RawComment commentAtDeclarationLocation(sourceMgr,
511 clang::SourceRange(sourceLocation), m_context->getLangOpts().CommentOpts,
false);
521 auto comment =
std::lower_bound(rawComments.begin(), rawComments.end(),
522 &commentAtDeclarationLocation, compareSourceLocation);
525 if (comment == rawComments.begin())
529 std::pair<
clang::FileID,
unsigned> declLocDecomp = sourceMgr.getDecomposedLoc(sourceLocation);
532 bool invalid =
false;
533 const char *buffer = sourceMgr.getBufferData(declLocDecomp.first, &invalid).data();
535 qCDebug(lcClang).nospace() <<
"An error occurred fetching the source buffer of file: "
536 << toQt(sourceMgr.getFilename(sourceLocation));
540 std::vector<QString> retrievedRawComments;
541 auto lastDecompLoc = declLocDecomp.second;
542 const auto declLineNum = sourceMgr.getLineNumber(declLocDecomp.first, declLocDecomp.second);
544 std::advance(comment, -1);
547 std::pair<
clang::FileID,
unsigned> commentEndDecomp
548 = sourceMgr.getDecomposedLoc((*comment)->getSourceRange().getEnd());
551 if (declLocDecomp.first != commentEndDecomp.first) {
552 qCDebug(lcClang) <<
"Comment and the declaration aren't in the same file. Comment '"
553 << toQt((*comment)->getRawText(sourceMgr)) <<
"' is ignored, return.";
554 return retrievedRawComments;
559 bool sameLineComment =
false;
560 if (declLineNum == sourceMgr.getLineNumber(commentEndDecomp.first, commentEndDecomp.second))
561 sameLineComment =
true;
564 llvm::StringRef text(buffer + commentEndDecomp.second,
565 lastDecompLoc - commentEndDecomp.second);
569 if (text.find_first_of(
";}#@") != llvm::StringRef::npos) {
570 qCDebug(lcClang) <<
"Found another declaration or preprocessor directive between"
571 " comment and declaration, break.";
574 if (sameLineComment && text.find_first_of(
",") != llvm::StringRef::npos) {
575 qCDebug(lcClang) <<
"Comment ends on same line as the declaration and is separated "
576 "from the tr call by a ','. Comment '"
577 << toQt((*comment)->getRawText(sourceMgr))
578 <<
"' is ignored, continue.";
584 qCDebug(lcClang) <<
"Found another translation function between comment and "
585 "declaration, break.";
589 retrievedRawComments.emplace(retrievedRawComments.begin(),
590 toQt((*comment)->getRawText(sourceMgr)));
591 lastDecompLoc = sourceMgr.getDecomposedLoc((*comment)->getSourceRange().getBegin()).second;
592 }
while (comment != rawComments.begin());
594 return retrievedRawComments;
598
599
600
601void LupdateVisitor::setInfoFromRawComment(
const QString &commentString,
604 const QStringList commentLines = commentString.split(QLatin1Char(
'\n'));
606 static const QRegularExpression
608 QStringLiteral(
"^\\/\\/(?<identifier>[:=~%]|(\\s*?TRANSLATOR))\\s+(?<comment>.+)$"));
609 static const QRegularExpression
611 QStringLiteral(
"^\\/\\*(?<identifier>[:=~%]|(\\s*?TRANSLATOR))\\s+(?<comment>.+)\\*\\/$"));
612 static const QRegularExpression
614 QStringLiteral(
"^\\/\\*(?<identifier>[:=~%]|(\\s*?TRANSLATOR))\\s+(?<comment>.*)$"));
616 static const QRegularExpression isSpace(QStringLiteral(
"\\s+"));
617 static const QRegularExpression idefix(
618 QStringLiteral(
"^\\/\\*(?<identifier>[:=~%]|(\\s*?TRANSLATOR))"));
621 bool sawStarPrefix =
false;
622 bool sourceIdentifier =
false;
624 int storeLine = store->lupdateLocationLine;
625 int lineExtra = storeLine - 1;
627 QString comment, identifier;
628 for (
auto line : commentLines) {
629 line = line.trimmed();
631 if (!sawStarPrefix) {
632 if (line.startsWith(QStringLiteral(
"//"))) {
634 save = LupdatePrivate::capture(cppStyle, line, &identifier, &comment);
635 storeLine = lineExtra;
636 }
else if (line.startsWith(QLatin1String(
"/*")) && line.endsWith(QLatin1String(
"*/"))) {
638 storeLine = lineExtra;
639 save = LupdatePrivate::capture(cStyleSingle, line, &identifier, &comment);
640 }
else if (line.startsWith(QLatin1String(
"/*"))) {
641 storeLine = lineExtra;
642 sawStarPrefix =
true;
644 auto result = idefix.match(line);
645 if (!result.hasMatch())
647 identifier = result.captured(QLatin1String(
"identifier"));
650 if (line.size() > (identifier.size() + 3))
651 LupdatePrivate::capture(cStyleMultiBegin, line, &identifier, &comment);
652 sourceIdentifier = (identifier == QLatin1String(
"%"));
655 if (line.endsWith(QLatin1String(
"*/"))) {
656 sawStarPrefix =
false;
657 line = line.remove(QLatin1String(
"*/")).trimmed();
660 if (sourceIdentifier) {
661 line = LupdatePrivate::cleanQuote(line.toStdString(),
662 LupdatePrivate::QuoteCompulsary::Left);
665 if (!line.isEmpty() && !comment.isEmpty() && !sourceIdentifier)
666 comment.append(QLatin1Char(
' '));
669 save = !sawStarPrefix && !comment.isEmpty();
676 if (!store->funcName.isEmpty()) {
677 if (identifier == QStringLiteral(
":")) {
678 if (!store->lupdateExtraComment.isEmpty())
679 store->lupdateExtraComment.append(QLatin1Char(
' '));
680 store->lupdateExtraComment += comment;
681 }
else if (identifier == QStringLiteral(
"=")) {
682 if (!store->lupdateIdMetaData.isEmpty())
683 store->lupdateIdMetaData.append(QLatin1Char(
' '));
684 store->lupdateIdMetaData = comment;
685 }
else if (identifier == QStringLiteral(
"~")) {
686 auto first = comment.section(isSpace, 0, 0);
687 auto second = comment.mid(first.size()).trimmed();
688 if (!second.isEmpty())
689 store->lupdateAllMagicMetaData.insert(first, second);
690 }
else if (identifier == QLatin1String(
"%")) {
691 store->lupdateSourceWhenId += comment;
693 }
else if (identifier.trimmed() == QStringLiteral(
"TRANSLATOR")) {
697 qCDebug(lcClang) <<
"Comment = " << comment;
698 TranslationRelatedStore newStore;
700 newStore.funcName = QStringLiteral(
"TRANSLATOR");
701 auto index = comment.indexOf(QStringLiteral(
" "));
703 newStore.contextArg = comment.left(index).trimmed();
704 newStore.lupdateComment = comment.mid(index).trimmed();
706 newStore.lupdateLocationFile = store->lupdateLocationFile;
707 newStore.lupdateLocationLine = storeLine;
708 newStore.locationCol = 0;
709 newStore.printStore();
710 m_trCalls.emplace_back(std::move(newStore));
721 QString inputFile = toQt(m_inputFile);
722 for (
const auto &store : m_stores->Preprocessor) {
723 if (store.lupdateInputFile == inputFile)
724 processPreprocessorCall(store);
729 for (
const clang::FileEntry *file : m_preprocessor->getIncludedFiles()) {
730 auto &sourceMgr = m_context->getSourceManager();
732 clang::StringRef fileNameRealPath = file->tryGetRealPathName();
733 if (!LupdatePrivate::isFileSignificant(fileNameRealPath.str())
734 || fileNameRealPath.str() == m_inputFile)
737 auto sourceFile = sourceMgr.getFileManager()
738 .getFile(fileNameRealPath);
739 auto sourceLocation = sourceMgr.translateFileLineCol(sourceFile.get(), 1, 1);
740 const clang::FileID fileId = sourceMgr.getDecomposedLoc(sourceLocation).first;
741 processIsolatedComments(fileId);
745 if (m_qDeclareTrMacroAll.size() > 0 || m_noopTranslationMacroAll.size() > 0)
752 const std::vector<QString> rawComments = rawCommentsFromSourceLocation(store
753 .callLocation(m_context->getSourceManager()));
755 for (
const auto &rawComment : rawComments)
756 setInfoFromRawComment(rawComment, &store);
760 if (store.callType.contains(QStringLiteral(
"InclusionDirective"))) {
761 auto &sourceMgr = m_context->getSourceManager();
763 processIsolatedComments(file);
769 if (store.funcName.contains(QStringLiteral(
"Q_DECLARE_TR_FUNCTIONS")))
770 m_qDeclareTrMacroAll.emplace_back(std::move(store));
772 m_noopTranslationMacroAll.emplace_back(std::move(store));
781 auto fullLocation = m_context->getFullLoc(namedDeclaration->getBeginLoc());
782 if (!fullLocation.isValid() || !fullLocation.getFileEntry())
786 auto fileEntry = fullLocation.getFileEntryRef();
787 if (fileEntry && !LupdatePrivate::isFileSignificant(fileEntry->getName().str()))
794 qCDebug(lcClang) <<
"NamedDecl Name: " << QString::fromStdString(namedDeclaration->getQualifiedNameAsString());
795 qCDebug(lcClang) <<
"NamedDecl source: " << QString::fromStdString(namedDeclaration->getSourceRange().printToString(
796 m_context->getSourceManager()));
805 qCDebug(lcClang) <<
"=================findContextForTranslationStoresFromPP===================";
806 qCDebug(lcClang) <<
"m_noopTranslationMacroAll " << m_noopTranslationMacroAll.size();
807 qCDebug(lcClang) <<
"m_qDeclareTrMacroAll " << m_qDeclareTrMacroAll.size();
808 clang::SourceManager &sm = m_context->getSourceManager();
814 for (TranslationRelatedStore &store : m_noopTranslationMacroAll) {
815 if (!store.contextArg.isEmpty())
817 clang::SourceLocation sourceLoc = store.callLocation(sm);
818 if (!sourceLoc.isValid())
820 if (LupdatePrivate::isPointWithin(namedDeclaration->getSourceRange(), sourceLoc, sm)) {
822 store.contextRetrieved = LupdatePrivate::contextForNoopMacro(namedDeclaration, sm);
823 qCDebug(lcClang) <<
"------------------------------------------NOOP Macro in range ---";
824 qCDebug(lcClang) <<
"Range " << QString::fromStdString(namedDeclaration->getSourceRange().printToString(sm));
825 qCDebug(lcClang) <<
"Point " << QString::fromStdString(sourceLoc.printToString(sm));
826 qCDebug(lcClang) <<
"=========== Visit Named Declaration =============================";
827 qCDebug(lcClang) <<
" Declaration Location " <<
828 QString::fromStdString(namedDeclaration->getSourceRange().printToString(sm));
829 qCDebug(lcClang) <<
" Macro Location "
830 << QString::fromStdString(sourceLoc.printToString(sm));
831 qCDebug(lcClang) <<
" Context namedDeclaration->getQualifiedNameAsString() "
832 << QString::fromStdString(namedDeclaration->getQualifiedNameAsString());
833 qCDebug(lcClang) <<
" Context LupdatePrivate::contextForNoopMacro "
834 << store.contextRetrieved;
835 qCDebug(lcClang) <<
" Context Retrieved " << store.contextRetrieved;
836 qCDebug(lcClang) <<
"=================================================================";
841 for (TranslationRelatedStore &store : m_qDeclareTrMacroAll) {
842 clang::SourceLocation sourceLoc = store.callLocation(sm);
843 if (!sourceLoc.isValid())
845 if (LupdatePrivate::isPointWithin(namedDeclaration->getSourceRange(), sourceLoc, sm)) {
846 store.contextRetrieved = QString::fromStdString(
847 namedDeclaration->getQualifiedNameAsString());
848 qCDebug(lcClang) <<
"------------------------------------------DECL Macro in range ---";
849 qCDebug(lcClang) <<
"Range " << QString::fromStdString(namedDeclaration->getSourceRange().printToString(sm));
850 qCDebug(lcClang) <<
"Point " << QString::fromStdString(sourceLoc.printToString(sm));
851 qCDebug(lcClang) <<
"=========== Visit Named Declaration =============================";
852 qCDebug(lcClang) <<
" Declaration Location " <<
853 QString::fromStdString(namedDeclaration->getSourceRange().printToString(sm));
854 qCDebug(lcClang) <<
" Macro Location "
855 << QString::fromStdString(sourceLoc.printToString(sm));
856 qCDebug(lcClang) <<
" Context namedDeclaration->getQualifiedNameAsString() "
857 << store.contextRetrieved;
858 qCDebug(lcClang) <<
" Context Retrieved " << store.contextRetrieved;
859 qCDebug(lcClang) <<
"=================================================================";
867 qCDebug(lcClang) <<
"=================generateOutput============================";
868 m_noopTranslationMacroAll.erase(std::remove_if(m_noopTranslationMacroAll.begin(),
869 m_noopTranslationMacroAll.end(), [](
const TranslationRelatedStore &store) {
874 if (!LupdatePrivate::isFileSignificant(store.lupdateLocationFile.toStdString()))
877 }), m_noopTranslationMacroAll.end());
879 m_stores->QNoopTranlsationWithContext.emplace_bulk(std::move(m_noopTranslationMacroAll));
881 m_qDeclareTrMacroAll.erase(std::remove_if(m_qDeclareTrMacroAll.begin(),
882 m_qDeclareTrMacroAll.end(), [](
const TranslationRelatedStore &store) {
884 return store.contextRetrieved.isEmpty();
885 }), m_qDeclareTrMacroAll.end());
886 m_stores->QDeclareTrWithContext.emplace_bulk(std::move(m_qDeclareTrMacroAll));
888 processIsolatedComments();
889 m_stores->AST.emplace_bulk(std::move(m_trCalls));
bool operator()(const clang::RawComment &LHS, const clang::RawComment &RHS)
BeforeThanCompare(const clang::SourceManager &SM)
bool operator()(const clang::RawComment *LHS, const clang::RawComment *RHS)
bool VisitNamedDecl(clang::NamedDecl *namedDeclaration)
void findContextForTranslationStoresFromPP(clang::NamedDecl *namedDeclaration)
bool VisitCallExpr(clang::CallExpr *callExpression)
void processPreprocessorCalls()
#define LUPDATE_CLANG_VERSION
#define LUPDATE_CLANG_VERSION_CHECK(major, minor, patch)
bool hasQuote(llvm::StringRef source)
void exploreChildrenForFirstStringLiteral(clang::Stmt *stmt, QString &context)
bool trFunctionPresent(llvm::StringRef text)
QString exploreBases(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
bool isPointWithin(const clang::SourceRange &sourceRange, const clang::SourceLocation &point, const clang::SourceManager &sm)
bool isQObjectOrQDeclareTrFunctionMacroDeclared(clang::CXXRecordDecl *recordDecl, QString &context, const clang::SourceManager &sm)
static bool capture(const QRegularExpression &exp, const QString &line, QString *i, QString *c)
bool isFileSignificant(const std::string &filePath)
QString contextForFunctionDecl(clang::FunctionDecl *func, const std::string &funcName)
QString contextForNoopMacro(clang::NamedDecl *namedDecl, const clang::SourceManager &sm)
QString lookForContext(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
Combined button and popup list for selecting options.