From a2997e35ff8f30cc043de8a4fe09e33948802f74 Mon Sep 17 00:00:00 2001 From: Thilina Ratnayaka Date: Wed, 20 Sep 2023 16:37:01 -0500 Subject: [PATCH] [nomp] Print canonical types to expand typedefs --- clang/lib/Parse/ParseNomp.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Parse/ParseNomp.cpp b/clang/lib/Parse/ParseNomp.cpp index dfd47d5c5a37..7c94dfbb44b2 100644 --- a/clang/lib/Parse/ParseNomp.cpp +++ b/clang/lib/Parse/ParseNomp.cpp @@ -577,6 +577,7 @@ static void GetExtVarsAndKnl(std::set &EV, std::string &KnlStr, clang::PrintingPolicy Policy(Opts); Policy.SuppressInitializers = true; + Policy.PrintCanonicalTypes = true; llvm::raw_string_ostream KnlStream(KnlStr); KnlStream << "void " << KnlName << "("; @@ -592,12 +593,8 @@ static void GetExtVarsAndKnl(std::set &EV, std::string &KnlStr, } KnlStream << " {\n"; - SourceLocation BL = FS->getBeginLoc(), EL = FS->getEndLoc(); - llvm::StringRef bfr = SM.getBufferData(SM.getFileID(BL)); - unsigned s = SM.getFileOffset(BL), e = SM.getFileOffset(EL), n = e; - for (; n < bfr.size() && bfr[n] != ';' && bfr[n] != '}'; n++) - ; - KnlStream << std::string(bfr.data() + s, n - s + 2) << "}"; + FS->printPretty(KnlStream, nullptr, Policy, 0); + KnlStream << "}"; } static void CreateNompJitCall(llvm::SmallVector &Stmts,