From 4c810f9d1ad3c24bd015ea27c5e29ab9b0107d7a Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Tue, 17 Dec 2024 16:51:29 +0000 Subject: [PATCH] Use ASTContext's printing policy, reuse the Sema variable. NFC --- tools/ClangPlugin.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/ClangPlugin.cpp b/tools/ClangPlugin.cpp index c868336dd..9e1977e0b 100644 --- a/tools/ClangPlugin.cpp +++ b/tools/ClangPlugin.cpp @@ -164,11 +164,12 @@ namespace clad { request.Function = request.Function->getDefinition(); request.UpdateDiffParamsInfo(m_CI.getSema()); const FunctionDecl* FD = request.Function; - // set up printing policy - clang::LangOptions LangOpts; - LangOpts.CPlusPlus = true; - clang::PrintingPolicy Policy(LangOpts); - Policy.Bool = true; + ASTContext& C = S.getASTContext(); + clang::PrintingPolicy Policy = C.getPrintingPolicy(); +#if CLANG_VERSION_MAJOR > 10 + // Our testsuite expects 'a >' rather than 'a>'. + Policy.SplitTemplateClosers = true; +#endif // if enabled, print source code of the original functions if (m_DO.DumpSourceFn) { FD->print(llvm::outs(), Policy); @@ -183,11 +184,9 @@ namespace clad { std::string Err; if (llvm::sys::DynamicLibrary:: LoadLibraryPermanently(m_DO.CustomModelName.c_str(), &Err)) { - auto& SemaInst = m_CI.getSema(); - unsigned diagID = SemaInst.Diags.getCustomDiagID( + unsigned diagID = S.Diags.getCustomDiagID( DiagnosticsEngine::Error, "Failed to load '%0', %1. Aborting."); - clang::Sema::SemaDiagnosticBuilder stream = SemaInst.Diag(noLoc, - diagID); + clang::Sema::SemaDiagnosticBuilder stream = S.Diag(noLoc, diagID); stream << m_DO.CustomModelName << Err; return nullptr; }