[clang-tools-extra] [clang-tidy] do not expand macros in modernize-use-using fix (PR #113837)
Congcong Cai via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 06:57:41 PST 2024
================
@@ -119,14 +122,55 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- PrintingPolicy PrintPolicy(getLangOpts());
- PrintPolicy.SuppressScope = true;
- PrintPolicy.ConstantArraySizeAsWritten = true;
- PrintPolicy.UseVoidForZeroParams = false;
- PrintPolicy.PrintInjectedClassNameWithArguments = false;
+ const TypeLoc TL = MatchedDecl->getTypeSourceInfo()->getTypeLoc();
+
+ auto [Type, QualifierStr] = [MatchedDecl, &Result, this,
+ &TL]() -> std::pair<std::string, std::string> {
+ SourceRange TypeRange = TL.getSourceRange();
+
+ // Function pointer case, get the left and right side of the identifier
+ // without the identifier.
+ if (TypeRange.fullyContains(MatchedDecl->getLocation())) {
+ return {(Lexer::getSourceText(
+ CharSourceRange::getCharRange(TL.getBeginLoc(),
+ MatchedDecl->getLocation()),
+ *Result.SourceManager, getLangOpts()) +
+ Lexer::getSourceText(
+ CharSourceRange::getCharRange(
+ Lexer::getLocForEndOfToken(MatchedDecl->getLocation(), 0,
+ *Result.SourceManager,
+ getLangOpts()),
+ Lexer::getLocForEndOfToken(TL.getEndLoc(), 0,
+ *Result.SourceManager,
+ getLangOpts())),
+ *Result.SourceManager, getLangOpts()))
+ .str(),
+ ""};
+ }
----------------
HerrCai0907 wrote:
Could you somehow refactor this part of code. It is too hard to understand what is the meaning of each substring due to indentation
https://github.com/llvm/llvm-project/pull/113837
More information about the cfe-commits
mailing list