kuganv created this revision. Herald added a subscriber: kadircet. Herald added a project: All. kuganv updated this revision to Diff 489882. kuganv edited the summary of this revision. kuganv added a comment. kuganv added subscribers: DmitryPolukhin, 0x1eaf, ivanmurashko. kuganv updated this revision to Diff 494242. kuganv added reviewers: craig.topper, jkorous, rnk, gribozavr. kuganv published this revision for review. Herald added subscribers: cfe-commits, ilya-biryukov. Herald added a project: clang.
Updating the summary. kuganv added a comment. Rebasing the diff to latest main Especially in generated code with sparse comments, it takes longer to bailout when there is code in-between. Searching from last (with find_last_of) bails out faster. This shows up in perf profiles with clangd in some auto-generated code. ASTContext::getRawCommentForDeclNoCacheImpl showing as much as 18.2% in this case. With find_last_of, this drops to 2.8%. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D141950 Files: clang/lib/AST/ASTContext.cpp Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -348,7 +348,7 @@ // There should be no other declarations or preprocessor directives between // comment and declaration. - if (Text.find_first_of(";{}#@") != StringRef::npos) + if (Text.find_last_of(";{}#@") != StringRef::npos) return nullptr; return CommentBeforeDecl;
Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -348,7 +348,7 @@ // There should be no other declarations or preprocessor directives between // comment and declaration. - if (Text.find_first_of(";{}#@") != StringRef::npos) + if (Text.find_last_of(";{}#@") != StringRef::npos) return nullptr; return CommentBeforeDecl;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits