diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a0c9885e12a8811bff554b131f99ac6220dd3c4f..34b11dfe080211eedc6e8804e54afaace1527855 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -489,6 +489,9 @@ public: mutable llvm::DenseMap BSCDeclContextMap; + /// A mapping to contain the declaration and its desugared decls. + mutable llvm::DenseMap> BSCDesugaredMap; + private: friend class ASTDeclReader; friend class ASTReader; diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h index cb25b2750dd434b59c59bdb2700db03a4ddb1490..f686b7401b023262dfc7c23dc5d8a4fac560ac48 100644 --- a/clang/include/clang/AST/PrettyPrinter.h +++ b/clang/include/clang/AST/PrettyPrinter.h @@ -75,7 +75,7 @@ struct PrintingPolicy { PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true), UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false), CleanUglifiedParameters(false), EntireContentsOfLargeArray(true), - UseEnumerators(true) {} + UseEnumerators(true), RewriteBSC(false) {} /// Adjust this printing policy for cases where it's known that we're /// printing C++ code (for instance, if AST dumping reaches a C++-only @@ -87,6 +87,12 @@ struct PrintingPolicy { UseVoidForZeroParams = false; } + /// Adjust this printing policy for rewriting BSC code to C doe. + void adjustForRewritingBSC() { + Bool = false; + RewriteBSC = true; + } + /// The number of spaces to use to indent each line. unsigned Indentation : 8; @@ -295,6 +301,9 @@ struct PrintingPolicy { /// enumerator name or via cast of an integer. unsigned UseEnumerators : 1; + /// Whether rewriting BSC source code to C source code. + unsigned RewriteBSC : 1; + /// Callbacks to use to allow the behavior of printing to be customized. const PrintingCallbacks *Callbacks = nullptr; }; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a110b014bbfae27b15ed727cd56737163c6ad0e5..ba3725122babe3e9044c7d6cc7f532bc54895746 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -3181,10 +3181,9 @@ public: ExprResult BuildAwaitExpr(SourceLocation AwaitLoc, Expr *E); ExprResult ActOnAwaitExpr(SourceLocation AwaitLoc, Expr *E); - // Entry - void ActOnAsyncFunctionDefinition(FunctionDecl *FD, - SmallVector DeclsInGroup); + /// Entry functions for desugaring async functions. SmallVector ActOnAsyncFunctionDeclaration(FunctionDecl *FD); + SmallVector ActOnAsyncFunctionDefinition(FunctionDecl *FD); /// We've found a use of a templated declaration that would trigger an /// implicit instantiation. Check that any relevant explicit specializations diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 9c13184cce568897d97947965eea4dab6e1b5e34..59663772ac9ed227574f1c52eb3d7a07b529a296 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -183,6 +183,31 @@ static QualType getDeclType(Decl* D) { return QualType(); } +// To prefix the type by jointing '_' between types and function name. +// Arg 'isFront' determines weather to prefix '_' at the front of type or not. +static std::string GetTypePrefix(QualType T, bool isFront, + const PrintingPolicy &PP) { + std::string ExtendedTypeStr; + llvm::raw_string_ostream OS(ExtendedTypeStr); + T.print(OS, PP); + for (int i = ExtendedTypeStr.length() - 1; i >= 0; i--) { + if (ExtendedTypeStr[i] == ' ') { + ExtendedTypeStr.replace(i, 1, "_"); + } else if (ExtendedTypeStr[i] == '*') { + // Since '*' is not allowed to appear in identifier, + // we replace it with 'P'. + // FIXME: it may conflict with user defined type Char_P. + ExtendedTypeStr.replace(i, 1, "P"); + } + } + if (isFront) { + ExtendedTypeStr = "_" + ExtendedTypeStr; + } else { + ExtendedTypeStr += "_"; + } + return ExtendedTypeStr; +} + void Decl::printGroup(Decl** Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation) { @@ -394,10 +419,14 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) { // Don't print implicit specializations, as they are printed when visiting // corresponding templates. - if (auto FD = dyn_cast(*D)) + if (auto FD = dyn_cast(*D)) { if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation && !isa(DC)) continue; + // Skip member functions for BSC. + if (Context.getLangOpts().BSC && isa(FD->getParent())) + continue; + } // The next bits of code handle stuff like "struct {int x;} a,b"; we're // forced to merge the declarations because there's no other way to @@ -591,23 +620,6 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out, Out << Proto; } -// To prefix the type by jointing '_' between types and function name. -// Arg 'isFront' determines weather to prefix '_' at the front of type or not. -static std::string GetTpyoPrefix(QualType T, bool isFront) { - std::string ExtendedTypeStr = T.getAsString(); - for (int i = ExtendedTypeStr.length() - 1; i >= 0; i--) { - if (ExtendedTypeStr[i] == ' ') { - ExtendedTypeStr.replace(i, 1, "_"); - } - } - if (isFront) { - ExtendedTypeStr = "_" + ExtendedTypeStr; - } else { - ExtendedTypeStr += "_"; - } - return ExtendedTypeStr; -} - void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (!D->getDescribedFunctionTemplate() && !D->isFunctionTemplateSpecialization()) @@ -662,19 +674,28 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { NS->print(OS, Policy); } } - // We don`t need print this in BSC generic. - if(!(Context.getLangOpts().BSC && D->isTemplateInstantiation())) { + if (!Policy.RewriteBSC) { D->getNameInfo().printName(OS, Policy); } else { - std::string FunctionNameStr = D->getDeclName().getAsString(); - if(const TemplateArgumentList *TArgs = - D->getTemplateSpecializationArgs()) { - for (size_t i = 0; i < TArgs->size(); i++) { - std::string QT = GetTpyoPrefix(TArgs->asArray()[i].getAsType(), /*isFront=*/true); - FunctionNameStr += QT; + if (const BSCMethodDecl *BMD = dyn_cast(D)) { + std::string FunctionNameStr = + GetTypePrefix(BMD->getExtendedType(), false, SubPolicy); + FunctionNameStr += D->getDeclName().getAsString(); + OS << FunctionNameStr; + } else if (D->isTemplateInstantiation()) { + std::string FunctionNameStr = D->getDeclName().getAsString(); + if (const TemplateArgumentList *TArgs = + D->getTemplateSpecializationArgs()) { + for (size_t i = 0; i < TArgs->size(); i++) { + std::string QT = GetTypePrefix(TArgs->asArray()[i].getAsType(), + /*isFront=*/true, SubPolicy); + FunctionNameStr += QT; + } } + OS << FunctionNameStr; + } else { + D->getNameInfo().printName(OS, Policy); } - OS << FunctionNameStr; } } @@ -924,51 +945,11 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) { } } - // FIXME: this looks very weird, too many if-else. - // rewrite BSC template struct instantial statement. - if (Context.getLangOpts().BSC) { - if (const auto *ET = dyn_cast(T)) { - QualType QT = ET->getNamedType(); - if (const auto *TST = dyn_cast(QT)) { - std::string InstantialName = D->getNameAsString(); - std::string RecordKind; - switch (QT->getAsRecordDecl()->getTagKind()) - { - case TTK_Struct: - RecordKind = "struct"; - break; - case TTK_Union: - RecordKind = "union"; - break; - case TTK_Enum: - RecordKind = "enum"; - break; - default: - break; - } - - std::string FunctionNameStr = - TST->getTemplateName().getAsTemplateDecl()->getDeclName().getAsString(); - - FunctionNameStr = RecordKind + " " + FunctionNameStr; + printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters && + D->getIdentifier()) + ? D->getIdentifier()->deuglifiedName() + : D->getName()); - for (size_t i = 0; i < TST->getNumArgs(); i++) { - std::string QT = GetTpyoPrefix(TST->getArg(i).getAsType(), /*isFront=*/true); - FunctionNameStr += QT; - } - Out << FunctionNameStr + " " + InstantialName; - } else { - printDeclType(T, D->getName()); - } - } else { - printDeclType(T, D->getName()); - } - } else { - printDeclType(T, (isa(D) && Policy.CleanUglifiedParameters && - D->getIdentifier()) - ? D->getIdentifier()->deuglifiedName() - : D->getName()); - } Expr *Init = D->getInit(); if (!Policy.SuppressInitializers && Init) { bool ImplicitInit = false; @@ -1075,10 +1056,11 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { if (auto S = dyn_cast(D)) { ArrayRef Args = S->getTemplateArgs().asArray(); - if (Context.getLangOpts().BSC) { + if (Policy.RewriteBSC) { std::string FunctionNameStr = S->getDeclName().getAsString(); for (size_t i = 0; i < Args.size(); i++) { - std::string QT = GetTpyoPrefix(Args[i].getAsType(), /*isFront=*/true); + std::string QT = + GetTypePrefix(Args[i].getAsType(), /*isFront=*/true, Policy); FunctionNameStr += QT; } Out << ' ' + FunctionNameStr; diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 7448ba31a992f1bdaebe38b86367d28b5bfe3c26..d3a691f9cc432db02e430f220614787a322b7dda 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1133,22 +1133,52 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) { PrintExpr(Node->getSubExpr()); } -static std::string GetPrefix(QualType T) { - std::string ExtendedTypeStr = T.getAsString(); +// To prefix the type by jointing '_' between types and function name. +// Arg 'isFront' determines weather to prefix '_' at the front of type or not. +static std::string GetTypePrefix(QualType T, bool isFront, + const PrintingPolicy &PP) { + std::string ExtendedTypeStr; + llvm::raw_string_ostream OS(ExtendedTypeStr); + T.print(OS, PP); for (int i = ExtendedTypeStr.length() - 1; i >= 0; i--) { if (ExtendedTypeStr[i] == ' ') { ExtendedTypeStr.replace(i, 1, "_"); + } else if (ExtendedTypeStr[i] == '*') { + // Since '*' is not allowed to appear in identifier, + // we replace it with 'P'. + // FIXME: it may conflict with user defined type Char_P. + ExtendedTypeStr.replace(i, 1, "P"); } } - ExtendedTypeStr += "_"; + if (isFront) { + ExtendedTypeStr = "_" + ExtendedTypeStr; + } else { + ExtendedTypeStr += "_"; + } return ExtendedTypeStr; } void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { - if (Node->HasBSCScopeSpec) { - if (auto *BD = dyn_cast(Node->getFoundDecl())) { - std::string ExtendedTypeStr = GetPrefix(BD->getExtendedType()); - OS << ExtendedTypeStr + Node->getNameInfo().getAsString(); + if (Policy.RewriteBSC) { + if (Node->HasBSCScopeSpec) { + if (auto *BD = dyn_cast(Node->getFoundDecl())) { + std::string ExtendedTypeStr = + GetTypePrefix(BD->getExtendedType(), false, Policy); + OS << ExtendedTypeStr + Node->getNameInfo().getAsString(); + return; + } + } + if (Node->getFoundDecl()->isTemplateDecl()) { + auto *FD = dyn_cast(Node->getDecl()); + std::string FunctionNameStr = FD->getDeclName().getAsString(); + for (unsigned i = 0; i < FD->getTemplateSpecializationArgs()->size(); + i++) { + std::string QT = GetTypePrefix( + FD->getTemplateSpecializationArgs()->asArray()[i].getAsType(), + /*isFront=*/true, Policy); + FunctionNameStr += QT; + } + OS << FunctionNameStr; return; } } @@ -1572,10 +1602,12 @@ static bool isImplicitThis(const Expr *E) { } void StmtPrinter::VisitMemberExpr(MemberExpr *Node) { - // const SourceManager &SM = Context->getSourceManager(); - if (auto *BD = dyn_cast(Node->getMemberDecl())) { - std::string ExtendedTypeStr = GetPrefix(BD->getExtendedType()); - OS << ExtendedTypeStr; + if (Policy.RewriteBSC) { + if (auto *BD = dyn_cast(Node->getMemberDecl())) { + std::string ExtendedTypeStr = + GetTypePrefix(BD->getExtendedType(), false, Policy); + OS << ExtendedTypeStr; + } } else if (!Policy.SuppressImplicitBase || !isImplicitThis(Node->getBase())) { PrintExpr(Node->getBase()); @@ -2054,7 +2086,13 @@ void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) { } void StmtPrinter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) { - OS << (Node->getValue() ? "true" : "false"); + if (Policy.RewriteBSC) { + OS << (Node->getValue() + ? "1" + : "0"); // FIXME: a little bit weird. why enter here. + } else { + OS << (Node->getValue() ? "true" : "false"); + } } void StmtPrinter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *Node) { diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index da9b09f6254019ead62f73aead794455c9a2a78f..d559bd6a584b84906ab9418dd9fa4b995f90912e 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -83,15 +83,23 @@ namespace { class DefaultTemplateArgsPolicyRAII { PrintingPolicy &Policy; bool Old; + bool SuppressTagKeyword; public: explicit DefaultTemplateArgsPolicyRAII(PrintingPolicy &Policy) - : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) { + : Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs), + SuppressTagKeyword(Policy.SuppressTagKeyword) { Policy.SuppressDefaultTemplateArgs = false; + if (Policy.RewriteBSC) { // FIXME: quite hack + Policy.SuppressTagKeyword = false; + } } ~DefaultTemplateArgsPolicyRAII() { Policy.SuppressDefaultTemplateArgs = Old; + if (Policy.RewriteBSC) { + Policy.SuppressTagKeyword = SuppressTagKeyword; + } } }; @@ -2093,8 +2101,13 @@ printTo(raw_ostream &OS, ArrayRef Args, const PrintingPolicy &Policy, } const char *Comma = Policy.MSVCFormatting ? "," : ", "; - if (!IsPack) - OS << '<'; + if (!IsPack) { + if (Policy.RewriteBSC) { + OS << '_'; + } else { + OS << '<'; + } + } bool NeedSpace = false; bool FirstArg = true; @@ -2109,8 +2122,12 @@ printTo(raw_ostream &OS, ArrayRef Args, const PrintingPolicy &Policy, printTo(ArgOS, Argument.getPackAsArray(), Policy, TPL, /*IsPack*/ true, ParmIndex); } else { - if (!FirstArg) - OS << Comma; + if (!FirstArg) { + if (!Policy.RewriteBSC) + OS << Comma; + else + OS << '_'; + } // Tries to print the argument with location info if exists. printArgument(Arg, Policy, ArgOS, TemplateParameterList::shouldIncludeTypeForArgument( @@ -2124,7 +2141,22 @@ printTo(raw_ostream &OS, ArrayRef Args, const PrintingPolicy &Policy, if (FirstArg && !ArgString.empty() && ArgString[0] == ':') OS << ' '; - OS << ArgString; + std::string NewArgString = ArgString.str(); + + if (Policy.RewriteBSC) { + for (int i = NewArgString.length() - 1; i >= 0; i--) { + if (NewArgString[i] == ' ') { + NewArgString.replace(i, 1, "_"); + } else if (NewArgString[i] == '*') { + // Since '*' is not allowed to appear in identifier, + // we replace it with 'P'. + // FIXME: it may conflict with user defined type Char_P. + NewArgString.replace(i, 1, "P"); + } + } + } + + OS << NewArgString; // If the last character of our string is '>', add another space to // keep the two '>''s separate tokens. @@ -2139,9 +2171,11 @@ printTo(raw_ostream &OS, ArrayRef Args, const PrintingPolicy &Policy, } if (!IsPack) { - if (NeedSpace) - OS << ' '; - OS << '>'; + if (!Policy.RewriteBSC) { + if (NeedSpace) + OS << ' '; + OS << '>'; + } } } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3453401bb946a7a6fb362a11a30ce16f56c85549..73b6cb7096f98b92645d5e6623f314863bb87db1 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6087,10 +6087,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { if (D->isTemplated()) return; - // Consteval function shouldn't be emitted. - if (auto *FD = dyn_cast(D)) + // Consteval and async function shouldn't be emitted. + if (auto *FD = dyn_cast(D)) { if (FD->isConsteval()) return; + if (FD->isAsyncSpecified()) + return; + } switch (D->getKind()) { case Decl::CXXConversion: diff --git a/clang/lib/Frontend/Rewrite/RewriteBSC.cpp b/clang/lib/Frontend/Rewrite/RewriteBSC.cpp index b9dd8697da0f32de83d9aa50c4fa9c3f13eb4cce..7a72c9f0fca4b496acbf916487cf772f6db48cd9 100644 --- a/clang/lib/Frontend/Rewrite/RewriteBSC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteBSC.cpp @@ -35,9 +35,13 @@ private: const char *MainFileStart, *MainFileEnd; std::string InFileName; std::unique_ptr OutFile; + clang::PrintingPolicy Policy; unsigned RewriteFailedDiag; + /// Save rewritten decls to aviod rewritting one decl twice. + std::vector RewrittenDecls; + public: RewriteBSC(std::string inFile, std::unique_ptr OS, DiagnosticsEngine &D, const LangOptions &LOpts); @@ -58,16 +62,15 @@ public: HandleTopLevelSingleDecl(D); } - void RewriteBSCMethodDecl(BSCMethodDecl *BMD); - void RewriteMemberExpr(MemberExpr *ME); - void RewriteCallExpr(CallExpr *CE); - void RewriteDeclRefExpr(DeclRefExpr *CE); - - void RewriteVarDecl(VarDecl *VD); - void RwriteBSCFunctionTemplateDecl(FunctionTemplateDecl *FTD); + void RewriteBSCMethodDecl(FunctionDecl *BMD); + void ReplaceDecl(Decl *D); + void InsertDecl(Decl *D); + void RemoveDecl(Decl *D); + void RewriteGenericFunction(FunctionDecl *FD); + void RewriteBSCFunctionTemplateDecl(FunctionTemplateDecl *FTD); void RewriteBSCInstantialFunctionDecl(FunctionDecl *FD); - void RwriteBSCClassTemplateDecl(ClassTemplateDecl *FTD); - void RwriteBSCInstantialClassDecl(ClassTemplateSpecializationDecl *FD); + void RewriteBSCClassTemplateDecl(ClassTemplateDecl *FTD); + void RewriteBSCInstantialClassDecl(ClassTemplateSpecializationDecl *FD); void InsertText(SourceLocation Loc, StringRef Str, bool InsertAfter = true) { // If insertion succeeded or warning disabled return with no warning. @@ -101,50 +104,16 @@ public: Diags.Report(Context->getFullLoc(Start), RewriteFailedDiag); } }; - -class RewriterVisitor : public StmtVisitor { -public: - RewriterVisitor(RewriteBSC *rewriter) : rewriter(rewriter) {} - RewriteBSC *rewriter; - - void VisitMemberExpr(MemberExpr *E) { - rewriter->RewriteMemberExpr(E); - VisitExpr(E); - } - - void VisitCallExpr(CallExpr *E) { - VisitExpr(E); - rewriter->RewriteCallExpr(E); - } - - void VisitDeclRefExpr(DeclRefExpr *DRE) { - VisitExpr(DRE); - rewriter->RewriteDeclRefExpr(DRE); - } - - void VisitDeclStmt(DeclStmt *DT) { - VisitStmt(DT); - for (auto *D : DT->decls()) { - if (VarDecl *VD = cast(D)) - rewriter->RewriteVarDecl(VD); - } - } - - void VisitStmt(Stmt *S) { - for (auto *C : S->children()) { - if (C) - Visit(C); - } - } -}; -} // end anonymous namespace +} // namespace RewriteBSC::RewriteBSC(std::string inFile, std::unique_ptr OS, DiagnosticsEngine &D, const LangOptions &LOpts) - : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)) { + : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(std::move(OS)), + Policy(LangOpts) { RewriteFailedDiag = Diags.getCustomDiagID( DiagnosticsEngine::Warning, "rewriting sub-expression within a macro (may not be correct)"); + Policy.adjustForRewritingBSC(); } std::unique_ptr @@ -185,42 +154,61 @@ void RewriteBSC::HandleTopLevelSingleDecl(Decl *D) { } void RewriteBSC::HandleDeclInMainFile(Decl *D) { + if (std::find(RewrittenDecls.begin(), RewrittenDecls.end(), D) != + RewrittenDecls.end()) { + return; + } switch (D->getKind()) { case Decl::BSCMethod: case Decl::Function: { - if (BSCMethodDecl *BSCMD = dyn_cast(D)) { - RewriteBSCMethodDecl(BSCMD); - } FunctionDecl *FD = cast(D); - if (!FD->isThisDeclarationADefinition()) + if (FD->getParent() && isa(FD->getParent())) { + if (cast(FD->getParent())->getDescribedClassTemplate()) { + // Remove origin generic BSC member function. + + RewriteGenericFunction(FD); + RewrittenDecls.push_back(FD); + break; + } + } + if (FD->isAsyncSpecified()) { + RewrittenDecls.push_back(FD); + ReplaceDecl(FD); break; - // Rewrite BSC instantial template function + } if (FD->isTemplateInstantiation()) { RewriteBSCInstantialFunctionDecl(FD); } else { - if (CompoundStmt *Body = dyn_cast_or_null(FD->getBody())) { - RewriterVisitor visitor(this); - visitor.VisitStmt(Body); - } + RewriteBSCMethodDecl(FD); } + RewrittenDecls.push_back(FD); + break; + } + case Decl::Record: + case Decl::Var: { + RewrittenDecls.push_back(D); + ReplaceDecl(D); break; } case Decl::FunctionTemplate: { FunctionTemplateDecl *FTD = cast(D); // Remove origin BSC template function. - RwriteBSCFunctionTemplateDecl(FTD); + RewrittenDecls.push_back(FTD); + RewriteBSCFunctionTemplateDecl(FTD); break; } case Decl::ClassTemplate: { ClassTemplateDecl *CTD = cast(D); // Remove origin BSC template struct. - RwriteBSCClassTemplateDecl(CTD); + RewrittenDecls.push_back(CTD); + RewriteBSCClassTemplateDecl(CTD); break; } case Decl::ClassTemplateSpecialization: { // Rewrite ClassTemplateSpecializationDecl ClassTemplateSpecializationDecl *CTSD = cast(D); - RwriteBSCInstantialClassDecl(CTSD); + RewrittenDecls.push_back(CTSD); + RewriteBSCInstantialClassDecl(CTSD); break; } default: @@ -242,139 +230,61 @@ void RewriteBSC::HandleTranslationUnit(ASTContext &C) { OutFile->flush(); } -// To prefix the type by jointing '_' between types and function name. -// Arg 'isFront' determines weather to prefix '_' at the front of type or not. -static std::string GetTpyoPrefix(QualType T, bool isFront) { - std::string ExtendedTypeStr = T.getAsString(); - for (int i = ExtendedTypeStr.length() - 1; i >= 0; i--) { - if (ExtendedTypeStr[i] == ' ') { - ExtendedTypeStr.replace(i, 1, "_"); - } - } - if (isFront) { - ExtendedTypeStr = "_" + ExtendedTypeStr; - } else { - ExtendedTypeStr += "_"; - } - return ExtendedTypeStr; -} - -void RewriteBSC::RewriteBSCMethodDecl(BSCMethodDecl *BMD) { - SourceLocation StartLoc = BMD->getExtentedTypeBeginLoc(); - - DeclarationNameInfo DNI = BMD->getNameInfo(); - SourceLocation EndLoc = DNI.getBeginLoc(); - - const char *startBuf = SM->getCharacterData(StartLoc); - const char *endBuf = SM->getCharacterData(EndLoc); +void RewriteBSC::RewriteBSCMethodDecl(FunctionDecl *BMD) { + SourceRange range = BMD->getSourceRange(); + RemoveText(BMD->getBeginLoc(), range); + // Rename the BSC instantial function template decl, and insert it + // at the end of the origin function template decl. + SourceLocation StartLoc = BMD->getBeginLoc(); - std::string ExtendedTypeStr = GetTpyoPrefix(BMD->getExtendedType(), - /*isFront=*/false); - ReplaceText(StartLoc, endBuf - startBuf, ExtendedTypeStr); + std::string SStr; + llvm::raw_string_ostream Buf(SStr); + BMD->print(Buf, Policy, /*PrintInstantiation=*/true); + const std::string &Str = Buf.str(); + InsertText(StartLoc, Str); } -void RewriteBSC::RewriteCallExpr(CallExpr *CE) { - Expr *Callee = CE->getCallee(); - if (ImplicitCastExpr *ICE = dyn_cast(Callee)) { - Expr *SE = ICE->getSubExpr(); - if (MemberExpr *Member = dyn_cast(SE)) { - if (dyn_cast(Member->getMemberDecl())) { - std::string SStr; - llvm::raw_string_ostream Buf(SStr); - CE->getArg(0)->printPretty(Buf, nullptr, PrintingPolicy(LangOpts)); - const std::string &Str = Buf.str(); - SourceLocation StartLoc; - if (CE->getNumArgs() == 1) { - StartLoc = CE->getRParenLoc(); - InsertText(StartLoc, Str); - } else { - StartLoc = CE->getArg(1)->getBeginLoc(); - InsertText(StartLoc, Str + ", "); - } - } - } - if (DeclRefExpr *DeclRef = dyn_cast(SE)) { - if (DeclRef->getFoundDecl()->isTemplateDecl()) { - // 1.get repalce name - auto *FD = dyn_cast(DeclRef->getDecl()); - std::string FunctionNameStr = FD->getDeclName().getAsString(); - for (unsigned i = 0; i < FD->getTemplateSpecializationArgs()->size(); i++) { - std::string QT = GetTpyoPrefix(FD->getTemplateSpecializationArgs() - ->asArray()[i].getAsType(), - /*isFront=*/true); - FunctionNameStr += QT; - } - // 2.get locations to replace - unsigned TemplateArgNum = DeclRef->getNumTemplateArgs(); - SourceLocation LocStart = CE->getBeginLoc(); - SourceLocation LocEnd; - // If template args '(T a)' is not zero, then use getBeginLoc() and - // shift to left for 1, so that we can get '>' location. If template - // arg '()' is zero, then getBeginLoc() API is invalid, we can only - // find the location of ')', then shift to the left - // for 2 to get '<'. - if (TemplateArgNum != 0) { - LocEnd = CE->getArg(0)->getBeginLoc().getLocWithOffset(-1); - } else { - LocEnd = CE->getRParenLoc().getLocWithOffset(-2); - } - // 3.replace the func name - const char *startBuf = SM->getCharacterData(LocStart); - const char *endBuf = SM->getCharacterData(LocEnd); - ReplaceText(LocStart, endBuf - startBuf, FunctionNameStr); +void RewriteBSC::ReplaceDecl(Decl *D) { + SourceRange range = D->getSourceRange(); + std::string SStr; + llvm::raw_string_ostream Buf(SStr); + if (Context->BSCDesugaredMap.find(D) != Context->BSCDesugaredMap.end()) { + for (auto &DesugaredDecl : Context->BSCDesugaredMap[D]) { + DesugaredDecl->print(Buf, Policy, /*PrintInstantiation=*/true); + if (!isa(DesugaredDecl)) { + Buf << ";\n"; } + Buf << "\n"; + RewrittenDecls.push_back(DesugaredDecl); } + } else { + D->print(Buf, Policy, /*PrintInstantiation=*/true); } + const std::string &Str = Buf.str(); + ReplaceText(D->getBeginLoc(), range, Str); } -void RewriteBSC::RewriteMemberExpr(MemberExpr *ME) { - if (auto *BD = dyn_cast(ME->getMemberDecl())) { - SourceLocation LocStart = ME->getBeginLoc(); - SourceLocation MemberStart = ME->getMemberLoc(); - const char *startBuf = SM->getCharacterData(LocStart); - const char *endBuf = SM->getCharacterData(MemberStart); - std::string ExtendedTypeStr = GetTpyoPrefix(BD->getExtendedType(), - /*isFront=*/false); - ReplaceText(LocStart, endBuf - startBuf, ExtendedTypeStr); - } +void RewriteBSC::InsertDecl(Decl *D) { + std::string SStr; + llvm::raw_string_ostream Buf(SStr); + D->print(Buf, Policy, /*PrintInstantiation=*/true); + const std::string &Str = Buf.str(); + InsertText(D->getBeginLoc(), Str + ";\n"); } -void RewriteBSC::RewriteDeclRefExpr(DeclRefExpr *DRE) { - if (DRE->HasBSCScopeSpec) { - if (auto *BD = dyn_cast(DRE->getFoundDecl())) { - SourceLocation LocStart = DRE->getExtendedTypeBeginLoc(); - SourceLocation LocEnd = DRE->getBeginLoc(); - const char *startBuf = SM->getCharacterData(LocStart); - const char *endBuf = SM->getCharacterData(LocEnd); - std::string ExtendedTypeStr = GetTpyoPrefix(BD->getExtendedType(), - /*isFront=*/false); - ReplaceText(LocStart, endBuf - startBuf, ExtendedTypeStr); - } - } +void RewriteBSC::RemoveDecl(Decl *D) { + SourceRange range = D->getSourceRange(); + range.setEnd(range.getEnd().getLocWithOffset(1)); + RemoveText(D->getBeginLoc(), range); } -void RewriteBSC::RewriteVarDecl(VarDecl *VD) { - QualType T = VD->getTypeSourceInfo() - ? VD->getTypeSourceInfo()->getType() - : VD->getASTContext().getUnqualifiedObjCPointerType(VD->getType()); - - // rewrite BSC template struct instantial statement. - if (const auto *ET = dyn_cast(T)) { - QualType QT = ET->getNamedType(); - if (dyn_cast(QT)) { - std::string SStr; - llvm::raw_string_ostream Buf(SStr); - VD->print(Buf, PrintingPolicy(LangOpts), /*PrintInstantiation=*/true); - const std::string &Str = Buf.str(); - - SourceLocation StartLoc = VD->getBeginLoc(); - SourceRange VDRange = VD->getSourceRange(); - ReplaceText(StartLoc, VDRange, Str); - } - } +void RewriteBSC::RewriteGenericFunction(FunctionDecl *FD) { + // Remove the BSC template function source code; + SourceRange range = FD->getSourceRange(); + RemoveText(FD->getBeginLoc(), range); } -void RewriteBSC::RwriteBSCFunctionTemplateDecl(FunctionTemplateDecl *FTD) { +void RewriteBSC::RewriteBSCFunctionTemplateDecl(FunctionTemplateDecl *FTD) { // Remove the BSC template function source code; SourceRange range = FTD->getSourceRange(); RemoveText(FTD->getBeginLoc(), range); @@ -383,18 +293,18 @@ void RewriteBSC::RwriteBSCFunctionTemplateDecl(FunctionTemplateDecl *FTD) { void RewriteBSC::RewriteBSCInstantialFunctionDecl(FunctionDecl *FD) { // Rename the BSC instantial function template decl, and insert it // at the end of the origin function template decl. - SourceLocation EndLoc = FD->getEndLoc(); + SourceLocation EndLoc = FD->getBeginLoc(); std::string SStr; llvm::raw_string_ostream Buf(SStr); - FD->print(Buf, PrintingPolicy(LangOpts), /*PrintInstantiation=*/true); + FD->print(Buf, Policy, /*PrintInstantiation=*/true); const std::string &Str = Buf.str(); // Insert instantial function decl at the end of origin template function // shift 2, in case the origin template function is at the beginning of // source code. - InsertText(EndLoc.getLocWithOffset(2), Str + "\n"); + InsertText(EndLoc, Str + "\n"); } -void RewriteBSC::RwriteBSCClassTemplateDecl(ClassTemplateDecl *CTD){ +void RewriteBSC::RewriteBSCClassTemplateDecl(ClassTemplateDecl *CTD) { // Remove the BSC template struct source code; SourceRange range = CTD->getSourceRange(); // somehow, the range doesn`t include the end semi ';' of the @@ -403,13 +313,14 @@ void RewriteBSC::RwriteBSCClassTemplateDecl(ClassTemplateDecl *CTD){ RemoveText(CTD->getBeginLoc(), range); } -void RewriteBSC::RwriteBSCInstantialClassDecl(ClassTemplateSpecializationDecl *CTSD) { +void RewriteBSC::RewriteBSCInstantialClassDecl( + ClassTemplateSpecializationDecl *CTSD) { // Rename the BSC instantial struct template decl, and insert it // at the end of the origin struct template decl. SourceLocation EndLoc = CTSD->getEndLoc(); std::string SStr; llvm::raw_string_ostream Buf(SStr); - CTSD->print(Buf, PrintingPolicy(LangOpts), /*PrintInstantiation=*/true); + CTSD->print(Buf, Policy, /*PrintInstantiation=*/true); const std::string &Str = Buf.str(); // Insert instantial struct decl at the end of origin template struct // shift 2, in case the origin template struct is at the beginning of diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index e26e6f247f6eef7b29ac1cc8e578d91b05ddcaa9..bb2dfa61f5fff2a546cd3c2a2583997378fc334d 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2129,9 +2129,9 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, FunctionDecl *FD = dyn_cast_or_null(TheDecl); if (getLangOpts().BSC && FD) { - SmallVector decls = - Actions.ActOnAsyncFunctionDeclaration(FD); - return Actions.BuildDeclaratorGroup(decls); + SmallVector Decls = + Actions.ActOnAsyncFunctionDefinition(FD); + return Actions.BuildDeclaratorGroup(Decls); } return Actions.ConvertDeclToDeclGroup(TheDecl); } @@ -2205,7 +2205,10 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, if (FirstDecl) { FunctionDecl *FD = dyn_cast_or_null(FirstDecl); if (getLangOpts().BSC && FD && FD->isAsyncSpecified()) { - Actions.ActOnAsyncFunctionDefinition(FD, DeclsInGroup); + SmallVector Decls = Actions.ActOnAsyncFunctionDeclaration(FD); + for (auto &D : Decls) { + DeclsInGroup.push_back(D); + } } } diff --git a/clang/lib/Sema/SemaBSCCoroutine.cpp b/clang/lib/Sema/SemaBSCCoroutine.cpp index 15e921322a56ef265aa9037856ec07831d68132e..97f073473f90afd0f4f7f49a09cb91fd7f0e91b0 100644 --- a/clang/lib/Sema/SemaBSCCoroutine.cpp +++ b/clang/lib/Sema/SemaBSCCoroutine.cpp @@ -68,20 +68,18 @@ static FunctionDecl *buildAsyncFuncDecl(ASTContext &C, DeclContext *DC, return NewDecl; } -static BSCMethodDecl *buildAsyncBSCMethodDecl(ASTContext &C, DeclContext *DC, - SourceLocation StartLoc, - SourceLocation NLoc, - DeclarationName N, QualType T, - TypeSourceInfo *TInfo, - StorageClass SC) { +static BSCMethodDecl * +buildAsyncBSCMethodDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, + SourceLocation NLoc, DeclarationName N, QualType T, + TypeSourceInfo *TInfo, StorageClass SC, QualType ET) { BSCMethodDecl *NewDecl = BSCMethodDecl::Create( // TODO: inline should be passed. C, DC, StartLoc, DeclarationNameInfo(N, NLoc), T, TInfo, SC, false, false, ConstexprSpecKind::Unspecified, NLoc); if (auto RD = dyn_cast_or_null(DC)) { C.BSCDeclContextMap[RD->getTypeForDecl()] = DC; - NewDecl->setHasThisParam(true); - NewDecl->setExtendedType(RD->getTypeForDecl()->getCanonicalTypeInternal()); + NewDecl->setHasThisParam(true); // bug + NewDecl->setExtendedType(ET); } return NewDecl; } @@ -457,7 +455,8 @@ static RecordDecl *buildFutureRecordDecl( return RD; } -static RecordDecl *generateVoidStruct(Sema &S) { +static RecordDecl *generateVoidStruct(Sema &S, SourceLocation BLoc, + SourceLocation ELoc) { std::string Recordname = "Void"; DeclContext::lookup_result Decls = S.Context.getTranslationUnitDecl()->lookup( DeclarationName(&(S.Context.Idents).get(Recordname))); @@ -473,8 +472,7 @@ static RecordDecl *generateVoidStruct(Sema &S) { } } } else if (Decls.empty()) { - VoidRD = buildAsyncDataRecord(S.Context, Recordname, SourceLocation(), - SourceLocation(), + VoidRD = buildAsyncDataRecord(S.Context, Recordname, BLoc, ELoc, clang::TagDecl::TagKind::TTK_Struct); VoidRD->startDefinition(); VoidRD->completeDefinition(); @@ -485,8 +483,8 @@ static RecordDecl *generateVoidStruct(Sema &S) { /// TODO: will be removed after using Future in stdlib static std::tuple, std::pair> -generateVtableAndFatPointerStruct(Sema &S, QualType T, - RecordDecl *PollResultRD) { +generateVtableAndFatPointerStruct(Sema &S, QualType T, RecordDecl *PollResultRD, + FunctionDecl *FD) { RecordDecl *VtableStruct = nullptr; QualType ReturnTy = T; std::string VtableStructName = "__Vtable_" + GetPrefix(ReturnTy); @@ -507,7 +505,7 @@ generateVtableAndFatPointerStruct(Sema &S, QualType T, VtableStruct->addAttr(WeakAttr::CreateImplicit(S.Context)); } else if (Decls.empty()) { VtableStruct = buildAsyncDataRecord(S.Context, VtableStructName, - SourceLocation(), SourceLocation(), + FD->getBeginLoc(), FD->getEndLoc(), clang::TagDecl::TagKind::TTK_Struct); VtableStruct->startDefinition(); SmallVector Args; @@ -544,7 +542,7 @@ generateVtableAndFatPointerStruct(Sema &S, QualType T, FatPointerStruct->addAttr(WeakAttr::CreateImplicit(S.Context)); } else if (FatPointerDecls.empty()) { FatPointerStruct = buildAsyncDataRecord( - S.Context, FatPointerName, SourceLocation(), SourceLocation(), + S.Context, FatPointerName, FD->getBeginLoc(), FD->getEndLoc(), clang::TagDecl::TagKind::TTK_Struct); FatPointerStruct->startDefinition(); addAsyncRecordDecl(S.Context, "data", S.Context.VoidPtrTy, SourceLocation(), @@ -569,8 +567,8 @@ static VarDecl *buildVtableInitDecl(Sema &S, FunctionDecl *FD, std::string IName = VtableRD->getDeclName().getAsString() + FD->getDeclName().getAsString(); VarDecl *VD = VarDecl::Create( - S.Context, S.Context.getTranslationUnitDecl(), SourceLocation(), - SourceLocation(), &(S.Context.Idents).get(IName), + S.Context, S.Context.getTranslationUnitDecl(), FD->getBeginLoc(), + FD->getEndLoc(), &(S.Context.Idents).get(IName), S.Context.getRecordType(VtableRD), nullptr, SC_None); DeclGroupRef DG(VD); S.PushOnScopeChains(VD, S.getCurScope(), false); @@ -583,6 +581,7 @@ static VarDecl *buildVtableInitDecl(Sema &S, FunctionDecl *FD, S.Context.getRecordType(PollResultRD), Args, {})); Expr *PollInit = S.BuildDeclRefExpr(PollFunc, PollFunc->getType(), VK_LValue, SourceLocation()); + PollInit->HasBSCScopeSpec = true; PollInit = S.ImpCastExprToType(PollInit, S.Context.getPointerType(PollInit->getType()), CK_FunctionToPointerDecay) @@ -594,6 +593,7 @@ static VarDecl *buildVtableInitDecl(Sema &S, FunctionDecl *FD, S.Context.getFunctionType(S.Context.VoidTy, Args, {})); Expr *FreeInit = S.BuildDeclRefExpr(FreeFunc, FreeFunc->getType(), VK_LValue, SourceLocation()); + FreeInit->HasBSCScopeSpec = true; FreeInit = S.ImpCastExprToType(FreeInit, S.Context.getPointerType(FreeInit->getType()), CK_FunctionToPointerDecay) @@ -608,58 +608,21 @@ static VarDecl *buildVtableInitDecl(Sema &S, FunctionDecl *FD, return VD; } -FunctionDecl *buildFutureInitFunctionDeclaraion(Sema &S, RecordDecl *RD, +FunctionDecl *buildFutureInitFunctionDefinition(Sema &S, RecordDecl *RD, FunctionDecl *FD, RecordDecl *FatPointerRD, - VarDecl *VtableInit) { + VarDecl *VtableInit, + FunctionDecl *NewFD) { SourceLocation SLoc = FD->getBeginLoc(); SourceLocation NLoc = FD->getNameInfo().getLoc(); DeclarationName funcName = FD->getDeclName(); - QualType FuncRetType = S.Context.getRecordType(FatPointerRD); SmallVector ParamTys; FunctionDecl::param_const_iterator pi; for (pi = FD->param_begin(); pi != FD->param_end(); pi++) { ParamTys.push_back((*pi)->getType()); } - QualType FuncType = S.Context.getFunctionType(FuncRetType, ParamTys, {}); - TypeSourceInfo *Tinfo = FD->getTypeSourceInfo(); std::string FName = "__" + funcName.getAsString(); - DeclContext::lookup_result Decls = FD->getDeclContext()->lookup( - DeclarationName(&(S.Context.Idents).get(FName))); - FunctionDecl *NewFD = nullptr; - if (Decls.isSingleResult()) { - for (DeclContext::lookup_result::iterator I = Decls.begin(), - E = Decls.end(); - I != E; ++I) { - if (isa(*I)) { - NewFD = dyn_cast(*I); - break; - } - } - } else if (Decls.empty()) { - if (dyn_cast(FD)) { - NewFD = buildAsyncBSCMethodDecl(S.Context, FD->getDeclContext(), SLoc, - NLoc, &(S.Context.Idents).get(FName), - FuncType, Tinfo, SC_None); - } else { - NewFD = - buildAsyncFuncDecl(S.Context, FD->getDeclContext(), SLoc, NLoc, - &(S.Context.Idents).get(FName), FuncType, Tinfo); - } - SmallVector ParmVarDecls; - for (const auto &I : FD->parameters()) { - ParmVarDecl *PVD = ParmVarDecl::Create( - S.Context, NewFD, SourceLocation(), SourceLocation(), - &(S.Context.Idents).get(I->getName()), I->getType(), nullptr, SC_None, - nullptr); - ParmVarDecls.push_back(PVD); - } - NewFD->setParams(ParmVarDecls); - NewFD->setLexicalDeclContext(S.Context.getTranslationUnitDecl()); - S.PushOnScopeChains(NewFD, S.getCurScope(), true); - } - S.PushFunctionScope(); S.PushDeclContext(S.getCurScope(), NewFD); @@ -825,8 +788,8 @@ FunctionDecl *buildFutureInitFunctionDeclaraion(Sema &S, RecordDecl *RD, return NewFD; } -FunctionDecl *buildFutureInitFunctionDefinition(Sema &S, FunctionDecl *FD, - RecordDecl *FatPointerRD) { +FunctionDecl *buildFutureInitFunctionDeclaration(Sema &S, FunctionDecl *FD, + RecordDecl *FatPointerRD) { SourceLocation SLoc = FD->getBeginLoc(); SourceLocation NLoc = FD->getNameInfo().getLoc(); DeclarationName funcName = FD->getDeclName(); @@ -840,25 +803,12 @@ FunctionDecl *buildFutureInitFunctionDefinition(Sema &S, FunctionDecl *FD, TypeSourceInfo *Tinfo = FD->getTypeSourceInfo(); std::string FName = "__" + funcName.getAsString(); - DeclContext::lookup_result Decls = FD->getDeclContext()->lookup( - DeclarationName(&(S.Context.Idents).get(FName))); - - if (Decls.isSingleResult()) { - for (DeclContext::lookup_result::iterator I = Decls.begin(), - E = Decls.end(); - I != E; ++I) { - if (isa(*I)) { - return dyn_cast(*I); - break; - } - } - } - - FunctionDecl *NewFD; - if (dyn_cast(FD)) { + FunctionDecl *NewFD = nullptr; + if (isa(FD)) { + BSCMethodDecl *BMD = cast(FD); NewFD = buildAsyncBSCMethodDecl(S.Context, FD->getDeclContext(), SLoc, NLoc, &(S.Context.Idents).get(FName), FuncType, - Tinfo, SC_None); + Tinfo, SC_None, BMD->getExtendedType()); } else { NewFD = buildAsyncFuncDecl(S.Context, FD->getDeclContext(), SLoc, NLoc, &(S.Context.Idents).get(FName), FuncType, Tinfo); @@ -929,6 +879,7 @@ Stmt *ProcessAwaitExprStatus(Sema &S, int AwaitCount, RecordDecl *RD, Expr *ICE, if (IsCompletedFD) { Expr *IsCompletedFDRef = S.BuildDeclRefExpr( IsCompletedFD, IsCompletedFD->getType(), VK_LValue, SourceLocation()); + IsCompletedFDRef->HasBSCScopeSpec = true; IsCompletedFDRef = S.ImpCastExprToType( IsCompletedFDRef, @@ -973,6 +924,7 @@ Stmt *ProcessAwaitExprStatus(Sema &S, int AwaitCount, RecordDecl *RD, Expr *ICE, if (PendingFD) { Expr *PendingFDRef = S.BuildDeclRefExpr(PendingFD, PendingFD->getType(), VK_LValue, SourceLocation()); + PendingFDRef->HasBSCScopeSpec = true; PendingFDRef = S.ImpCastExprToType(PendingFDRef, S.Context.getPointerType(PendingFDRef->getType()), @@ -1009,7 +961,8 @@ class TransformToReturnVoid : public TreeTransform { // make sure redo semantic analysis bool AlwaysRebuild() { return true; } - Decl *TransformFunctionDecl(FunctionDecl *D) { + FunctionDecl *TransformFunctionDecl(FunctionDecl *D) { + FunctionDecl *NewFD = D; if (D->getReturnType()->isVoidType()) { std::string ReturnStructName = "Void"; DeclContext::lookup_result ReturnDecls = @@ -1036,7 +989,33 @@ class TransformToReturnVoid : public TreeTransform { } QualType FuncType = SemaRef.Context.getFunctionType(ReturnTy, ParamTys, {}); - D->setType(FuncType); + + SourceLocation SLoc = D->getBeginLoc(); + SourceLocation NLoc = D->getNameInfo().getLoc(); + TypeSourceInfo *Tinfo = D->getTypeSourceInfo(); + std::string FName = std::string(D->getIdentifier()->getName()); + + if (isa(D)) { + BSCMethodDecl *BMD = cast(D); + NewFD = buildAsyncBSCMethodDecl( + SemaRef.Context, D->getDeclContext(), SLoc, NLoc, + &(SemaRef.Context.Idents).get(FName), FuncType, Tinfo, SC_None, + BMD->getExtendedType()); + } else { + NewFD = buildAsyncFuncDecl(SemaRef.Context, D->getDeclContext(), SLoc, + NLoc, &(SemaRef.Context.Idents).get(FName), + FuncType, Tinfo); + } + SmallVector ParmVarDecls; + for (const auto &I : D->parameters()) { + ParmVarDecl *PVD = ParmVarDecl::Create( + SemaRef.Context, NewFD, SourceLocation(), SourceLocation(), + &(SemaRef.Context.Idents).get(I->getName()), I->getType(), nullptr, + SC_None, nullptr); + ParmVarDecls.push_back(PVD); + } + NewFD->setParams(ParmVarDecls); + NewFD->setLexicalDeclContext(SemaRef.Context.getTranslationUnitDecl()); CompoundStmt *body = dyn_cast(D->getBody()); Stmt *LastStmt = body->body_back(); @@ -1049,16 +1028,15 @@ class TransformToReturnVoid : public TreeTransform { nullptr, nullptr); Stmts.push_back(RS); Sema::CompoundScopeRAII CompoundScope(SemaRef); - CompoundStmt *CS = BaseTransform::RebuildCompoundStmt( - SourceLocation(), Stmts, SourceLocation(), false) - .getAs(); - D->setBody(CS); + body = BaseTransform::RebuildCompoundStmt(SourceLocation(), Stmts, + SourceLocation(), false) + .getAs(); } - Stmt *FuncBody = BaseTransform::TransformStmt(D->getBody()).getAs(); - D->setBody(FuncBody); + Stmt *FuncBody = BaseTransform::TransformStmt(body).getAs(); + NewFD->setBody(FuncBody); } - return D; + return NewFD; } StmtResult TransformReturnStmt(ReturnStmt *S) { @@ -1194,7 +1172,7 @@ class TransformToAP : public TreeTransform { } } - SemaRef.AddInitializerToDecl(ArgVDNew, CInit, /*DirectInit=*/true); + SemaRef.AddInitializerToDecl(ArgVDNew, CInit, /*DirectInit=*/false); DeclStmt *DSNew = SemaRef .ActOnDeclStmt(SemaRef.ConvertDeclToDeclGroup(ArgVDNew), @@ -1240,7 +1218,7 @@ class TransformToAP : public TreeTransform { .get(); std::string AssignedPtrName = - "__ASSIGNED_ARRAY_PTR_" + SubQT.getAsString(); + "__ASSIGNED_ARRAY_PTR_" + GetPrefix(SubQT); VarDecl *AssignedPtrVar = GetArrayAssignedPointerMap(StringRef(AssignedPtrName)); if (AssignedPtrVar == nullptr) { @@ -1250,7 +1228,7 @@ class TransformToAP : public TreeTransform { Pty.getNonReferenceType(), nullptr, SC_None); SemaRef.AddInitializerToDecl(AssignedPtrVar, AssignedCCE, - /*DirectInit=*/true); + /*DirectInit=*/false); DeclStmt *AssignedDS = SemaRef @@ -1288,7 +1266,7 @@ class TransformToAP : public TreeTransform { SourceLocation(), ArrayType, SourceLocation(), ArrayRVExpr) .get(); - std::string ArrayPtrName = "__ARRAY_PTR_" + SubQT.getAsString(); + std::string ArrayPtrName = "__ARRAY_PTR_" + GetPrefix(SubQT); VarDecl *ArrayPtrVar = GetArrayPointersMap(StringRef(ArrayPtrName)); if (ArrayPtrVar == nullptr) { ArrayPtrVar = VarDecl::Create( @@ -1297,7 +1275,7 @@ class TransformToAP : public TreeTransform { Pty.getNonReferenceType(), nullptr, SC_None); SemaRef.AddInitializerToDecl(ArrayPtrVar, ArrayCCE, - /*DirectInit=*/true); + /*DirectInit=*/false); DeclStmt *ArrayDS = SemaRef .ActOnDeclStmt( @@ -1765,6 +1743,7 @@ class ARFinder : public StmtVisitor { Expr *CompletedRef = SemaRef.BuildDeclRefExpr( CompletedFD, CompletedFD->getType(), VK_LValue, SourceLocation()); + CompletedRef->HasBSCScopeSpec = true; CompletedRef = SemaRef .ImpCastExprToType( @@ -1932,12 +1911,13 @@ class AEFinder : public StmtVisitor { Expr *FDRef = SemaRef.BuildDeclRefExpr(CFD, CFD->getType().getNonReferenceType(), VK_LValue, CFD->getLocation()); + FDRef->HasBSCScopeSpec = true; FDRef = SemaRef .ImpCastExprToType( FDRef, SemaRef.Context.getPointerType(CFD->getType()), CK_FunctionToPointerDecay) .get(); - + FDRef->HasBSCScopeSpec = true; RHSExpr = SemaRef .BuildCallExpr(nullptr, FDRef, SourceLocation(), CallArgs, SourceLocation()) @@ -2125,7 +2105,7 @@ class TransformAEToCS : public TreeTransform { bool HasAwait = HasAwaitExpr(Init); if (HasAwait && Init != nullptr) { Init = BaseTransform::TransformExpr(Init).get(); - SemaRef.AddInitializerToDecl(VD, Init, /*DirectInit=*/true); + SemaRef.AddInitializerToDecl(VD, Init, /*DirectInit=*/false); } } Decls.push_back(D); @@ -2158,13 +2138,16 @@ class TransformAEToCS : public TreeTransform { for (int j = index; j < index + UnitNum - 1; j++) { if (j == index + 1) { + Stmt::EmptyShell Empty; + Stmt *Null = new (SemaRef.Context) NullStmt(Empty); LabelStmt *LS = BaseTransform::RebuildLabelStmt( SourceLocation(), cast(LabelDecls[AwaitIndex + i + 1]), - SourceLocation(), AwaitStmts[j]) + SourceLocation(), Null) .getAs(); Statements.push_back(LS); + Statements.push_back(AwaitStmts[j]); continue; } @@ -2227,9 +2210,9 @@ static BSCMethodDecl *buildFreeFunction(Sema &S, RecordDecl *RD, QualType FuncType = S.Context.getFunctionType(FuncRetType, ParamTys, {}); - BSCMethodDecl *NewFD = buildAsyncBSCMethodDecl(S.Context, RD, SLoc, NLoc, - &(S.Context.Idents).get(FName), - FuncType, nullptr, SC_None); + BSCMethodDecl *NewFD = buildAsyncBSCMethodDecl( + S.Context, RD, SLoc, NLoc, &(S.Context.Idents).get(FName), FuncType, + nullptr, SC_None, RD->getTypeForDecl()->getCanonicalTypeInternal()); NewFD->setLexicalDeclContext(S.Context.getTranslationUnitDecl()); S.Context.BSCDeclContextMap[RD->getTypeForDecl()] = RD; @@ -2406,9 +2389,9 @@ static BSCMethodDecl *buildPollFunction(Sema &S, RecordDecl *RD, QualType FuncType = S.Context.getFunctionType(FuncRetType, ParamTys, {}); QualType OriginType = S.Context.getFunctionType(Ty, ParamTys, {}); - BSCMethodDecl *NewFD = buildAsyncBSCMethodDecl(S.Context, RD, SLoc, NLoc, - &(S.Context.Idents).get(FName), - OriginType, nullptr, SC_None); + BSCMethodDecl *NewFD = buildAsyncBSCMethodDecl( + S.Context, RD, SLoc, NLoc, &(S.Context.Idents).get(FName), OriginType, + nullptr, SC_None, RD->getTypeForDecl()->getCanonicalTypeInternal()); NewFD->setLexicalDeclContext(S.Context.getTranslationUnitDecl()); S.Context.BSCDeclContextMap[RD->getTypeForDecl()] = RD; S.PushFunctionScope(); @@ -2482,13 +2465,15 @@ static BSCMethodDecl *buildPollFunction(Sema &S, RecordDecl *RD, int StmtSize = Stmts.size(); - TransformToReturnVoid(S).TransformFunctionDecl(FD); + FunctionDecl *TransformedFD = + TransformToReturnVoid(S).TransformFunctionDecl(FD); - NewFD->setType(S.Context.getFunctionType(FD->getReturnType(), ParamTys, {})); + NewFD->setType( + S.Context.getFunctionType(TransformedFD->getReturnType(), ParamTys, {})); S.PushDeclContext(S.getCurScope(), NewFD); TransformToAP DT = TransformToAP(S, FutureObj, RD, NewFD); - StmtResult MemberChangeRes = DT.TransformStmt(FD->getBody()); + StmtResult MemberChangeRes = DT.TransformStmt(TransformedFD->getBody()); Stmt *FuncBody = MemberChangeRes.get(); StmtResult SingleStateRes = @@ -2514,20 +2499,16 @@ static BSCMethodDecl *buildPollFunction(Sema &S, RecordDecl *RD, for (auto *C : AEToCSRes.get()->children()) { Stmts.push_back(C); } - + Stmt::EmptyShell Empty; + Stmt *Null = new (S.Context) NullStmt(Empty); int CurStmtSize = Stmts.size(); if (CurStmtSize > StmtSize) { - Stmt *FirstStmt = Stmts[StmtSize]; LabelStmt *LS = - new (S.Context) LabelStmt(SourceLocation(), LabelDecls[0], FirstStmt); - Stmts.erase(Stmts.begin() + StmtSize); + new (S.Context) LabelStmt(SourceLocation(), LabelDecls[0], Null); Stmts.insert(Stmts.begin() + StmtSize, LS); } else { - llvm::APInt ResultVal(S.Context.getTargetInfo().getIntWidth(), 0); - Stmt *IL = IntegerLiteral::Create(S.Context, ResultVal, S.Context.IntTy, - SourceLocation()); LabelStmt *LS = - new (S.Context) LabelStmt(SourceLocation(), LabelDecls[0], IL); + new (S.Context) LabelStmt(SourceLocation(), LabelDecls[0], Null); Stmts.push_back(LS); } @@ -2621,38 +2602,49 @@ ExprResult Sema::ActOnAwaitExpr(SourceLocation AwaitLoc, Expr *E) { return BuildAwaitExpr(AwaitLoc, E); } -void Sema::ActOnAsyncFunctionDefinition(FunctionDecl *FD, - SmallVector DeclsInGroup) { +SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { + SmallVector decls; if (!IsFutureType(FD->getReturnType())) { QualType ReturnTy = FD->getReturnType(); ReturnTy.removeLocalConst(); if (ReturnTy->isVoidType()) { - RecordDecl *VoidRD = generateVoidStruct(*this); + RecordDecl *VoidRD = + generateVoidStruct(*this, FD->getBeginLoc(), FD->getEndLoc()); + decls.push_back(VoidRD); + Context.BSCDesugaredMap[FD].push_back(VoidRD); ReturnTy = Context.getRecordType(VoidRD); } QualType PollResultType = lookupPollResultType(*this, FD->getBeginLoc(), ReturnTy); if (PollResultType.isNull()) { - return; + return decls; } RecordDecl *PollResultRD = PollResultType->getAsRecordDecl(); std::tuple, std::pair> - NewRDs = - generateVtableAndFatPointerStruct(*this, ReturnTy, PollResultRD); + NewRDs = generateVtableAndFatPointerStruct(*this, ReturnTy, + PollResultRD, FD); - if (!std::get<1>(std::get<0>(NewRDs))) - DeclsInGroup.push_back(std::get<0>(std::get<0>(NewRDs))); - if (!std::get<1>(std::get<1>(NewRDs))) - DeclsInGroup.push_back(std::get<0>(std::get<1>(NewRDs))); + if (!std::get<1>(std::get<0>(NewRDs))) { + decls.push_back(std::get<0>(std::get<0>(NewRDs))); + Context.BSCDesugaredMap[FD].push_back(std::get<0>(std::get<0>(NewRDs))); + } + if (!std::get<1>(std::get<1>(NewRDs))) { + decls.push_back(std::get<0>(std::get<1>(NewRDs))); + Context.BSCDesugaredMap[FD].push_back(std::get<0>(std::get<1>(NewRDs))); + } - FunctionDecl *FutureInitDef = buildFutureInitFunctionDefinition( + FunctionDecl *FutureInitDef = buildFutureInitFunctionDeclaration( *this, FD, std::get<0>(std::get<1>(NewRDs))); - DeclsInGroup.push_back(FutureInitDef); + FutureInitDef->dump(); + decls.push_back(FutureInitDef); + Context.BSCDesugaredMap[FD].push_back(FutureInitDef); } + return decls; } -SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { +SmallVector Sema::ActOnAsyncFunctionDefinition(FunctionDecl *FD) { SmallVector decls; + decls.push_back(FD); AwaitExprFinder finder = AwaitExprFinder(); finder.Visit(FD->getBody()); @@ -2663,7 +2655,6 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { Diag(FD->getBeginLoc(), diag::err_await_invalid_scope) << "non-async function."; } - decls.push_back(FD); return decls; } @@ -2685,7 +2676,10 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { QualType ReturnTy = FD->getReturnType(); ReturnTy.removeLocalConst(); if (ReturnTy->isVoidType()) { - RecordDecl *VoidRD = generateVoidStruct(*this); + RecordDecl *VoidRD = + generateVoidStruct(*this, FD->getBeginLoc(), FD->getEndLoc()); + decls.push_back(VoidRD); + Context.BSCDesugaredMap[FD].push_back(VoidRD); ReturnTy = Context.getRecordType(VoidRD); } QualType PollResultType = @@ -2696,16 +2690,22 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { RecordDecl *PollResultRD = PollResultType->getAsRecordDecl(); std::tuple, std::pair> - NewRDs = generateVtableAndFatPointerStruct(*this, ReturnTy, PollResultRD); + NewRDs = + generateVtableAndFatPointerStruct(*this, ReturnTy, PollResultRD, FD); - if (!std::get<1>(std::get<0>(NewRDs))) + if (!std::get<1>(std::get<0>(NewRDs))) { decls.push_back(std::get<0>(std::get<0>(NewRDs))); - if (!std::get<1>(std::get<1>(NewRDs))) + Context.BSCDesugaredMap[FD].push_back(std::get<0>(std::get<0>(NewRDs))); + } + + if (!std::get<1>(std::get<1>(NewRDs))) { decls.push_back(std::get<0>(std::get<1>(NewRDs))); + Context.BSCDesugaredMap[FD].push_back(std::get<0>(std::get<1>(NewRDs))); + } - // Handle definition first. - (void)buildFutureInitFunctionDefinition(*this, FD, - std::get<0>(std::get<1>(NewRDs))); + // Handle declaration first. + FunctionDecl *FutureInitDef = buildFutureInitFunctionDeclaration( + *this, FD, std::get<0>(std::get<1>(NewRDs))); const int FutureStateNumber = finder.GetAwaitExprNum() + 1; @@ -2715,6 +2715,7 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { return decls; } decls.push_back(RD); + Context.BSCDesugaredMap[FD].push_back(RD); BSCMethodDecl *PollDecl = buildPollFunction(*this, RD, PollResultRD, FD, @@ -2723,12 +2724,14 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { return decls; } decls.push_back(PollDecl); + Context.BSCDesugaredMap[FD].push_back(PollDecl); BSCMethodDecl *FreeDecl = buildFreeFunction(*this, RD, FD); if (!FreeDecl) { return decls; } decls.push_back(FreeDecl); + Context.BSCDesugaredMap[FD].push_back(FreeDecl); VarDecl *VtableDecl = buildVtableInitDecl(*this, FD, std::get<0>(std::get<0>(NewRDs)), @@ -2737,12 +2740,15 @@ SmallVector Sema::ActOnAsyncFunctionDeclaration(FunctionDecl *FD) { return decls; } decls.push_back(VtableDecl); + Context.BSCDesugaredMap[FD].push_back(VtableDecl); - FunctionDecl *FutureInit = buildFutureInitFunctionDeclaraion( - *this, RD, FD, std::get<0>(std::get<1>(NewRDs)), VtableDecl); + FunctionDecl *FutureInit = buildFutureInitFunctionDefinition( + *this, RD, FD, std::get<0>(std::get<1>(NewRDs)), VtableDecl, + FutureInitDef); if (!FutureInit) { return decls; } decls.push_back(FutureInit); + Context.BSCDesugaredMap[FD].push_back(FutureInit); return decls; } \ No newline at end of file diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 70783efc1c8f3bba4fe500cb1e495d9f826f33fa..d52e7961dc44db55fae28e0e24d9bceb9aa0091e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6936,6 +6936,9 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, TempCFD, TempCFD->getType().getNonReferenceType(), VK_LValue, TempCFD->getLocation()); Expr *RHSExpr1 = RHSER1.get(); + RHSExpr1->HasBSCScopeSpec = NakedFn->HasBSCScopeSpec; + RHSExpr1->IsDesugaredBSCMethodCall = + NakedFn->IsDesugaredBSCMethodCall; Fn = ImpCastExprToType(RHSExpr1, Context.getPointerType(TempCFD->getType()), CK_FunctionToPointerDecay) diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index a2f85342920b79530d8d1591cca484354f2daa5d..52b50062ce68ebd9c61b972beef84b1141cefe08 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -11062,7 +11062,9 @@ TreeTransform::TransformCallExpr(CallExpr *E) { // Keep flag unchanged in transformation. Callee.get()->IsDesugaredBSCMethodCall = E->getCallee()->IsDesugaredBSCMethodCall; Callee.get()->HasBSCScopeSpec = E->getCallee()->HasBSCScopeSpec; - + Callee.get()->IgnoreImplicit()->HasBSCScopeSpec = + E->getCallee()->IgnoreImplicit()->HasBSCScopeSpec; + // Transform arguments. bool ArgChanged = false; SmallVector Args; diff --git a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-nest-await.cbs b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-nest-await.cbs index ab3bbf254357ed53ca96a28f12a5f3046f67527a..9810ecf22fd9b64eb83c4f0866a5cc05636ae94f 100644 --- a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-nest-await.cbs +++ b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-nest-await.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-num.cbs b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-num.cbs index fa912fc64a66b6a28793545c2381bab561e5ec78..695d6b3119b63e3ee0d14ab4a3d8dacbe7a2ebbf 100644 --- a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-num.cbs +++ b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-num.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-of-return.cbs b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-of-return.cbs index a7a47febd91ef5d38b98079743957ebe05964c94..638d7150e10321c30101114ced51acb70e987752 100644 --- a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-of-return.cbs +++ b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-of-return.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-single-judgement.cbs b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-single-judgement.cbs index efd013870b88c8a7e73f793f075652cd96c562b0..8e4570dd5f0d9b28cf995088e50124421ad367d1 100644 --- a/clang/test/BSC/Coroutine/AwaitExpr/await-expr-single-judgement.cbs +++ b/clang/test/BSC/Coroutine/AwaitExpr/await-expr-single-judgement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Other/Definition/async_definition_1.cbs b/clang/test/BSC/Coroutine/Other/Definition/async_definition_1.cbs index 451a32f7bccc4993aba8ee1c1e9b8faf6ee2c7bb..618a5aa829bfa0be9593e9ae825204bc4a902aaa 100644 --- a/clang/test/BSC/Coroutine/Other/Definition/async_definition_1.cbs +++ b/clang/test/BSC/Coroutine/Other/Definition/async_definition_1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Other/DifferenctReturnType/async-different-return-type2.cbs b/clang/test/BSC/Coroutine/Other/DifferenctReturnType/async-different-return-type2.cbs index 464a9a4386437e541fe5f5140e838630098d63f8..456c080f86bca6141d2323bfc778fb18d06ba776 100644 --- a/clang/test/BSC/Coroutine/Other/DifferenctReturnType/async-different-return-type2.cbs +++ b/clang/test/BSC/Coroutine/Other/DifferenctReturnType/async-different-return-type2.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output #include "../../async-func-read.hbs" #include diff --git a/clang/test/BSC/Coroutine/Other/NonCallAwaitExpr/await-non-call.cbs b/clang/test/BSC/Coroutine/Other/NonCallAwaitExpr/await-non-call.cbs index 2aa0865d535c1aefd8b45d92bab6d37cc785a7dc..5568b416265e26c940a02ea717da278c8e87c45b 100644 --- a/clang/test/BSC/Coroutine/Other/NonCallAwaitExpr/await-non-call.cbs +++ b/clang/test/BSC/Coroutine/Other/NonCallAwaitExpr/await-non-call.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output + #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/await-expr-for.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/await-expr-for.cbs index 6996ba85987d2b917549a275759d7e52d9c5d651..e069e51535821017e157d155bf1b075c65c9e11b 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/await-expr-for.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/await-expr-for.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/func-invoke.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/func-invoke.cbs index 9924f1d599b976129a4141da2a9d8fb47d1620e7..1de749085066e6b084c888eb69db6fa1a65e02ed 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/func-invoke.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/func-invoke.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/register-storage-class.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/register-storage-class.cbs index 7a0a2b7ba2e1df3e8a5d5264fa6400f6e14c7dd6..64d27828c25ba99e6fe54e0ddee6e4aa3d5bc76c 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/register-storage-class.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/register-storage-class.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/static-storage-class.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/static-storage-class.cbs index c7a5b890a993fc9ff8d84665d80a77345789cd8c..a3b5a6ac168b45198d1ae60f11e3e1aba586542e 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/static-storage-class.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Common/static-storage-class.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl.cbs index e130b577d257b19b8f60d4eacd7cb5fa64cab07b..dd2cd90ff1be8b896937481ebffe4411af9c0837 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl1.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl1.cbs index c174dfb95401bfca5645357456b80613d4979cdc..81c1c21409fea9c4f2806aeb2196a0c5d4d34732 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl1.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/array-decl1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/base-type-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/base-type-decl.cbs index 1ec6c50c7198561fcc234bf0b78562d5246f8a3c..b6544c9fa9b2789ec9ca40e43239378151a931e1 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/base-type-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/base-type-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/const-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/const-decl.cbs index 11cd708f4c97cebe98331df98219e068d8a35969..e4b5fc52f9cccd84a411c10ec4bb22825a90750b 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/const-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/const-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/literal-quantity-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/literal-quantity-decl.cbs index af2710a6870c8993a50cc8afdeaa62a156f18fe1..9cc767bb6dbf6f58914094f7ad6df888392826dc 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/literal-quantity-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/literal-quantity-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-decl.cbs index 24ce1a202ac4fd0655b55987d7be23ee407b2522..d2d273f4ba06035cb02572d553192f5feee9204e 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-dimension-array-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-dimension-array-decl.cbs index 52f44ffed53a905a040ba7fc6223aa1795941ca1..bf2cbe81a985df5726836913949cac89d3fd3e65 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-dimension-array-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/multi-dimension-array-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/pointer-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/pointer-decl.cbs index 97c831aacf4dd54b7da0149243552eac18fc00c7..70f0582290ec2029aeabb2706cba1370f5c1d309 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/pointer-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/pointer-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/static-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/static-decl.cbs index ceb2953bef6431523b7d9c33489f4743ebbdcf8f..bcba52b9caaa2a5a4d2df28fc95b99b0e05eab5b 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/static-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/static-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/struct-decl.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/struct-decl.cbs index acb011fe07586f790e121c193dd64279f1130875..1ca36001aae8a0e55e9648df136a67b33caf6765 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/struct-decl.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/MultiDecl/struct-decl.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/arithmetic-op-of-c-pointer.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/arithmetic-op-of-c-pointer.cbs index 5f8e30264e77193a1fde57a4bed062477fb388e2..4611c56127844fc64a0f340f08e15bb19f40c77d 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/arithmetic-op-of-c-pointer.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/arithmetic-op-of-c-pointer.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/c-pointer-to-pointer.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/c-pointer-to-pointer.cbs index f7464514f0be6f1d3c8b1ee357ba06ff56e8e9bd..9453e1afd8907c2b3aa6c3c26775ea8537e5a0c6 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/c-pointer-to-pointer.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/c-pointer-to-pointer.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/func-pointer.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/func-pointer.cbs index fc49cbe2649e134ff3f685b2a2d980ddca15f2d1..d095e9ce5206e3775f4183e2b2fd85d7b0ab4c8a 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/func-pointer.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Pointer/func-pointer.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Struct/struct-init.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Struct/struct-init.cbs index 66001bf0fc4a4465d59cd9112f35fb0bda97a4cd..c90dcad749e6c3d62fe2d75517a24fe22c5d9762 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Struct/struct-init.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Struct/struct-init.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Union/union-init.cbs b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Union/union-init.cbs index 550f6464ea50ddd9875d964c6e70dfe4559fd674..f9d7352094d72a2ceb90b5fcfa6fd52261c2f3f4 100644 --- a/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Union/union-init.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/DeclStmt/Union/union-init.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/await-expr-if.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/await-expr-if.cbs index 293469a138ff30a4382b79d26256b636220b0bdc..b5ff57b0481bcfe6060181f7b76221f71ef838f7 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/await-expr-if.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/await-expr-if.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-else-statement.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-else-statement.cbs index ef79904013fbbdcab5fa58f95b848ef9f8c03aca..8e5414dded006951790f02c07184d7d3af321eb0 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-else-statement.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-else-statement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-nested-if-statement.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-nested-if-statement.cbs index d6b9112ac2399b8619ed46617fdb53ee40b7f57d..125b95dfa38f78038a1bb9b4add766c14cd65cad 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-nested-if-statement.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-nested-if-statement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-statement.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-statement.cbs index 07d587bc63407cd3897131fcfe105f662dad1de1..8c3ede3b44c1ac4ce8d364a9961e5b779b0d4633 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-statement.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/if-statement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-nested-switch-statement.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-nested-switch-statement.cbs index d599dba8d7e0600b3d595828790821f76622c55d..354b0d7ef32896bcb0eb21c7f89594332f2fd4be 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-nested-switch-statement.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-nested-switch-statement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-statement.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-statement.cbs index f9a9f457c4d750135f9aae98264314af965a312f..602f8bde4a9081d2b1003716579f781b8b0b74a2 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-statement.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Judgement/switch-statement.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/do-while-loop.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/do-while-loop.cbs index 80e5952ca22ffd79ff7c6d9199db176eb29b33fd..5fee617333d53b688b517f6db6917b203b7b76df 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/do-while-loop.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/do-while-loop.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/for-loop.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/for-loop.cbs index 54d88e2615fcfc8388e461a25f58098fb53dffc9..5e0096787518ddbc7df00c9d809b00eaed067841 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/for-loop.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/for-loop.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/loop-nested.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/loop-nested.cbs index e0aae2b7738c0e36318081b18fa9c71b5a74f3b5..b9a5349f9fe9e0427589e1c6e6836d1dad410a2c 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/loop-nested.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/loop-nested.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/while-loop.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/while-loop.cbs index 322c01036288013d05ffeea55601eeedb81afc0b..34e8da76bf271eb64f9e0cc6d870e9bc15e3c02f 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Loop/while-loop.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Loop/while-loop.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/arithmetic-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/arithmetic-op.cbs index 8ee43a7343ce4dd8dfb658bd23871503337ed68a..4ab9821de7a394961f75f442e209e94213936b24 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/arithmetic-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/arithmetic-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/assign-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/assign-op.cbs index f30479f9865d59de2c5a12dec99a700f7d976bed..91e19bbc73b233a8cde1c564b4a197cea3fc145e 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/assign-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/assign-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/bit-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/bit-op.cbs index eac7df0899a7428abb5a9d692a6d6b8d14350fe2..339074a1b9b6075e3e489d2174f3c83fecb9a754 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/bit-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/bit-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/logocal-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/logocal-op.cbs index 190e379d351848b3e385550503531fb14af65f4b..84208a8d2a689acbed950f7663fcb2f070858c1d 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/logocal-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/logocal-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/other-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/other-op.cbs index 5604c376946e487e0237a3e656a67c725093834c..a9f00f8be07328db4663f568c9d5461da797ba56 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/other-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/other-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/relational-op.cbs b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/relational-op.cbs index c83b0e84109b8dbf07c504cdfee53d8e770161dd..b49f5a3918ddfab71b9da59cba1d804618dd0b4c 100644 --- a/clang/test/BSC/Coroutine/Treetransform/Other/Operators/relational-op.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/Other/Operators/relational-op.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-const-int.cbs b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-const-int.cbs index 393afd0ba9540ab3167c7a014a0e8ade33ba3b57..bd5bd58230cae23f97e852af6cdcfe59684294e0 100644 --- a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-const-int.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-const-int.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-type.cbs b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-type.cbs index f17fa112e158b1ba2c3cf934beca79a0a10d6815..fd70727b83b6fd71c38f33b145ca5515d85f8eed 100644 --- a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-type.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/async-func-return-type.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type.cbs b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type.cbs index 0ac2af65146a012cac05da304e3ab68c17688b9b..fff8f567c5495cb31d9421982c19032bd02fd018 100644 --- a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type1.cbs b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type1.cbs index 80ae70d825c647201eef90d05225cf4018a218f8..fe9ae9b4bf983568bf75448fcbcba7e24ff337d2 100644 --- a/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type1.cbs +++ b/clang/test/BSC/Coroutine/Treetransform/ReturnStmt/await-expr-return-type1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %test.output // RUN: %test.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include "../../async-func-read.hbs" diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_1.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_1.cbs index 7ce0a477eb4da5d565758681a5861f24e1bd5b47..82c0d55461516332fee647f1ad965785ce5146cd 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_1.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_1.cbs @@ -24,7 +24,7 @@ int main() { return 0; } -// CHECK:int int_increase(int* this) { +// CHECK:int int_increase(int *this) { // CHECK-NEXT: return *this += 1; // CHECK-NEXT:} @@ -42,12 +42,12 @@ int main() { // CHECK-NEXT: return a > b ? a : b; // CHECK-NEXT: } -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: int a1 = 1; // CHECK-NEXT: int b1 = 2; // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int c1 = max_int_int(a1, b1); -// CHECK-NEXT: float c2 = max_float_float(1.0, 2.0); +// CHECK-NEXT: float c2 = max_float_float(1., 2.); // CHECK-NEXT: return 0; // CHECK-NEXT:} \ No newline at end of file diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_2.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_2.cbs index 2903f030dc7e6e6928c83c9a730dee6b6d009728..69bb7d5aebff1595017fb68261f6300cdea4d8a9 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_2.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_2.cbs @@ -21,7 +21,7 @@ int main() { // CHECK-NEXT: float a; // CHECK-NEXT:}; -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: struct Foo_int foo = {.a = 42}; // CHECK-NEXT: struct Foo_float foo_2 = {.a = 1.5}; // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_3.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_3.cbs index 18e886e0d9842dce722b2a0365fb4e4ad36276e3..5cd7deb22ce1cbbebb87e35b7a7e7936ad655bea 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_3.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_3.cbs @@ -26,7 +26,7 @@ int main() { // CHECK:struct Block { -// CHECK-NEXT: char* color; +// CHECK-NEXT: char *color; // CHECK-NEXT: int blood; // CHECK-NEXT:}; @@ -48,8 +48,8 @@ int main() { // CHECK-NEXT: return grass; // CHECK-NEXT: } -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: struct Block br1 = bar_int_int(1, 2); -// CHECK-NEXT: struct Block br2 = bar_double_float(1.0, 2.0); +// CHECK-NEXT: struct Block br2 = bar_double_float(1., 2.); // CHECK-NEXT: return 0; // CHECK-NEXT:} \ No newline at end of file diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_4.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_4.cbs index f9fcc4c45583458a2a6a096470f0cac85d87d549..b30c6f476d4c2c17645f594803ea96c26362bd03 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_4.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_4.cbs @@ -31,7 +31,7 @@ int main() { // CHECK-NEXT: } -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: int b1 = 2; // CHECK-NEXT: struct Block bb; // CHECK-NEXT: test_struct_Block(bb); diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_5.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_5.cbs index 483bb0b106afc4431a7aa9d1fc001dbbb39e1738..3cf1873add34dc1fe4a7c0771587f1a7312c6dda 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_5.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_5.cbs @@ -24,7 +24,7 @@ int main() { return 0; } -// CHECK:int int_increase(int* this) { +// CHECK:int int_increase(int *this) { // CHECK-NEXT: return *this += 1; // CHECK-NEXT:} @@ -42,12 +42,12 @@ int main() { // CHECK-NEXT: return a > b ? a : b; // CHECK-NEXT: } -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: int a1 = 1; // CHECK-NEXT: int b1 = 2; // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int c1 = max_int(a1); -// CHECK-NEXT: float c2 = max_float(1.0); +// CHECK-NEXT: float c2 = max_float(1.); // CHECK-NEXT: return 0; // CHECK-NEXT:} \ No newline at end of file diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_6.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_6.cbs new file mode 100644 index 0000000000000000000000000000000000000000..ad2034f895218bc418d7ab6a6eaa630224bb992b --- /dev/null +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_6.cbs @@ -0,0 +1,55 @@ +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output + +struct B {}; +struct Foo { + T a; +}; + +int struct B::increase(struct B* this) { + return 0; +} + +struct Foo max(T1 a) { + struct Foo f; + struct B x; + struct B::increase(&x); + int b = x.increase(); + return f; +} + +int main() { + struct B a1; + struct B b1; + b1.increase(); + struct B::increase(&b1); + struct Foo c1 = max(a1); + return 0; +} + +// CHECK: struct Foo_int { +// CHECK-NEXT: int a; +// CHECK-NEXT: }; + +// CHECK: int struct_B_increase(struct B *this) { +// CHECK-NEXT: return 0; +// CHECK-NEXT: } + +// CHECK: struct Foo_int max_struct_B(struct B a) { +// CHECK-NEXT: struct Foo_int f; +// CHECK-NEXT: struct B x; +// CHECK-NEXT: struct_B_increase(&x); +// CHECK-NEXT: int b = struct_B_increase(&x); +// CHECK-NEXT: return f; +// CHECK-NEXT: } + +// CHECK: int main(void) { +// CHECK-NEXT: struct B a1; +// CHECK-NEXT: struct B b1; +// CHECK-NEXT: struct_B_increase(&b1); +// CHECK-NEXT: struct_B_increase(&b1); +// CHECK-NEXT: struct Foo_int c1 = max_struct_B(a1); +// CHECK-NEXT: return 0; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_7.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_7.cbs new file mode 100644 index 0000000000000000000000000000000000000000..1619745fcee9cd8ebf52857c60edd0add12525af --- /dev/null +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_7.cbs @@ -0,0 +1,79 @@ +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output + +struct B {}; + +struct Foo { + T a; +}; + +struct Goo { + T1 a; + T2 b; +}; + +int struct B::increase(struct B* this) { + return 0; +} + +struct Foo max(T1 a, struct Foo foo) { + struct B x; + struct B::increase(&x); + int b = x.increase(); + return foo; +} + +struct Goo poo(struct Goo goo) { + return goo; +} + +int main() { + struct B a1; + struct B b1; + b1.increase(); + struct B::increase(&b1); + struct Foo foo; + foo = max(a1, foo); + struct Goo p; + p = poo(p); + return 0; +} + +// CHECK: struct Foo_struct_B { +// CHECK-NEXT: struct B a; +// CHECK-NEXT: }; + +// CHECK: struct Goo_struct_B_struct_B { +// CHECK-NEXT: struct B a; +// CHECK-NEXT: struct B b; +// CHECK-NEXT: }; + +// CHECK: int struct_B_increase(struct B *this) { +// CHECK-NEXT: return 0; +// CHECK-NEXT: } + +// CHECK: struct Foo_struct_B max_struct_B(struct B a, struct Foo_struct_B foo) { +// CHECK-NEXT: struct B x; +// CHECK-NEXT: struct_B_increase(&x); +// CHECK-NEXT: int b = struct_B_increase(&x); +// CHECK-NEXT: return foo; +// CHECK-NEXT: } + +// CHECK: struct Goo_struct_B_struct_B poo(struct Goo_struct_B_struct_B goo) { +// CHECK-NEXT: return goo; +// CHECK-NEXT: } + +// CHECK: int main(void) { +// CHECK-NEXT: struct B a1; +// CHECK-NEXT: struct B b1; +// CHECK-NEXT: struct_B_increase(&b1); +// CHECK-NEXT: struct_B_increase(&b1); +// CHECK-NEXT: struct Foo_struct_B foo; +// CHECK-NEXT: foo = max_struct_B(a1, foo); +// CHECK-NEXT: struct Goo_struct_B_struct_B p; +// CHECK-NEXT: p = poo(p); +// CHECK-NEXT: return 0; +// CHECK-NEXT: } + diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_8.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_8.cbs new file mode 100644 index 0000000000000000000000000000000000000000..bdfa5bf097577018ef76f01df54699c8c1bf2bef --- /dev/null +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_8.cbs @@ -0,0 +1,39 @@ +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output + +struct PollResult { + +}; + + +struct A { +struct PollResult a; + +}; + +struct B { + +}; + + +struct C { + struct PollResult a; +}; + +int main() {}; + +// CHECK: struct PollResult_int { +// CHECK-NEXT: }; + +// CHECK: struct A { +// CHECK-NEXT: struct PollResult_int a; +// CHECK-NEXT: }; + +// CHECK: struct B { +// CHECK-NEXT: }; + +// CHECK: struct C { +// CHECK-NEXT: struct PollResult_int a; +// CHECK-NEXT: }; diff --git a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_with_header.cbs b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_with_header.cbs index ad2d36eeab517ed4f368b556c74abfff769a5a42..d431f2499ffc24d8e64cfecf20a277a46a71eee4 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_with_header.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/Generic/rewrite_bsc_generic_with_header.cbs @@ -18,7 +18,7 @@ int main() { } -// CHECK:int int_increase(int* this) { +// CHECK:int int_increase(int *this) { // CHECK-NEXT: return *this += 1; // CHECK-NEXT:} @@ -44,13 +44,13 @@ int main() { // CHECK-NEXT: float a; // CHECK-NEXT:}; -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: int a1 = 1; // CHECK-NEXT: int b1 = 2; // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int_increase(&b1); // CHECK-NEXT: int c1 = max_int_int(a1, b1); -// CHECK-NEXT: float c2 = max_float_float(1.0, 2.0); +// CHECK-NEXT: float c2 = max_float_float(1., 2.); // CHECK-NEXT: struct Foo_int foo = {.a = 42}; // CHECK-NEXT: struct Foo_float foo_2 = {.a = 1.5}; // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Driver/rewrite-bsc/GenericBSCMethod/rewrite_generic_bscmethod.cbs b/clang/test/BSC/Driver/rewrite-bsc/GenericBSCMethod/rewrite_generic_bscmethod.cbs new file mode 100644 index 0000000000000000000000000000000000000000..c98d1f000c50839c735592babaa9438be67261b6 --- /dev/null +++ b/clang/test/BSC/Driver/rewrite-bsc/GenericBSCMethod/rewrite_generic_bscmethod.cbs @@ -0,0 +1,43 @@ +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output + +struct MyStruct { + T res; +}; + +void int::increase(int* this) { + *this = *this +1; +} + +int struct MyStruct::foo() { + int x = 1; + x.increase(); + return x; +} + +int main() { + int res = struct MyStruct::foo(); + return res - 2; +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: void int_increase(int *this) { +// CHECK-NEXT: *this = *this + 1; +// CHECK-NEXT: } + +// CHECK: int struct_MyStruct_int_foo(void) { +// CHECK-NEXT: int x = 1; +// CHECK-NEXT: int_increase(&x); +// CHECK-NEXT: return x; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res = struct_MyStruct_int_foo(); +// CHECK-NEXT: return res - 2; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_option.cbs b/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_option.cbs index 0b90b7fd652331b1128b3caf58c7eef8f9c187b4..0a45df52cff7f8b1e992d5f85d92c173de6e5fee 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_option.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_option.cbs @@ -30,7 +30,7 @@ int main() { // CHECK-NEXT: int a; // CHECK-NEXT:}; -// CHECK:int struct_Foo_getA(struct Foo* this) { +// CHECK:int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT:} @@ -38,7 +38,7 @@ int main() { // CHECK-NEXT: *this = *this + 1; // CHECK-NEXT:} -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 42}; // CHECK-NEXT: int a = struct_Foo_getA(&foo); // CHECK-NEXT: int b = 41; diff --git a/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_with_header.cbs b/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_with_header.cbs index 8fe7ebcd0b5ec668e767dd84b2e61583860d4a1c..db1e8810f9725822a853699076c9f9f104be815a 100644 --- a/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_with_header.cbs +++ b/clang/test/BSC/Driver/rewrite-bsc/rewrite_bsc_with_header.cbs @@ -18,7 +18,7 @@ int main() { // CHECK-NEXT: int a; // CHECK-NEXT: }; -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } @@ -26,7 +26,7 @@ int main() { // CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 42}; // CHECK-NEXT: int a = struct_Foo_getA(&foo); // CHECK-NEXT: int b = 41; diff --git a/clang/test/BSC/Generic/DataStructure/Array.cbs b/clang/test/BSC/Generic/DataStructure/Array.cbs index 2fcb4cd69d08bdbfc1087ca9533b056b84e7c12f..e7cc065c2aa3e1db57c4014c789f79a2fced4b45 100644 --- a/clang/test/BSC/Generic/DataStructure/Array.cbs +++ b/clang/test/BSC/Generic/DataStructure/Array.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/DataStructure/LinkedList.cbs b/clang/test/BSC/Generic/DataStructure/LinkedList.cbs index 00195a1f32b14702a277d265d2ccd58f8d88c727..a0656b925c2147047ac52e435a4dddd93c70a00d 100644 --- a/clang/test/BSC/Generic/DataStructure/LinkedList.cbs +++ b/clang/test/BSC/Generic/DataStructure/LinkedList.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/DataStructure/Map.cbs b/clang/test/BSC/Generic/DataStructure/Map.cbs index b0806bf1a41278574ef7291741f53c68c2b83c0e..3efd9d80474d12923a8354ea89c268aab0c44c85 100644 --- a/clang/test/BSC/Generic/DataStructure/Map.cbs +++ b/clang/test/BSC/Generic/DataStructure/Map.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/DataStructure/Queue.cbs b/clang/test/BSC/Generic/DataStructure/Queue.cbs index a0da4213e586569d539d32314e3090a618da64c1..985cb4abd0b808ae8df0559024bf086293d6d146 100644 --- a/clang/test/BSC/Generic/DataStructure/Queue.cbs +++ b/clang/test/BSC/Generic/DataStructure/Queue.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include @@ -60,7 +63,7 @@ T struct Queue::back(struct Queue *this) { } int main() { - Queue q; + struct Queue q; q.init(); for (int i = 0; i < 10; i++) { q.push(i); diff --git a/clang/test/BSC/Generic/DataStructure/Stack.cbs b/clang/test/BSC/Generic/DataStructure/Stack.cbs index 56dbb0c0b3ff183b14204c87ad5d374bc89c682f..f66ae8647cc2140002eb319a9ef681ebfbfcd387 100644 --- a/clang/test/BSC/Generic/DataStructure/Stack.cbs +++ b/clang/test/BSC/Generic/DataStructure/Stack.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/GenericTypeMethods/generic_func_nested_call.cbs b/clang/test/BSC/Generic/GenericTypeMethods/generic_func_nested_call.cbs index 97635529d5925196c7b61e6f6fd5faba95cc4a89..f178f55bb337b484be13b20ef2a6e8c67a190ea8 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/generic_func_nested_call.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/generic_func_nested_call.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct S { @@ -30,4 +34,37 @@ int main() { int res1 = f1(2); int res2 = f2(2); return res1 - res2; -} \ No newline at end of file +} + +// CHECK: struct S_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: struct S_int s; +// CHECK-NEXT: }; + +// CHECK: int struct_MyStruct_int_foo(struct MyStruct_int *this, int a) { +// CHECK-NEXT: this->res = a; +// CHECK-NEXT: return this->res; +// CHECK-NEXT: } + + +// CHECK: int f1_int(int a) { +// CHECK-NEXT: struct MyStruct_int s = {.res = a}; +// CHECK-NEXT: return struct_MyStruct_int_foo(&s, a); +// CHECK-NEXT: } + + +// CHECK: int f2_int(int a) { +// CHECK-NEXT: struct MyStruct_int s = {.res = a}; +// CHECK-NEXT: return struct_MyStruct_int_foo(&s, a); +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res1 = f1_int(2); +// CHECK-NEXT: int res2 = f2_int(2); +// CHECK-NEXT: return res1 - res2; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_builtIn_member_func.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_builtIn_member_func.cbs index ced1b537f06f776be3d42bbbc44cab0eb26e3564..1ac348775b462a6c20be47f9927666206a66999a 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_builtIn_member_func.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_builtIn_member_func.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -19,4 +23,24 @@ int struct MyStruct::foo() { int main() { int res = struct MyStruct::foo(); return res - 2; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: void int_increase(int *this) { +// CHECK-NEXT: *this = *this + 1; +// CHECK-NEXT: } + +// CHECK: int struct_MyStruct_int_foo(void) { +// CHECK-NEXT: int x = 1; +// CHECK-NEXT: int_increase(&x); +// CHECK-NEXT: return x; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res = struct_MyStruct_int_foo(); +// CHECK-NEXT: return res - 2; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_func.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_func.cbs index 041ce80a8ea485e5cb667944ee5528bc8afee43a..5d4f24796268d76da354a47cd4cc909b54747457 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_func.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_func.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -17,4 +21,24 @@ int struct MyStruct::foo() { int main() { int res = struct MyStruct::foo(); return res - 42; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: int foo_int_int(int a, int b) { +// CHECK-NEXT: return 42; +// CHECK-NEXT: } + + +// CHECK: int struct_MyStruct_int_foo(void) { +// CHECK-NEXT: return foo_int_int(1, 2); +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res = struct_MyStruct_int_foo(); +// CHECK-NEXT: return res - 42; +// CHECK-NEXT: } + diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func.cbs index 92b6957afc158cb90a5e929cd08ee13df9ebea47..6411515df3f0e02b405408cccdfd3e0bb973d9ae 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct1 { @@ -21,4 +25,28 @@ int struct MyStruct2::foo() { int main() { int res = struct MyStruct2::foo(); return res - 42; -} \ No newline at end of file +} + +// CHECK: struct MyStruct1_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: struct MyStruct2_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: int struct_MyStruct1_int_foo(void) { +// CHECK-NEXT: return 42; +// CHECK-NEXT: } + + +// CHECK: int struct_MyStruct2_int_foo(void) { +// CHECK-NEXT: return struct_MyStruct1_int_foo(); +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res = struct_MyStruct2_int_foo(); +// CHECK-NEXT: return res - 42; +// CHECK-NEXT: } + diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func2.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func2.cbs index dc8fa976167cf605850b371d2ba59d3f3642a101..1f9b7114728dfecff8eabd50931da9de32731939 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func2.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_call_generic_member_func2.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct1 { @@ -22,4 +26,29 @@ int struct MyStruct2::foo() { int main() { int res = struct MyStruct2::foo(); return res - 42; -} \ No newline at end of file +} + +// CHECK: struct MyStruct1_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: struct MyStruct2_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: int struct_MyStruct1_int_foo(struct MyStruct1_int *this) { +// CHECK-NEXT: return 42; +// CHECK-NEXT: } + + +// CHECK: int struct_MyStruct2_int_foo(void) { +// CHECK-NEXT: struct MyStruct1_int s = {.res = 1}; +// CHECK-NEXT: return struct_MyStruct1_int_foo(&s); +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res = struct_MyStruct2_int_foo(); +// CHECK-NEXT: return res - 42; +// CHECK-NEXT: } + diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_instance_call.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_instance_call.cbs index c108ae553ab5070046636180bc069fc307113e43..98d38d7abfb62df740c9abaf87e9b809a9737719 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_instance_call.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_instance_call.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -26,4 +30,32 @@ int main() { int res1 = s.foo(10); int res2 = u.foo(6); return res1 - res2; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: union MyUnion_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: int struct_MyStruct_int_foo(struct MyStruct_int *this, int a) { +// CHECK-NEXT: this->res = this->res + a; +// CHECK-NEXT: return this->res; +// CHECK-NEXT: } + + +// CHECK: int union_MyUnion_int_foo(union MyUnion_int *this, int a) { +// CHECK-NEXT: this->res = this->res + a; +// CHECK-NEXT: return this->res; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: struct MyStruct_int s = {.res = 1}; +// CHECK-NEXT: union MyUnion_int u = {.res = 5}; +// CHECK-NEXT: int res1 = struct_MyStruct_int_foo(&s, 10); +// CHECK-NEXT: int res2 = union_MyUnion_int_foo(&u, 6); +// CHECK-NEXT: return res1 - res2; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_multi_generic_params.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_multi_generic_params.cbs index fc58b4938bc411c5b32b7bab162ff08077d9bed0..260a84ea98825d0490b1bca79c64f7603b19952c 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_multi_generic_params.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_multi_generic_params.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -24,4 +28,30 @@ int main() { s.foo(); u.foo(); return 0; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int_int_float { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: union MyUnion_float_int_char { +// CHECK-NEXT: float res; +// CHECK-NEXT: }; + +// CHECK: struct MyStruct_int_int_float struct_MyStruct_int_int_float_foo(struct MyStruct_int_int_float *this) { +// CHECK-NEXT: return *this; +// CHECK-NEXT: } + + +// CHECK: union MyUnion_float_int_char union_MyUnion_float_int_char_foo(union MyUnion_float_int_char *this) { +// CHECK-NEXT: return *this; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: struct MyStruct_int_int_float s = {.res = 1}; +// CHECK-NEXT: union MyUnion_float_int_char u = {.res = 5.}; +// CHECK-NEXT: struct_MyStruct_int_int_float_foo(&s); +// CHECK-NEXT: union_MyUnion_float_int_char_foo(&u); +// CHECK-NEXT: return 0; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/GenericTypeMethods/member_func_static_call.cbs b/clang/test/BSC/Generic/GenericTypeMethods/member_func_static_call.cbs index 4f9b61f46383db245e0bec40a6397216f3896f2f..cce875d4d28c342cb82a9c1d3b4cfe1ab482c992 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/member_func_static_call.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/member_func_static_call.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -22,4 +26,28 @@ int main() { int res1 = struct MyStruct::foo(12); int res2 = union MyUnion::foo(10); return res1 - res2 - 2; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: union MyUnion_int { +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: int struct_MyStruct_int_foo(int a) { +// CHECK-NEXT: return a; +// CHECK-NEXT: } + + +// CHECK: int union_MyUnion_int_foo(int a) { +// CHECK-NEXT: return a; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: int res1 = struct_MyStruct_int_foo(12); +// CHECK-NEXT: int res2 = union_MyUnion_int_foo(10); +// CHECK-NEXT: return res1 - res2 - 2; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated.cbs b/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated.cbs index 2bca2620ab40a73102ccca2ab36caca122511bcb..19d90f066ac157b6bda6216b0d77e0ba24695ee7 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated.cbs @@ -1,5 +1,9 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { @@ -32,4 +36,38 @@ int main() { int res2 = struct MyStruct::poll(&p, 12); int res3 = f(); return res1 + res2 - res3; -} \ No newline at end of file +} + +// CHECK: struct MyStruct_int { +// CHECK-NEXT: int isPending; +// CHECK-NEXT: int res; +// CHECK-NEXT: }; + +// CHECK: struct MyStruct_int foo(struct MyStruct_int *a) { +// CHECK-NEXT: return *a; +// CHECK-NEXT: } + +// CHECK: int struct_MyStruct_int_bar(struct MyStruct_int *this, int a) { +// CHECK-NEXT: return a; +// CHECK-NEXT: } + + +// CHECK: int f(void) { +// CHECK-NEXT: struct MyStruct_int p; +// CHECK-NEXT: int res1 = struct_MyStruct_int_bar(&p, 10); +// CHECK-NEXT: int res2 = struct_MyStruct_int_bar(&p, 12); +// CHECK-NEXT: return res1 + res2; +// CHECK-NEXT: } + +// CHECK: int struct_MyStruct_int_poll(struct MyStruct_int *this, int a) { +// CHECK-NEXT: return a; +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: struct MyStruct_int p; +// CHECK-NEXT: int res1 = struct_MyStruct_int_poll(&p, 10); +// CHECK-NEXT: int res2 = struct_MyStruct_int_poll(&p, 12); +// CHECK-NEXT: int res3 = f(); +// CHECK-NEXT: return res1 + res2 - res3; +// CHECK-NEXT: } \ No newline at end of file diff --git a/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated_diff_types.cbs b/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated_diff_types.cbs index 36691ec694df3e841c46d98d22fb4e56ef4c271f..1a8b11033cdf8091dd5b92023a213d988427f93b 100644 --- a/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated_diff_types.cbs +++ b/clang/test/BSC/Generic/GenericTypeMethods/multi_instantiated_diff_types.cbs @@ -1,4 +1,10 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang %s -o %t.output +// RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: FileCheck --input-file=%t-rw.c %s +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct S { @@ -13,4 +19,27 @@ int main() { s2.f(); return 0; -} \ No newline at end of file +} + +// CHECK: struct S_int { +// CHECK-NEXT: int t; +// CHECK-NEXT: }; + +// CHECK: struct S_double { +// CHECK-NEXT: double t; +// CHECK-NEXT: }; + +// CHECK: void struct_S_int_f(struct S_int *this) { +// CHECK-NEXT: } + +// CHECK: void struct_S_double_f(struct S_double *this) { +// CHECK-NEXT: } + + +// CHECK: int main(void) { +// CHECK-NEXT: struct S_int s1; +// CHECK-NEXT: struct_S_int_f(&s1); +// CHECK-NEXT: struct S_double s2; +// CHECK-NEXT: struct_S_double_f(&s2); +// CHECK-NEXT: return 0; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Generic/StructAndFunction/Instantiation_without_LHS.cbs b/clang/test/BSC/Generic/StructAndFunction/Instantiation_without_LHS.cbs index 406b7df4dc29438be0539e1799a4f385093e293b..d6be59221ebe1e8323fa93984eb80207dc9dcfdd 100644 --- a/clang/test/BSC/Generic/StructAndFunction/Instantiation_without_LHS.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/Instantiation_without_LHS.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/bsc_generic.cbs b/clang/test/BSC/Generic/StructAndFunction/bsc_generic.cbs index 1d9698d03f38b20ccfe76b62098b7cab16606d8a..0462f59597442ca8e474e39fe903ab85868ed391 100644 --- a/clang/test/BSC/Generic/StructAndFunction/bsc_generic.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/bsc_generic.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/call_member_func.cbs b/clang/test/BSC/Generic/StructAndFunction/call_member_func.cbs index 76445ae265b2fe969472a20d1334f68ebbeb52e2..90245dc958c87e6cfda3473fec61d4e10f865840 100644 --- a/clang/test/BSC/Generic/StructAndFunction/call_member_func.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/call_member_func.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics void int::increase(int* this) { diff --git a/clang/test/BSC/Generic/StructAndFunction/cast_in_generic_body.cbs b/clang/test/BSC/Generic/StructAndFunction/cast_in_generic_body.cbs index f5a73fb074cdc89dd79c43ae9353e31798ec2029..39794f324fe4de435a0d497026682245df274980 100644 --- a/clang/test/BSC/Generic/StructAndFunction/cast_in_generic_body.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/cast_in_generic_body.cbs @@ -4,7 +4,7 @@ int foo (T a, T b) { - int x = int(a) + int(b); + int x = int(a) + int(b); // this should report error return x; } diff --git a/clang/test/BSC/Generic/StructAndFunction/function_call.cbs b/clang/test/BSC/Generic/StructAndFunction/function_call.cbs index 26712d67df2f989208ad8d1b7bd3ee3ce2d0fdc3..d65f43e662692019425d617982bba372d173b754 100644 --- a/clang/test/BSC/Generic/StructAndFunction/function_call.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/function_call.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/multi_type_params.cbs b/clang/test/BSC/Generic/StructAndFunction/multi_type_params.cbs index 2493aa70d42bf4efc3bba95205042f69d2a393c6..f9fac69463984316c083783fe7fbc39c0ae627b9 100644 --- a/clang/test/BSC/Generic/StructAndFunction/multi_type_params.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/multi_type_params.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_1.cbs b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_1.cbs index d16e29160479d13ef43bdea1bb36aedbacb42e2e..3935f7fb7458ba59bb9338f8f17ae52a097de9e4 100644 --- a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_1.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_2.cbs b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_2.cbs index 55bdef04c6735e6f1e2f26b555f13b93e998bf8b..87ed845777b9f37a60d112fe2365aacac994403f 100644 --- a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_2.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_2.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics enum sock_handle_type { diff --git a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_3.cbs b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_3.cbs index 4142cd3823f7c867913d574e0be3a10f12b52069..514cc68bb6a864f22c60947d063518f67f12257e 100644 --- a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_3.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_3.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_4.cbs b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_4.cbs index 20b1f495a62b4900707aef2e3ab6e61b49a096c2..e62ef4fd93c9983c53019d2a1b92c99939a8824c 100644 --- a/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_4.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/normal_c_logic_4.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct Runtime { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_Instantiated_struct.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_Instantiated_struct.cbs index 72b25ea1419aa419ad926b6886e23529fb184f57..11584891f98eb635710bba54f8fb5f0087939f05 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_Instantiated_struct.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_Instantiated_struct.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct.cbs index bdad0cf41717dae508fff1bebb6a8deba6bac74d..7525d9656c7393dd9e81cdcaabb66a20d94b45e9 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct1.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct1.cbs index 0ffa6a59754c958a61ae0dc333a13d862cf06c86..5bca01073a700f0c0d223bbcd037f6969f80a63d 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct1.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_struct1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_union.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_union.cbs index ef1005f8db493c4add63ebb6cbb2b1ccf959d79c..177d3a3ad8fd8ded1f46159e4f8dc22e56a6d6d4 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_generic_union.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_generic_union.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics union MyUnion { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_instantiated_struct1.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_instantiated_struct1.cbs index d3f1158ccca70a4ba59f7223914942d5a0e65506..1573aa2bbeca9116c177ae7950965aaed5d1a1e7 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_instantiated_struct1.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_instantiated_struct1.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct PollResult { diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_int.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_int.cbs index 448b8ccee79b5e54dbb91ffcca19bef554be2024..ea88664c16b85a117edd7d200d50ce69817a1540 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_int.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_int.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_long_int.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_long_int.cbs index 4e71a9de9e5544cd187e73099389a41fff11cfe0..470f46bd74c3dcd1e4207191fa1431d4ed6a933d 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_long_int.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_long_int.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_multi.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_multi.cbs index 848ef6d8a7796f6b44180025dbdbda7aaf387684..ad91f79df8d045a29fdc2caeb46f5606c8b56b34 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_multi.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_multi.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_multi_tok.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_multi_tok.cbs index fb6a41647e35b4b8ab73ecd3950561c5e567efdc..2aaff3cee6bc061af5c6c7b17ff56c06191c1348 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_multi_tok.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_multi_tok.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_pointer.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_pointer.cbs index 83a644f23d52adf6017b7f43aece03f0d3340fc9..600a481ac13c3e2e908828940e3d227847f0bcba 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_pointer.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_pointer.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics diff --git a/clang/test/BSC/Generic/StructAndFunction/return_type_struct.cbs b/clang/test/BSC/Generic/StructAndFunction/return_type_struct.cbs index ce94d097bf09df76c0f706534bbbd966b0ac9685..5fc2e1dacb773db8a52ad96f753f2e9756fa7633 100644 --- a/clang/test/BSC/Generic/StructAndFunction/return_type_struct.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/return_type_struct.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/single_type_param.cbs b/clang/test/BSC/Generic/StructAndFunction/single_type_param.cbs index 4a10ea27c2f5baf983e69839b440b7771edadc39..e3f6c7b497015af3c0b885b41201dc1256d114e9 100644 --- a/clang/test/BSC/Generic/StructAndFunction/single_type_param.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/single_type_param.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Generic/StructAndFunction/struct_instantiate_before_define_member_func.cbs b/clang/test/BSC/Generic/StructAndFunction/struct_instantiate_before_define_member_func.cbs index fe61298a3404b111a552ee222e9520ad77c5f094..5be7e02256e623ea502513f80f77b97ecfe17968 100644 --- a/clang/test/BSC/Generic/StructAndFunction/struct_instantiate_before_define_member_func.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/struct_instantiate_before_define_member_func.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics struct MyStruct { diff --git a/clang/test/BSC/Generic/StructAndFunction/struct_template_type_struct.cbs b/clang/test/BSC/Generic/StructAndFunction/struct_template_type_struct.cbs index ebe7b74940ac71fb27a2141f773ce3c861179079..2fea52f752386b8797a21780a3817f20a5809708 100644 --- a/clang/test/BSC/Generic/StructAndFunction/struct_template_type_struct.cbs +++ b/clang/test/BSC/Generic/StructAndFunction/struct_template_type_struct.cbs @@ -1,5 +1,8 @@ // RUN: %clang %s -o %t.output // RUN: %t.output +// RUN: %clang -rewrite-bsc %s -o %t-rw.c +// RUN: %clang %t-rw.c -o %t-rw.output +// RUN: %t-rw.output // expected-no-diagnostics #include diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function.cbs index 7c9ebf78b50cc520bffc1e3f25a49f4a5cf5ce2c..94474340cc04b5e99136ba5fad47a47e5573b450 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function.cbs @@ -15,11 +15,11 @@ int main() { return 0; } -// CHECK: void int_increase(int* this) { -// CHECK-NEXT: *this = *this +1; +// CHECK: void int_increase(int *this) { +// CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: int x = 1; // CHECK-NEXT: int_increase(&x); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow.cbs index 1c43f7a93d58b9ba6f49e0bdbac4d3b1b6b61d54..10fcddf60e1e0e58c098fb51b2f5dadc9f5bef0a 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow.cbs @@ -23,14 +23,14 @@ int main() { return *y - 3; } -// CHECK: void int_increase(int* this) { -// CHECK-NEXT: *this = *this +1; +// CHECK: void int_increase(int *this) { +// CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK:int main() { +// CHECK:int main(void) { // CHECK-NEXT: int x = 1; -// CHECK-NEXT: int* y = &x; +// CHECK-NEXT: int *y = &x; // CHECK-NEXT: int_increase(y); // CHECK-NEXT: int_increase(y); // CHECK-NEXT: printf("%d", *y); diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_const_param.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_const_param.cbs index d8a0a5c9a00406848b5c84543edea205d931d596..ab5f4cee1e0023c4abbb1debf34d071d0c77a3ed 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_const_param.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_const_param.cbs @@ -23,14 +23,14 @@ int main() { return *y - 1; } -// CHECK: void int_increase(const int* this) { +// CHECK: void int_increase(const int *this) { // CHECK-NEXT: return; // CHECK-NEXT:} -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: int x = 1; -// CHECK-NEXT: int* y = &x; +// CHECK-NEXT: int *y = &x; // CHECK-NEXT: int_increase(y); // CHECK-NEXT: int_increase(y); // CHECK-NEXT: printf("%d", *y); diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_vloatile_param.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_vloatile_param.cbs index 46c0d26fce806e92a65f9e710afe8f6580ed5960..4b39afbd848bbd569b3ad568d96d518742e57034 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_vloatile_param.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function_arrow_vloatile_param.cbs @@ -24,14 +24,14 @@ int main() { } -// CHECK: void int_increase(volatile int* this) { +// CHECK: void int_increase(volatile int *this) { // CHECK-NEXT: return; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: int x = 1; -// CHECK-NEXT: int* y = &x; +// CHECK-NEXT: int *y = &x; // CHECK-NEXT: int_increase(y); // CHECK-NEXT: int_increase(y); // CHECK-NEXT: printf("%d", *y); diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function_pointer.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function_pointer.cbs index ab5d07f8abf8b71ecde434714dd791bec15c37be..10f14392d9fde9fbb6ad1793cec1fd4519f8cb07 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function_pointer.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function_pointer.cbs @@ -18,11 +18,11 @@ int main() { return 0; } -// CHECK: void int_increase(int* this) { -// CHECK-NEXT: *this = *this +1; +// CHECK: void int_increase(int *this) { +// CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: int foo = 1; // CHECK-NEXT: void (*fp1)(int *) = int_increase; // CHECK-NEXT: void (*fp2)(int *) = &int_increase; diff --git a/clang/test/BSC/Method/BuiltInType/int_instance_function_with_typedef.cbs b/clang/test/BSC/Method/BuiltInType/int_instance_function_with_typedef.cbs index 36d010ec89d64d0684d0e01206c6b3d8fbc1fb14..31df1437df5f57956dc9e146824b939c4d67b1d9 100644 --- a/clang/test/BSC/Method/BuiltInType/int_instance_function_with_typedef.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_instance_function_with_typedef.cbs @@ -20,14 +20,14 @@ void int::increase_3(int* this) { // CHECK: typedef int bscInt; -// CHECK: void bscInt_increase_1(bscInt* this) { +// CHECK: void bscInt_increase_1(bscInt *this) { // CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK: void int_increase_2(bscInt* this) { +// CHECK: void int_increase_2(bscInt *this) { // CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } -// CHECK: void int_increase_3(int* this) { +// CHECK: void int_increase_3(int *this) { // CHECK-NEXT: *this = *this + 1; // CHECK-NEXT: } \ No newline at end of file diff --git a/clang/test/BSC/Method/BuiltInType/int_static_function_call.cbs b/clang/test/BSC/Method/BuiltInType/int_static_function_call.cbs index 5bc1eb828cd9571c8c8b7fb7b8f7d0a83060b9a1..dd6f0f7e5c63634f3c0fe2337674f64d17230176 100644 --- a/clang/test/BSC/Method/BuiltInType/int_static_function_call.cbs +++ b/clang/test/BSC/Method/BuiltInType/int_static_function_call.cbs @@ -15,11 +15,11 @@ int main() { return a - 2; } -//CHECK: int int_getA() { +//CHECK: int int_getA(void) { //CHECK-NEXT: return 2; //CHECK-NEXT: } -//CHECK: int main() { +//CHECK: int main(void) { //CHECK-NEXT: int_getA(); //CHECK-NEXT: int a = int_getA(); //CHECK-NEXT: return a - 2; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function.cbs b/clang/test/BSC/Method/Enum/enum_instance_function.cbs index 34253a76f3b4ba8a43e087997df4b4bba97f3960..0137a8e4b41d1e21b9cee4d6c0ce89291744ecf8 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function.cbs @@ -20,11 +20,11 @@ int main() { return 0; } -// CHECK: int enum_E_getA(enum E* this) { +// CHECK: int enum_E_getA(enum E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK: enum E foo = X3; // CHECK-NEXT: enum_E_getA(&foo); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_2.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_2.cbs index 6a9513272a9ede2acebb71984a9625df4faeed19..9310735c7bbebe05cf76a33cb3121875843f5eef 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_2.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_2.cbs @@ -23,11 +23,11 @@ int main() { // CHECK-NEXT: X3 // CHECK-NEXT: }; -// CHECK: int enum_E_to_int(enum E* this) { +// CHECK: int enum_E_to_int(enum E *this) { // CHECK-NEXT: return (int)*this; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; // CHECK-NEXT: int x = enum_E_to_int(&foo); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_3.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_3.cbs index c0a42df43b69b1ddc64750444728f91ab17ca111..a76f859641d1e355f5cbcc327d4809665dbfdc94 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_3.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_3.cbs @@ -23,11 +23,11 @@ int main() { // CHECK-NEXT: X3 // CHECK-NEXT: }; -// CHECK: int enum_E_to_int(enum E* this, int a) { +// CHECK: int enum_E_to_int(enum E *this, int a) { // CHECK-NEXT: return a; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; // CHECK-NEXT: int x = enum_E_to_int(&foo, 1); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_arrow.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_arrow.cbs index 00edcfb653e89b620454f41b81e88c1ecfa2ef11..59a060f5ed9a1ef3f51636107ba2447dd11f826a 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_arrow.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_arrow.cbs @@ -24,13 +24,13 @@ int main() { // CHECK-NEXT: X3 // CHECK-NEXT: }; -// CHECK: int enum_E_to_int(enum E* this) { +// CHECK: int enum_E_to_int(enum E *this) { // CHECK-NEXT: return (int)*this; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; -// CHECK-NEXT: enum E* f = &foo; +// CHECK-NEXT: enum E *f = &foo; // CHECK-NEXT: int x = enum_E_to_int(f); // CHECK-NEXT: return 0; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_declaration_only.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_declaration_only.cbs index 3b2b00729951e5d94c1c03e9d3269973468481ee..ca40f10c3f6d6256575c9861cb708308069100ba 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_declaration_only.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_declaration_only.cbs @@ -22,9 +22,9 @@ int main() { // CHECK-NEXT: X4 // CHECK-NEXT: }; -// CHECK: int enum_E_getA(enum E* this); +// CHECK: int enum_E_getA(enum E *this); -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; // CHECK-NEXT: return 0; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_pointer.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_pointer.cbs index 88e4b6caba40e9e18af97d571387919eed6aa845..272a71e2a9320718806f43632040d579d5461605 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_pointer.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_pointer.cbs @@ -28,11 +28,11 @@ int main() { // CHECK-NEXT: X4 // CHECK-NEXT: }; -// CHECK: int enum_E_getA(enum E* this) { +// CHECK: int enum_E_getA(enum E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; // CHECK-NEXT: int (*fp1)(enum E *) = enum_E_getA; // CHECK-NEXT: int (*fp2)(enum E *) = &enum_E_getA; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_same_name.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_same_name.cbs index 79073a4ff5e1de960676c520665f54b8dadf72bd..1eb62f50467e6576b9d0db5f9c0296d8757aeb0a 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_same_name.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_same_name.cbs @@ -33,15 +33,15 @@ int main() { // CHECK-NEXT: X4 // CHECK-NEXT: }; -// CHECK: int enum_E_getA(enum E* this) { +// CHECK: int enum_E_getA(enum E *this) { // CHECK-NEXT: return X3; // CHECK-NEXT: } -// CHECK: int int_getA(int* this) { +// CHECK: int int_getA(int *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: int a = 1; // CHECK-NEXT: int_getA(&a); // CHECK-NEXT: enum E foo = X3; diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_typedef.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_typedef.cbs index ae051b4d4cbd6dca1a5c8558c10561d40a3e2568..d13c324b989b16b3322687a7abf2b3d8664ea109 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_typedef.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_typedef.cbs @@ -42,19 +42,19 @@ int main() { // CHECK-NEXT: }; // CHECK: typedef enum E F; -// CHECK-NEXT: int F_getA(enum E* this) { +// CHECK-NEXT: int F_getA(enum E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int F_getB(F* this) { +// CHECK: int F_getB(F *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int enum_E_getC(F* this) { +// CHECK: int enum_E_getC(F *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: enum E foo = X3; // CHECK-NEXT: F_getA(&foo); // CHECK-NEXT: F_getB(&foo); diff --git a/clang/test/BSC/Method/Enum/enum_instance_function_with_typedef.cbs b/clang/test/BSC/Method/Enum/enum_instance_function_with_typedef.cbs index c917fa2f90f709a73d0c348de139ec5edd888fc6..3c303c9100858cebe9ce3a6515e37377921962b7 100644 --- a/clang/test/BSC/Method/Enum/enum_instance_function_with_typedef.cbs +++ b/clang/test/BSC/Method/Enum/enum_instance_function_with_typedef.cbs @@ -26,14 +26,14 @@ int enum E::getX4_3(enum E* this) { // CHECK-NEXT: X4 // CHECK-NEXT: }E; -// CHECK: int E_getX4_1(E* this) { +// CHECK: int E_getX4_1(E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int E_getX4_2(enum E* this) { +// CHECK: int E_getX4_2(enum E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } -// CHECK: int enum_E_getX4_3(enum E* this) { +// CHECK: int enum_E_getX4_3(enum E *this) { // CHECK-NEXT: return X4; // CHECK-NEXT: } \ No newline at end of file diff --git a/clang/test/BSC/Method/Struct/struct_instance_function.cbs b/clang/test/BSC/Method/Struct/struct_instance_function.cbs index 5cf498dc354146983b727ea086287aaa3ac5aa0f..e621889be2a4eff64bb0d3898d9ae744359b7b39 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function.cbs @@ -24,12 +24,12 @@ int main() { // CHECK-NEXT: int a; // CHECK-NEXT: }; -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 1}; // CHECK-NEXT: struct_Foo_getA(&foo); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_chaining.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_chaining.cbs index c0da01a73f42b46e9cb439a4b916be12e8e71caa..1c711a92e390519b5dd332ac02265cdd6fe0fc95 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_chaining.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_chaining.cbs @@ -29,18 +29,19 @@ int main() { // CHECK: struct queue { // CHECK-NEXT: }; -// CHECK: void struct_queue_isEmpty(struct queue* this){} +// CHECK: void struct_queue_isEmpty(struct queue *this) { +// CHECK-NEXT: } // CHECK: struct Scheduler { -// CHECK-NEXT: struct queue* que; +// CHECK-NEXT: struct queue *que; // CHECK: }; -// CHECK: void struct_Scheduler_run(struct Scheduler* this) { +// CHECK: void struct_Scheduler_run(struct Scheduler *this) { // CHECK-NEXT: struct_queue_isEmpty(this->que); // CHECK-NEXT: struct_queue_isEmpty(&(*this->que)); // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Scheduler s; // CHECK-NEXT: struct_Scheduler_run(&s); // CHECK-NEXT: return 0; diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_declaration.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_declaration.cbs index 2d743b3263b9e14113ce18242aa15ee007fd48dd..6b9af623d77f95c97d9c2a8223c44256bf9d3778 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_declaration.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_declaration.cbs @@ -25,14 +25,14 @@ int struct Foo::getA(struct Foo* this) { // CHECK-NEXT: int a; // CHECK-NEXT: }; -// CHECK: int struct_Foo_getA(struct Foo* this); +// CHECK: int struct_Foo_getA(struct Foo *this); -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 1}; // CHECK-NEXT: struct_Foo_getA(&foo); // CHECK-NEXT: return 0; // CHECK-NEXT: } -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } \ No newline at end of file diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_multi_declaration.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_multi_declaration.cbs index 452355f740434ac4c197bdbe3671bc3a63f2a679..d10d30d0923b3f2cba05b85e1a78988e113cfc51 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_multi_declaration.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_multi_declaration.cbs @@ -26,15 +26,15 @@ int struct Foo::getA(struct Foo* this) { // CHECK-NEXT: int a; // CHECK-NEXT: }; -// CHECK: int struct_Foo_getA(struct Foo* this); -// CHECK-NEXT: int struct_Foo_getA(struct Foo* this); +// CHECK: int struct_Foo_getA(struct Foo *this); +// CHECK-NEXT: int struct_Foo_getA(struct Foo *this); -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 1}; // CHECK-NEXT: struct_Foo_getA(&foo); // CHECK-NEXT: return 0; // CHECK-NEXT: } -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_parens.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_parens.cbs index a79d2def80bdaa7a330b1046f0df85e63631b036..2d9fd19dbc5f42ebbc649fb6ca8f8793c41c360d 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_parens.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_parens.cbs @@ -21,12 +21,15 @@ int main() {return 0;} // CHECK: typedef struct _queue { // CHECK-NEXT: }queue; -// CHECK: queue* queue_reverse(queue* this) { +// CHECK: queue *queue_reverse(queue *this) { // CHECK-NEXT: return this; // CHECK-NEXT: } -// CHECK: void destroyQueue(queue** q) { +// CHECK: void destroyQueue(queue **q) { // CHECK-NEXT: queue_reverse((*q)); // CHECK-NEXT: queue_reverse(&(**q)); // CHECK-NEXT: } -// CHECK-NEXT: int main() {return 0;} + +// CHECK: int main(void) { +// CHECK-NEXT: return 0; +// CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_pointer.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_pointer.cbs index 5ac275fcc4f1744ed181d6a5feb57cd45a22b945..4cc3ea4c2a95b5ccf8f685445275242faa93a8bc 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_pointer.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_pointer.cbs @@ -23,12 +23,12 @@ int main() { return 0; } -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: struct Foo foo = {.a = 1}; // CHECK-NEXT: int (*fp1)(struct Foo *) = struct_Foo_getA; // CHECK-NEXT: int (*fp2)(struct Foo *) = &struct_Foo_getA; diff --git a/clang/test/BSC/Method/Struct/struct_instance_function_with_typedef.cbs b/clang/test/BSC/Method/Struct/struct_instance_function_with_typedef.cbs index c12ed6e0ec2f4dd1f73b9bdd6ff3afd18ed25cf7..a043834535c3962e50db81489f441770722b5240 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_function_with_typedef.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_function_with_typedef.cbs @@ -21,14 +21,14 @@ int struct Foo::getA(struct Foo* this) { return this->a; } -// CHECK: int Foo_getB(Foo* this) { +// CHECK: int Foo_getB(Foo *this) { // CHECK-NEXT: return this->b; // CHECK-NEXT: } -// CHECK: int Foo_getAPlusB(struct Foo* this) { +// CHECK: int Foo_getAPlusB(struct Foo *this) { // CHECK-NEXT: return this->a + this->b; // CHECK-NEXT: } -// CHECK: int struct_Foo_getA(struct Foo* this) { +// CHECK: int struct_Foo_getA(struct Foo *this) { // CHECK-NEXT: return this->a; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Struct/struct_instance_recursive_call.cbs b/clang/test/BSC/Method/Struct/struct_instance_recursive_call.cbs index 946bb824ea6a4974f21b79e956c843dd75a16b11..b3dc3bed32940cb782ff3696ab6d054d574c6765 100644 --- a/clang/test/BSC/Method/Struct/struct_instance_recursive_call.cbs +++ b/clang/test/BSC/Method/Struct/struct_instance_recursive_call.cbs @@ -15,7 +15,7 @@ queue* queue::reverse(queue* this) { // CHECK: typedef struct _queue { // CHECK-NEXT: }queue; -// CHECK: queue* queue_reverse(queue* this) { +// CHECK: queue *queue_reverse(queue *this) { // CHECK-NEXT: queue_reverse(this); // CHECK-NEXT: return this; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Struct/struct_static_function_call.cbs b/clang/test/BSC/Method/Struct/struct_static_function_call.cbs index f240296ff205404f0164bf4bbe4e128e81e9545c..79a2ecc748bf1650fda347fd008ce2e3d093fb29 100644 --- a/clang/test/BSC/Method/Struct/struct_static_function_call.cbs +++ b/clang/test/BSC/Method/Struct/struct_static_function_call.cbs @@ -22,6 +22,6 @@ int main() { return a - 1; } -// CHECK: int struct_Foo_getA() { +// CHECK: int struct_Foo_getA(void) { // CHECK: struct_Foo_getA(); // CHECK-NEXT: int a = struct_Foo_getA(); \ No newline at end of file diff --git a/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs b/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs index 6ed620a857c96eb099de947c3c9192d674463b22..f8e8af3129ee12fef05f03dd2ead362474dc3b7c 100644 --- a/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs +++ b/clang/test/BSC/Method/Struct/struct_toplevel_func.cbs @@ -21,5 +21,5 @@ int main() { return increase(); } -// CHECK: int struct_F_increase() { +// CHECK: int struct_F_increase(void) { \ No newline at end of file diff --git a/clang/test/BSC/Method/Union/union_instance_function_declaration.cbs b/clang/test/BSC/Method/Union/union_instance_function_declaration.cbs index ad55c19810b9ad0a37d6cf5dcb3af2ea32b2ee5c..5b1277c6947da19df89aef4cb5c516fd10349bac 100644 --- a/clang/test/BSC/Method/Union/union_instance_function_declaration.cbs +++ b/clang/test/BSC/Method/Union/union_instance_function_declaration.cbs @@ -23,6 +23,6 @@ int union SimpleUnion::getA(union SimpleUnion * this) { return this->ui; } -// CHECK: int union_SimpleUnion_getA(union SimpleUnion* this); +// CHECK: int union_SimpleUnion_getA(union SimpleUnion *this); // CHECK: union_SimpleUnion_getA(&u); -// CHECK: int union_SimpleUnion_getA(union SimpleUnion * this) { +// CHECK: int union_SimpleUnion_getA(union SimpleUnion *this) { diff --git a/clang/test/BSC/Method/Union/union_instance_function_multi_declaration.cbs b/clang/test/BSC/Method/Union/union_instance_function_multi_declaration.cbs index 2ec56274507583a4ab02c1760e1d19f8d1495dfb..40e394a255cce89c12309b8dbf016a7e89454b33 100644 --- a/clang/test/BSC/Method/Union/union_instance_function_multi_declaration.cbs +++ b/clang/test/BSC/Method/Union/union_instance_function_multi_declaration.cbs @@ -24,15 +24,15 @@ int union SimpleUnion::getA(union SimpleUnion * this) { return this->ui; } -// CHECK: int union_SimpleUnion_getA(union SimpleUnion* this); -// CHECK-NEXT: int union_SimpleUnion_getA(union SimpleUnion* this); +// CHECK: int union_SimpleUnion_getA(union SimpleUnion *this); +// CHECK-NEXT: int union_SimpleUnion_getA(union SimpleUnion *this); -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: union SimpleUnion u = {.ui = 1}; // CHECK-NEXT: union_SimpleUnion_getA(&u); // CHECK-NEXT: return 0; // CHECK-NEXT: } -// CHECK: int union_SimpleUnion_getA(union SimpleUnion * this) { +// CHECK: int union_SimpleUnion_getA(union SimpleUnion *this) { // CHECK-NEXT: return this->ui; // CHECK-NEXT: } diff --git a/clang/test/BSC/Method/Union/union_instance_function_pointer.cbs b/clang/test/BSC/Method/Union/union_instance_function_pointer.cbs index 08c3bda4542979db2ad65684ef5cc8359e446a2f..fa8dfa977985cec453c56c43111a3b3b3b7e2b3a 100644 --- a/clang/test/BSC/Method/Union/union_instance_function_pointer.cbs +++ b/clang/test/BSC/Method/Union/union_instance_function_pointer.cbs @@ -24,11 +24,11 @@ int main() { return 0; } -// CHECK: int union_SimpleUnion_getA(union SimpleUnion * this) { +// CHECK: int union_SimpleUnion_getA(union SimpleUnion *this) { // CHECK-NEXT: return this->ui; // CHECK-NEXT: } -// CHECK: int main() { +// CHECK: int main(void) { // CHECK-NEXT: union SimpleUnion foo = {.ui = 1}; // CHECK-NEXT: int (*fp1)(union SimpleUnion *) = union_SimpleUnion_getA; // CHECK-NEXT: int (*fp2)(union SimpleUnion *) = &union_SimpleUnion_getA; diff --git a/clang/test/BSC/Method/ambiguous_1.cbs b/clang/test/BSC/Method/ambiguous_1.cbs index c5d5e44939513ce07c1a008c4ac5c464d34a1db9..5e88419d9f35cdf63e6060414792a8f3f5021566 100644 --- a/clang/test/BSC/Method/ambiguous_1.cbs +++ b/clang/test/BSC/Method/ambiguous_1.cbs @@ -20,14 +20,14 @@ int main() { return 0; }; -// CHECK: long int_getA1() { +// CHECK: long int_getA1(void) { // CHECK-NEXT: return 1; -// CHECK-NEXT: }; +// CHECK-NEXT: } -// CHECK: unsigned int_getA2() { +// CHECK: unsigned int int_getA2(void) { // CHECK-NEXT: return 1; -// CHECK-NEXT: }; +// CHECK-NEXT: } -// CHECK: short int_getA3() { +// CHECK: short int_getA3(void) { // CHECK-NEXT: return 1; -// CHECK-NEXT: }; +// CHECK-NEXT: } diff --git a/clang/test/BSC/ParamCheck/this_param_with_const.cbs b/clang/test/BSC/ParamCheck/this_param_with_const.cbs index e12583f8894be5916d283103c3632e4029c20028..5a146a807dca2e35cdbebc2221fb74df43b3c661 100644 --- a/clang/test/BSC/ParamCheck/this_param_with_const.cbs +++ b/clang/test/BSC/ParamCheck/this_param_with_const.cbs @@ -52,10 +52,10 @@ int main() { return 0; } -// CHECK: int main() { -// CHECK-NEXT: struct Foo foo ={.a = 42}; +// CHECK: int main(void) { +// CHECK-NEXT: struct Foo foo = {.a = 42}; // CHECK-NEXT: struct_Foo_getA(&foo); -// CHECK-NEXT: enum E e= X3; +// CHECK-NEXT: enum E e = X3; // CHECK-NEXT: enum_E_getA(&e); // CHECK-NEXT: union SimpleUnion u = {.ui = 1}; // CHECK-NEXT: union_SimpleUnion_getA(&u);