diff --git a/clang/lib/DPCT/AnalysisInfo.cpp b/clang/lib/DPCT/AnalysisInfo.cpp index 25fc08edd13d..c49c5653b66b 100644 --- a/clang/lib/DPCT/AnalysisInfo.cpp +++ b/clang/lib/DPCT/AnalysisInfo.cpp @@ -7525,7 +7525,7 @@ void FreeQueriesInfo::printImmediateText(llvm::raw_ostream &OS, const Node *S, if (!DFI) return; auto Index = DpctGlobalInfo::getCudaKernelDimDFIIndexThenInc(); - DpctGlobalInfo::insertCudaKernelDimDFIMap(Index, DFI); + DpctGlobalInfo::insertCudaKernelDimDFIMap(Index, std::move(DFI)); printFreeQueriesFunctionName( OS, K, "{{NEEDREPLACEG" + std::to_string(Index) + "}}"); } else { diff --git a/clang/lib/DPCT/DPCT.cpp b/clang/lib/DPCT/DPCT.cpp index 93db02b7b0dd..85ce5abc7f91 100644 --- a/clang/lib/DPCT/DPCT.cpp +++ b/clang/lib/DPCT/DPCT.cpp @@ -1029,9 +1029,14 @@ int runDPCT(int argc, const char **argv) { if (SourceCode.starts_with(OptionStr)) { QueryAPIMappingOpt += " (with the option"; while (SourceCode.consume_front(OptionStr)) { - auto Option = SourceCode.substr(0, SourceCode.find_first_of('\n')); - Option = Option.trim(' '); - SourceCode = SourceCode.substr(SourceCode.find_first_of('\n') + 1); + auto Pos = SourceCode.find('\n'); + StringRef Option; + if (Pos == StringRef::npos) { + std::swap(Option, SourceCode); + } else { + Option = SourceCode.substr(0, Pos).trim(' '); + SourceCode = SourceCode.substr(Pos + 1); + } QueryAPIMappingOpt += " "; QueryAPIMappingOpt += Option.str(); if (Option.starts_with("--use-dpcpp-extensions")) { diff --git a/clang/lib/DPCT/RuleInfra/CallExprRewriter.h b/clang/lib/DPCT/RuleInfra/CallExprRewriter.h index b8d859a0e357..764be7bb542f 100644 --- a/clang/lib/DPCT/RuleInfra/CallExprRewriter.h +++ b/clang/lib/DPCT/RuleInfra/CallExprRewriter.h @@ -1264,7 +1264,8 @@ class MultiStmtsPrinter : public MultiStmtsPrinter { MultiStmtsPrinter(std::string Indent, std::string NL, bool IsInMacroDef, FirstPrinter &&First, RestPrinter &&...Rest) - : Base(Indent, NL, IsInMacroDef, std::move(Rest)...), + : Base(std::move(Indent), std::move(NL), IsInMacroDef, + std::move(Rest)...), First(std::move(First)) {} template void print(StreamT &Stream) const { diff --git a/clang/lib/DPCT/RulesAsm/Parser/AsmParser.cpp b/clang/lib/DPCT/RulesAsm/Parser/AsmParser.cpp index 60e49a9c0c56..cc90057d4000 100644 --- a/clang/lib/DPCT/RulesAsm/Parser/AsmParser.cpp +++ b/clang/lib/DPCT/RulesAsm/Parser/AsmParser.cpp @@ -385,8 +385,8 @@ InlineAsmStmtResult InlineAsmParser::ParseInstruction() { Types.push_back(Context.getBuiltinType(InlineAsmBuiltinType::u32)); } - return ::new (Context) InlineAsmInstruction(Opcode, StateSpaces, Attrs, Types, - Out.get(), Pred.get(), Ops); + return ::new (Context) InlineAsmInstruction( + Opcode, std::move(StateSpaces), Attrs, Types, Out.get(), Pred.get(), Ops); } InlineAsmExprResult InlineAsmParser::ParseExpression() { diff --git a/clang/lib/DPCT/RulesLang/RulesLang.cpp b/clang/lib/DPCT/RulesLang/RulesLang.cpp index 859bf795c812..685f6a9abcfe 100644 --- a/clang/lib/DPCT/RulesLang/RulesLang.cpp +++ b/clang/lib/DPCT/RulesLang/RulesLang.cpp @@ -4910,10 +4910,12 @@ void KernelCallRule::runRule( const auto *LaunchKernelCall = getNodeAsType(Result, "launch"); if (!LaunchKernelCall) { LaunchKernelCall = getNodeAsType(Result, "launchUsed"); + if(!LaunchKernelCall) + return; IsAssigned = true; } auto FD = LaunchKernelCall->getDirectCallee(); - if (!LaunchKernelCall || !FD) + if (!FD) return; std::string FuncName = FD->getNameAsString(); if (FuncName == "cudaLaunchHostFunc") { diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5ec1fdd18dcc..44473197c89a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1822,7 +1822,11 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { llvm::Triple PrefixTriple{ClangNameParts.TargetPrefix}; if (PrefixTriple.getArch() == llvm::Triple::UnknownArch || PrefixTriple.isOSUnknown()) +#ifdef SYCLomatic_CUSTOMIZATION + Triple = std::move(PrefixTriple); +#else Triple = PrefixTriple; +#endif } // Otherwise, use the real triple as used by the driver. @@ -1876,7 +1880,11 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { } // Try loading .cfg and return if we find a match. +#ifdef SYCLomatic_CUSTOMIZATION + if (findTripleConfigFile(ExpCtx, CfgFilePath, std::move(Triple), ".cfg")) +#else if (findTripleConfigFile(ExpCtx, CfgFilePath, Triple, ".cfg")) +#endif return readConfigFile(CfgFilePath, ExpCtx); // If we were unable to find a config file deduced from executable name, diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 67ed7733ece4..9981068f0e99 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -1672,7 +1672,11 @@ static auto computeNewlines(const AnnotatedLine &Line, if (Line.startsWith(TT_NamespaceRBrace)) { if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never) Newlines = 1; +#ifdef SYCLomatic_CUSTOMIZATION + else if (PreviousLine && !PreviousLine->startsWith(TT_NamespaceRBrace)) +#else else if (!PreviousLine->startsWith(TT_NamespaceRBrace)) +#endif Newlines = std::max(Newlines, 2u); } } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e141278256ad..5adbbfb7eea7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -18951,8 +18951,13 @@ void Sema::ActOnLastBitfield(SourceLocation DeclLoc, // All conditions are met. Add a new bitfield to the tail end of ivars. llvm::APInt Zero(Context.getTypeSize(Context.IntTy), 0); Expr * BW = IntegerLiteral::Create(Context, Zero, Context.IntTy, DeclLoc); +#ifdef SYCLomatic_CUSTOMIZATION + Expr *BitWidth = + ConstantExpr::Create(Context, BW, APValue(llvm::APSInt(std::move(Zero)))); +#else Expr *BitWidth = ConstantExpr::Create(Context, BW, APValue(llvm::APSInt(Zero))); +#endif Ivar = ObjCIvarDecl::Create( Context, cast(CurContext), DeclLoc, DeclLoc, nullptr, diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 17593368ddf9..547e6322a946 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1668,8 +1668,11 @@ Decl *TemplateDeclInstantiator::VisitDecompositionDecl(DecompositionDecl *D) { if (!NewDD || NewDD->isInvalidDecl()) for (auto *NewBD : NewBindings) NewBD->setInvalidDecl(); - +#ifdef SYCLomatic_CUSTOMIZATION + if (NewDD && OldResolvedPack) { +#else if (OldResolvedPack) { +#endif // Mark the holding vars (if any) in the pack as instantiated since // they are created implicitly. auto Bindings = NewDD->bindings(); diff --git a/clang/lib/Tooling/Core/UnifiedPath.cpp b/clang/lib/Tooling/Core/UnifiedPath.cpp index 21c20ec44f6c..b24754f74172 100644 --- a/clang/lib/Tooling/Core/UnifiedPath.cpp +++ b/clang/lib/Tooling/Core/UnifiedPath.cpp @@ -54,30 +54,17 @@ void UnifiedPath::makeCanonical(const std::string &CWD) { llvm::SmallString<512> RealPath; // We need make sure the input `Path` for llvm::sys::fs::real_path is // exsiting, or else the behavior of real_path() is unexpected. - if (llvm::sys::fs::exists(Path)) { - llvm::sys::fs::real_path(Path, RealPath, true); - } else { - llvm::SmallString<512> Suffix; - if (llvm::sys::path::has_filename(Path)) { - Suffix = llvm::sys::path::filename(Path).str(); - llvm::sys::path::remove_filename(Path); - } - while (!llvm::sys::fs::exists(Path)) { - if (!llvm::sys::path::has_parent_path(Path)) { - assert(0 && "no real directory found"); - return; - } - llvm::sys::path::reverse_iterator RI = - llvm::sys::path::rbegin(llvm::StringRef(Path)); - llvm::SmallString<512> SuffixTemp(*RI); - llvm::sys::path::append(SuffixTemp, llvm::sys::path::Style::native, - Suffix); - Suffix = SuffixTemp; - Path = llvm::SmallString<512>(llvm::sys::path::parent_path(Path).str()); + llvm::StringRef ParentPath = Path; + while (!llvm::sys::fs::exists(ParentPath)) { + ParentPath = llvm::sys::path::parent_path(ParentPath); + if (ParentPath.empty()) { + assert(0 && "no real directory found"); + return; } - llvm::sys::fs::real_path(Path, RealPath, true); - llvm::sys::path::append(RealPath, llvm::sys::path::Style::native, Suffix); } + llvm::sys::fs::real_path(ParentPath, RealPath, true); + if (auto Suffix = Path.substr(ParentPath.size()); !Suffix.empty()) + llvm::sys::path::append(RealPath, llvm::sys::path::Style::native, Suffix); _CanonicalPath = RealPath.str(); #if defined(_WIN32) if (_CanonicalPath.size() >= 3 &&