================ @@ -372,6 +374,292 @@ maybeDropCxxExplicitObjectParameters(ArrayRef<const ParmVarDecl *> Params) { return Params; } +class TypeInlayHintLabelPartBuilder + : public TypeVisitor<TypeInlayHintLabelPartBuilder> { + QualType CurrentType; + NestedNameSpecifier *CurrentNestedNameSpecifier; + ASTContext &Context; + StringRef MainFilePath; + const PrintingPolicy &PP; + SourceManager &SM; + std::vector<InlayHintLabelPart> &LabelChunks; + + struct CurrentTypeRAII { + TypeInlayHintLabelPartBuilder &Builder; + QualType PreviousType; + NestedNameSpecifier *PreviousNestedNameSpecifier; + CurrentTypeRAII(TypeInlayHintLabelPartBuilder &Builder, QualType New, + NestedNameSpecifier *NNS = nullptr) + : Builder(Builder), PreviousType(Builder.CurrentType), + PreviousNestedNameSpecifier(Builder.CurrentNestedNameSpecifier) { + Builder.CurrentType = New; + if (NNS) + Builder.CurrentNestedNameSpecifier = NNS; + } + ~CurrentTypeRAII() { + Builder.CurrentType = PreviousType; + Builder.CurrentNestedNameSpecifier = PreviousNestedNameSpecifier; + } + }; + + void addLabel(llvm::function_ref<void(llvm::raw_ostream &)> NamePrinter, + llvm::function_ref<SourceLocation()> SourceLocationGetter) { ---------------- HighCommander4 wrote:
Since this function calls `SourceLocationGetter` unconditionally, it's simpler to just have it take a `SourceLocation`. Call sites like `VisitUsingType` can use an immediately-invoked lambda (`[&] { ... } ()`) if desired. https://github.com/llvm/llvm-project/pull/86629 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits