[PATCH] D36051: [clang-tidy] List the checkers with autofix
JonasToth added a comment. would be a classification of checks in general interesting? i could think of "quality", some checks might be heuristic, some might be new and have some bugs, and some might catch everything correct and handle it perfectly. So checks could have 2 categories: -> autofixing/warning -> always correct/heuristic/unsure This would maybe improve acceptance, since you know what you get. If you are not interested in toying around, just activate the "always correct" stuff, and you wont accidentially break your code. https://reviews.llvm.org/D36051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36057: Use class to pass information about executable name
sepavloff created this revision. Herald added subscribers: srhines, klimek. Information about clang executable name component, such as target and driver mode, was passes in std::pair. With this change it is passed in special structure. It improves readability and makes access to this information more convenient. NFC. https://reviews.llvm.org/D36057 Files: include/clang/Driver/Driver.h include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp lib/Tooling/Tooling.cpp tools/driver/driver.cpp Index: tools/driver/driver.cpp === --- tools/driver/driver.cpp +++ tools/driver/driver.cpp @@ -206,23 +206,19 @@ extern int cc1as_main(ArrayRef Argv, const char *Argv0, void *MainAddr); -static void insertTargetAndModeArgs(StringRef Target, StringRef Mode, +static void insertTargetAndModeArgs(const ParsedClangName &NameParts, SmallVectorImpl &ArgVector, std::set &SavedStrings) { - if (!Mode.empty()) { + if (!NameParts.ModeSuffix.empty()) { // Add the mode flag to the arguments. -auto it = ArgVector.begin(); -if (it != ArgVector.end()) - ++it; -ArgVector.insert(it, GetStableCStr(SavedStrings, Mode)); +ArgVector.insert(ArgVector.end(), + GetStableCStr(SavedStrings, NameParts.ModeSuffix)); } - if (!Target.empty()) { -auto it = ArgVector.begin(); -if (it != ArgVector.end()) - ++it; -const char *arr[] = {"-target", GetStableCStr(SavedStrings, Target)}; -ArgVector.insert(it, std::begin(arr), std::end(arr)); + if (NameParts.TargetIsValid) { +const char *arr[] = {"-target", GetStableCStr(SavedStrings, + NameParts.TargetPrefix)}; +ArgVector.insert(ArgVector.end(), std::begin(arr), std::end(arr)); } } @@ -330,9 +326,7 @@ } llvm::InitializeAllTargets(); - std::string ProgName = argv[0]; - std::pair TargetAndMode = - ToolChain::getTargetAndModeFromProgramName(ProgName); + auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(argv[0]); llvm::BumpPtrAllocator A; llvm::StringSaver Saver(A); @@ -345,7 +339,7 @@ // Finally, our -cc1 tools don't care which tokenization mode we use because // response files written by clang will tokenize the same way in either mode. bool ClangCLMode = false; - if (TargetAndMode.second == "--driver-mode=cl" || + if (TargetAndMode.ModeSuffix == "--driver-mode=cl" || std::find_if(argv.begin(), argv.end(), [](const char *F) { return F && strcmp(F, "--driver-mode=cl") == 0; }) != argv.end()) { @@ -454,9 +448,9 @@ Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags); SetInstallDir(argv, TheDriver, CanonicalPrefixes); + TheDriver.setTargetAndMode(TargetAndMode); - insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv, - SavedStrings); + insertTargetAndModeArgs(TargetAndMode, argv, SavedStrings); SetBackdoorDriverOutputsFromEnvVars(TheDriver); Index: lib/Tooling/Tooling.cpp === --- lib/Tooling/Tooling.cpp +++ lib/Tooling/Tooling.cpp @@ -190,11 +190,12 @@ } auto TargetMode = clang::driver::ToolChain::getTargetAndModeFromProgramName(InvokedAs); -if (!AlreadyHasMode && !TargetMode.second.empty()) { - CommandLine.insert(++CommandLine.begin(), TargetMode.second); +if (!AlreadyHasMode && !TargetMode.ModeSuffix.empty()) { + CommandLine.insert(++CommandLine.begin(), TargetMode.ModeSuffix); } -if (!AlreadyHasTarget && !TargetMode.first.empty()) { - CommandLine.insert(++CommandLine.begin(), {"-target", TargetMode.first}); +if (!AlreadyHasTarget && TargetMode.TargetIsValid) { + CommandLine.insert(++CommandLine.begin(), {"-target", + TargetMode.TargetPrefix}); } } } Index: lib/Driver/ToolChain.cpp === --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -176,28 +176,25 @@ } } // anonymous namespace -std::pair +ParsedClangName ToolChain::getTargetAndModeFromProgramName(StringRef PN) { std::string ProgName = normalizeProgramName(PN); const DriverSuffix *DS = parseDriverSuffix(ProgName); if (!DS) -return std::make_pair("", ""); +return ParsedClangName(); std::string ModeFlag = DS->ModeFlag == nullptr ? "" : DS->ModeFlag; std::string::size_type LastComponent = ProgName.rfind('-', ProgName.size() - strlen(DS->Suffix)); if (LastComponent == std::string::npos) -return std::make_pair("", ModeFlag); +return ParsedClangName(ModeFlag); // Infer target from the prefix. StringRef Prefix(ProgName); Prefix = Prefix.slice(0, LastComponent); std::string Ig
[PATCH] D35903: [x86][inline-asm]Allow a pack of Control Regs to be properly picked
This revision was automatically updated to reflect the committed changes. Closed by commit rL309508: [x86][inline-asm]Allow a pack of Control Regs to be properly picked (authored by coby). Changed prior to commit: https://reviews.llvm.org/D35903?vs=108317&id=108825#toc Repository: rL LLVM https://reviews.llvm.org/D35903 Files: cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/test/CodeGen/ms-inline-asm.c Index: cfe/trunk/lib/Basic/Targets/X86.cpp === --- cfe/trunk/lib/Basic/Targets/X86.cpp +++ cfe/trunk/lib/Basic/Targets/X86.cpp @@ -58,6 +58,7 @@ "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23", "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31", "k0","k1", "k2","k3","k4","k5","k6", "k7", +"cr0", "cr2", "cr3", "cr4", "cr8", }; const TargetInfo::AddlRegName AddlRegNames[] = { Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -627,6 +627,17 @@ // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) } +void t44() { + // CHECK-LABEL: define void @t44 + __asm { +mov cr0, eax +mov cr2, ebx +mov cr3, ecx +mov cr4, edx + } + // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", "~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"() +} + void dot_operator(){ // CHECK-LABEL: define void @dot_operator __asm { mov eax, 3[ebx]A.b} Index: cfe/trunk/lib/Basic/Targets/X86.cpp === --- cfe/trunk/lib/Basic/Targets/X86.cpp +++ cfe/trunk/lib/Basic/Targets/X86.cpp @@ -58,6 +58,7 @@ "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23", "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31", "k0","k1", "k2","k3","k4","k5","k6", "k7", +"cr0", "cr2", "cr3", "cr4", "cr8", }; const TargetInfo::AddlRegName AddlRegNames[] = { Index: cfe/trunk/test/CodeGen/ms-inline-asm.c === --- cfe/trunk/test/CodeGen/ms-inline-asm.c +++ cfe/trunk/test/CodeGen/ms-inline-asm.c @@ -627,6 +627,17 @@ // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) } +void t44() { + // CHECK-LABEL: define void @t44 + __asm { +mov cr0, eax +mov cr2, ebx +mov cr3, ecx +mov cr4, edx + } + // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", "~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"() +} + void dot_operator(){ // CHECK-LABEL: define void @dot_operator __asm { mov eax, 3[ebx]A.b} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36051: [clang-tidy] List the checkers with autofix
xazax.hun added a comment. Maybe instead of a separate list, having this information like yes/no column in a table in the original is more user-friendly. https://reviews.llvm.org/D36051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309510 - [x86][inline-asm][ms-compat] legalize the use of "jc/jz short "
Author: coby Date: Sun Jul 30 04:13:46 2017 New Revision: 309510 URL: http://llvm.org/viewvc/llvm-project?rev=309510&view=rev Log: [x86][inline-asm][ms-compat] legalize the use of "jc/jz short " MS ignores the keyword "short" when used after a jc/jz instruction, LLVM ought to do the same. llvm: D35892 Differential Revision: https://reviews.llvm.org/D35893 Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=309510&r1=309509&r2=309510&view=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Sun Jul 30 04:13:46 2017 @@ -704,10 +704,12 @@ void label5() { void label6(){ __asm { jmp short label + jc short label + jz short label label: } // CHECK-LABEL: define void @label6 - // CHECK: call void asm sideeffect inteldialect "jmp {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:", "~{dirflag},~{fpsr},~{flags}"() + // CHECK: jmp {{.*}}__MSASMLABEL_.${:uid}__label\0A\09jc {{.*}}__MSASMLABEL_.${:uid}__label\0A\09jz {{.*}}__MSASMLABEL_.${:uid}__label\0A\09{{.*}}__MSASMLABEL_.${:uid}__label:" } // Don't include mxcsr in the clobber list. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309496 - Improve readability of CXX method overrides list
Author: lll Date: Sat Jul 29 13:42:58 2017 New Revision: 309496 URL: http://llvm.org/viewvc/llvm-project?rev=309496&view=rev Log: Improve readability of CXX method overrides list Summary: Separate CXX method overrides list entries with commas. Reviewers: lhames Reviewed By: lhames Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D35800 Modified: cfe/trunk/lib/AST/ASTDumper.cpp Modified: cfe/trunk/lib/AST/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=309496&r1=309495&r2=309496&view=diff == --- cfe/trunk/lib/AST/ASTDumper.cpp (original) +++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jul 29 13:42:58 2017 @@ -1184,7 +1184,7 @@ void ASTDumper::VisitFunctionDecl(const I != E; ++I) dumpCXXCtorInitializer(*I); - if (const CXXMethodDecl *MD = dyn_cast(D)) + if (const CXXMethodDecl *MD = dyn_cast(D)) { if (MD->size_overridden_methods() != 0) { auto dumpOverride = [=](const CXXMethodDecl *D) { @@ -1199,11 +1199,14 @@ void ASTDumper::VisitFunctionDecl(const dumpOverride(*FirstOverrideItr); for (const auto *Override : llvm::make_range(FirstOverrideItr + 1, -MD->end_overridden_methods())) +MD->end_overridden_methods())) { + OS << ", "; dumpOverride(Override); +} OS << " ]"; }); } + } if (D->doesThisDeclarationHaveABody()) dumpStmt(D->getBody()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309508 - [x86][inline-asm]Allow a pack of Control Regs to be properly picked
Author: coby Date: Sun Jul 30 03:19:10 2017 New Revision: 309508 URL: http://llvm.org/viewvc/llvm-project?rev=309508&view=rev Log: [x86][inline-asm]Allow a pack of Control Regs to be properly picked Allows the incorporation of legit (x86) Control Regs within inline asm stataements Differential Revision: https://reviews.llvm.org/D35903 Modified: cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/test/CodeGen/ms-inline-asm.c Modified: cfe/trunk/lib/Basic/Targets/X86.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=309508&r1=309507&r2=309508&view=diff == --- cfe/trunk/lib/Basic/Targets/X86.cpp (original) +++ cfe/trunk/lib/Basic/Targets/X86.cpp Sun Jul 30 03:19:10 2017 @@ -58,6 +58,7 @@ static const char *const GCCRegNames[] = "zmm18", "zmm19", "zmm20", "zmm21", "zmm22", "zmm23", "zmm24", "zmm25", "zmm26", "zmm27", "zmm28", "zmm29", "zmm30", "zmm31", "k0","k1", "k2","k3","k4","k5","k6", "k7", +"cr0", "cr2", "cr3", "cr4", "cr8", }; const TargetInfo::AddlRegName AddlRegNames[] = { Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=309508&r1=309507&r2=309508&view=diff == --- cfe/trunk/test/CodeGen/ms-inline-asm.c (original) +++ cfe/trunk/test/CodeGen/ms-inline-asm.c Sun Jul 30 03:19:10 2017 @@ -627,6 +627,17 @@ void t43() { // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) } +void t44() { + // CHECK-LABEL: define void @t44 + __asm { +mov cr0, eax +mov cr2, ebx +mov cr3, ecx +mov cr4, edx + } + // CHECK: call void asm sideeffect inteldialect "mov cr0, eax\0A\09mov cr2, ebx\0A\09mov cr3, ecx\0A\09mov cr4, edx", "~{cr0},~{cr2},~{cr3},~{cr4},~{dirflag},~{fpsr},~{flags}"() +} + void dot_operator(){ // CHECK-LABEL: define void @dot_operator __asm { mov eax, 3[ebx]A.b} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36051: [clang-tidy] List the checkers with autofix
sylvestre.ledru added a comment. Good ideas guys. I will try to update list.rst to a table with the extra information. https://reviews.llvm.org/D36051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36051: [clang-tidy] List the checkers with autofix
Eugene.Zelenko added a comment. I think will be good idea to do this in -list-checks too. https://reviews.llvm.org/D36051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34182: [analyzer] Performance optimizations for the CloneChecker
teemperor updated this revision to Diff 108837. teemperor added a comment. Herald added a subscriber: klimek. - Updated according to Artem's comments. https://reviews.llvm.org/D34182 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/Format/UnwrappedLineParser.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp === --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -81,11 +81,11 @@ // because reportSuspiciousClones() wants to search them for errors. std::vector AllCloneGroups; - Detector.findClones(AllCloneGroups, - FilenamePatternConstraint(IgnoredFilesPattern), - RecursiveCloneTypeIIConstraint(), - MinComplexityConstraint(MinComplexity), - MinGroupSizeConstraint(2), OnlyLargestCloneConstraint()); + Detector.findClones( + AllCloneGroups, FilenamePatternConstraint(IgnoredFilesPattern), + RecursiveCloneTypeIIHashConstraint(), MinGroupSizeConstraint(2), + MinComplexityConstraint(MinComplexity), + RecursiveCloneTypeIIVerifyConstraint(), OnlyLargestCloneConstraint()); if (ReportSuspiciousClones) reportSuspiciousClones(BR, Mgr, AllCloneGroups); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -494,8 +494,8 @@ if (MunchSemi && FormatTok->Tok.is(tok::semi)) nextToken(); - Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; Line->Level = InitialLevel; + Line->MatchingOpeningBlockLineIndex = OpeningLineIndex; if (OpeningLineIndex != UnwrappedLine::kInvalidIndex) { // Update the opening line to add the forward reference as well (*CurrentLines)[OpeningLineIndex].MatchingOpeningBlockLineIndex = Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -216,9 +216,18 @@ return HashCode; } -size_t RecursiveCloneTypeIIConstraint::saveHash( -const Stmt *S, const Decl *D, -std::vector> &StmtsByHash) { +/// Generates and saves a hash code for the given Stmt. +/// \param S The given Stmt. +/// \param D The Decl containing S. +/// \param StmtsByHash Output parameter that will contain the hash codes for +///each StmtSequence in the given Stmt. +/// \return The hash code of the given Stmt. +/// +/// If the given Stmt is a CompoundStmt, this method will also generate +/// hashes for all possible StmtSequences in the children of this Stmt. +static size_t +saveHash(const Stmt *S, const Decl *D, + std::vector> &StmtsByHash) { llvm::MD5 Hash; ASTContext &Context = D->getASTContext(); @@ -320,6 +329,14 @@ void RecursiveCloneTypeIIConstraint::constrain( std::vector &Sequences) { + RecursiveCloneTypeIIHashConstraint Hash; + Hash.constrain(Sequences); + RecursiveCloneTypeIIVerifyConstraint Verify; + Verify.constrain(Sequences); +} + +void RecursiveCloneTypeIIHashConstraint::constrain( +std::vector &Sequences) { // FIXME: Maybe we can do this in-place and don't need this additional vector. std::vector Result; @@ -359,8 +376,7 @@ for (; i < StmtsByHash.size(); ++i) { // A different hash value means we have reached the end of the sequence. -if (PrototypeHash != StmtsByHash[i].first || -!areSequencesClones(StmtsByHash[i].second, Current.second)) { +if (PrototypeHash != StmtsByHash[i].first) { // The current sequence could be the start of a new CloneGroup. So we // decrement i so that we visit it again in the outer loop. // Note: i can never be 0 at this point because we are just comparing @@ -383,6 +399,14 @@ Sequences = Result; } +void RecursiveCloneTypeIIVerifyConstraint::constrain( +std::vector &Sequences) { + CloneConstraint::splitCloneGroups( + Sequences, [](const StmtSequence &A, const StmtSequence &B) { +return areSequencesClones(A, B); + }); +} + size_t MinComplexityConstraint::calculateStmtComplexity( const StmtSequence &Seq, const std::string &ParentMacroStack) { if (Seq.empty()) Index: include/clang/Analysis/CloneDetection.h === --- include/clang/Analysis/CloneDetection.h +++ include/clang/Analysis/CloneDetection.h @@ -442,22 +442,25 @@ std::function Compare); }; -/// Searches all children of the given clones for type II clones (i.e. they are -/// identical in every aspect beside the used variable names). -class RecursiveCloneTypeIIConstraint { - - /// Generates and saves a hash code for the given Stmt. - /// \param S The given Stmt. - /// \param D
[PATCH] D34182: [analyzer] Performance optimizations for the CloneChecker
teemperor updated this revision to Diff 108839. teemperor added a comment. (Fixed diff) https://reviews.llvm.org/D34182 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp === --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -81,11 +81,11 @@ // because reportSuspiciousClones() wants to search them for errors. std::vector AllCloneGroups; - Detector.findClones(AllCloneGroups, - FilenamePatternConstraint(IgnoredFilesPattern), - RecursiveCloneTypeIIConstraint(), - MinComplexityConstraint(MinComplexity), - MinGroupSizeConstraint(2), OnlyLargestCloneConstraint()); + Detector.findClones( + AllCloneGroups, FilenamePatternConstraint(IgnoredFilesPattern), + RecursiveCloneTypeIIHashConstraint(), MinGroupSizeConstraint(2), + MinComplexityConstraint(MinComplexity), + RecursiveCloneTypeIIVerifyConstraint(), OnlyLargestCloneConstraint()); if (ReportSuspiciousClones) reportSuspiciousClones(BR, Mgr, AllCloneGroups); Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -216,9 +216,18 @@ return HashCode; } -size_t RecursiveCloneTypeIIConstraint::saveHash( -const Stmt *S, const Decl *D, -std::vector> &StmtsByHash) { +/// Generates and saves a hash code for the given Stmt. +/// \param S The given Stmt. +/// \param D The Decl containing S. +/// \param StmtsByHash Output parameter that will contain the hash codes for +///each StmtSequence in the given Stmt. +/// \return The hash code of the given Stmt. +/// +/// If the given Stmt is a CompoundStmt, this method will also generate +/// hashes for all possible StmtSequences in the children of this Stmt. +static size_t +saveHash(const Stmt *S, const Decl *D, + std::vector> &StmtsByHash) { llvm::MD5 Hash; ASTContext &Context = D->getASTContext(); @@ -320,6 +329,14 @@ void RecursiveCloneTypeIIConstraint::constrain( std::vector &Sequences) { + RecursiveCloneTypeIIHashConstraint Hash; + Hash.constrain(Sequences); + RecursiveCloneTypeIIVerifyConstraint Verify; + Verify.constrain(Sequences); +} + +void RecursiveCloneTypeIIHashConstraint::constrain( +std::vector &Sequences) { // FIXME: Maybe we can do this in-place and don't need this additional vector. std::vector Result; @@ -359,8 +376,7 @@ for (; i < StmtsByHash.size(); ++i) { // A different hash value means we have reached the end of the sequence. -if (PrototypeHash != StmtsByHash[i].first || -!areSequencesClones(StmtsByHash[i].second, Current.second)) { +if (PrototypeHash != StmtsByHash[i].first) { // The current sequence could be the start of a new CloneGroup. So we // decrement i so that we visit it again in the outer loop. // Note: i can never be 0 at this point because we are just comparing @@ -383,6 +399,14 @@ Sequences = Result; } +void RecursiveCloneTypeIIVerifyConstraint::constrain( +std::vector &Sequences) { + CloneConstraint::splitCloneGroups( + Sequences, [](const StmtSequence &A, const StmtSequence &B) { +return areSequencesClones(A, B); + }); +} + size_t MinComplexityConstraint::calculateStmtComplexity( const StmtSequence &Seq, const std::string &ParentMacroStack) { if (Seq.empty()) Index: include/clang/Analysis/CloneDetection.h === --- include/clang/Analysis/CloneDetection.h +++ include/clang/Analysis/CloneDetection.h @@ -442,22 +442,25 @@ std::function Compare); }; -/// Searches all children of the given clones for type II clones (i.e. they are -/// identical in every aspect beside the used variable names). -class RecursiveCloneTypeIIConstraint { - - /// Generates and saves a hash code for the given Stmt. - /// \param S The given Stmt. - /// \param D The Decl containing S. - /// \param StmtsByHash Output parameter that will contain the hash codes for - ///each StmtSequence in the given Stmt. - /// \return The hash code of the given Stmt. - /// - /// If the given Stmt is a CompoundStmt, this method will also generate - /// hashes for all possible StmtSequences in the children of this Stmt. - size_t saveHash(const Stmt *S, const Decl *D, - std::vector> &StmtsByHash); +/// This constraint moves clones into clone groups of type II via hashing. +/// +/// Clones with different hash values are moved into separate clone groups. +/// Collisions are possible, and this constraint does nothing to address this +/// them. Add the slo
[libcxxabi] r309520 - [demangler] Fix some bugs in r309340 found by oss-fuzz
Author: epilk Date: Sun Jul 30 13:09:55 2017 New Revision: 309520 URL: http://llvm.org/viewvc/llvm-project?rev=309520&view=rev Log: [demangler] Fix some bugs in r309340 found by oss-fuzz Modified: libcxxabi/trunk/src/cxa_demangle.cpp libcxxabi/trunk/test/test_demangle.pass.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=309520&r1=309519&r2=309520&view=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Jul 30 13:09:55 2017 @@ -2871,7 +2871,7 @@ parse_new_expr(const char* first, const return first; t = t1; } -if (first_expr_in_list < db.names.size()) +if (first_expr_in_list > db.names.size()) return first; ExprList = db.popTrailingNodeArray(first_expr_in_list); ++t; @@ -2892,7 +2892,7 @@ parse_new_expr(const char* first, const return first; t = t1; } -if (init_list_begin < db.names.size()) +if (init_list_begin > db.names.size()) return first; init_list = db.popTrailingNodeArray(init_list_begin); } @@ -2924,7 +2924,7 @@ parse_conversion_expr(const char* first, db.try_to_parse_template_args = try_to_parse_template_args; if (t != first+2 && t != last) { -size_t ExprList_begin = db.names.size(); +size_t expr_list_begin = db.names.size(); if (*t != '_') { const char* t1 = parse_expression(t, last, db); @@ -2949,13 +2949,14 @@ parse_conversion_expr(const char* first, } ++t; } -if (db.names.size() < ExprList_begin) +if (db.names.size() < expr_list_begin || +type_begin > expr_list_begin) return first; NodeArray expressions = db.makeNodeArray( -db.names.begin() + (long)ExprList_begin, db.names.end()); +db.names.begin() + (long)expr_list_begin, db.names.end()); NodeArray types = db.makeNodeArray( db.names.begin() + (long)type_begin, -db.names.begin() + (long)ExprList_begin); +db.names.begin() + (long)expr_list_begin); auto* conv_expr = db.make( types, expressions); db.names.erase( @@ -3057,7 +3058,7 @@ parse_function_type(const char* first, c return first; t = t1; } -if (db.names.empty()) +if (db.names.empty() || params_begin > db.names.size()) return first; Node* fty = db.make( ret_type, db.popTrailingNodeArray(params_begin)); @@ -5140,6 +5141,8 @@ parse_template_args(const char* first, c } t = t1; } +if (begin_idx > db.names.size()) +return first; first = t + 1; TemplateParams* tp = db.make( db.popTrailingNodeArray(begin_idx)); @@ -5207,6 +5210,8 @@ parse_nested_name(const char* first, con t1 = parse_substitution(t0, last, db); if (t1 != t0 && t1 != last) { +if (db.names.size() < 2) +return first; auto name = db.names.back(); db.names.pop_back(); if (db.names.back()->K != Node::KEmptyName) @@ -5229,6 +5234,8 @@ parse_nested_name(const char* first, con t1 = parse_template_param(t0, last, db); if (t1 != t0 && t1 != last) { +if (db.names.size() < 2) +return first; auto name = db.names.back(); db.names.pop_back(); if (db.names.back()->K != Node::KEmptyName) @@ -5249,6 +5256,8 @@ parse_nested_name(const char* first, con t1 = parse_decltype(t0, last, db); if (t1 != t0 && t1 != last) { +if (db.names.size() < 2) +return first; auto name = db.names.back(); db.names.pop_back(); if (db.names.back()->K != Node::KEmptyName) @@ -5267,6 +5276,8 @@ parse_nested_name(const char* first, con t1 = parse_template_args(t0, last, db); if (t1 != t0 && t1 != last) { +if (db.names.size() < 2) +return first; auto name = db.names.back(); db.names.pop_back(); db.name
r309522 - Fix a typo.
Author: brad Date: Sun Jul 30 13:33:06 2017 New Revision: 309522 URL: http://llvm.org/viewvc/llvm-project?rev=309522&view=rev Log: Fix a typo. Modified: cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=309522&r1=309521&r2=309522&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Sun Jul 30 13:33:06 2017 @@ -946,7 +946,7 @@ // AARCH64-OPENBSD:#define __INT_LEAST32_FMTd__ "d" // AARCH64-OPENBSD:#define __INT_LEAST32_FMTi__ "i" // AARCH64-OPENBSD:#define __INT_LEAST32_MAX__ 2147483647 -// AARCH64-OPENSD:#define __INT_LEAST32_TYPE__ int +// AARCH64-OPENBSD:#define __INT_LEAST32_TYPE__ int // AARCH64-OPENBSD:#define __INT_LEAST64_FMTd__ "ld" // AARCH64-OPENBSD:#define __INT_LEAST64_FMTi__ "li" // AARCH64-OPENBSD:#define __INT_LEAST64_MAX__ 9223372036854775807L ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309523 - Also pass -pie back to the linker when linking on OpenBSD.
Author: brad Date: Sun Jul 30 14:13:59 2017 New Revision: 309523 URL: http://llvm.org/viewvc/llvm-project?rev=309523&view=rev Log: Also pass -pie back to the linker when linking on OpenBSD. Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp cfe/trunk/test/Driver/openbsd.c Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=309523&r1=309522&r2=309523&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Sun Jul 30 14:13:59 2017 @@ -133,6 +133,8 @@ void openbsd::Linker::ConstructJob(Compi } } + if (Args.hasArg(options::OPT_pie)) +CmdArgs.push_back("-pie"); if (Args.hasArg(options::OPT_nopie)) CmdArgs.push_back("-nopie"); Modified: cfe/trunk/test/Driver/openbsd.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=309523&r1=309522&r2=309523&view=diff == --- cfe/trunk/test/Driver/openbsd.c (original) +++ cfe/trunk/test/Driver/openbsd.c Sun Jul 30 14:13:59 2017 @@ -77,7 +77,9 @@ // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s -// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 2>&1 \ +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pie %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-PIE-FLAG %s +// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-STATIC-PIE %s @@ -93,6 +95,7 @@ // RUN: | FileCheck -check-prefix=CHECK-NOPIE %s // CHECK-PIE: "{{.*}}crt0.o" // CHECK-PIE-NOT: "-nopie" +// CHECK-PIE-FLAG: "-pie" // CHECK-STATIC-PIE: "{{.*}}rcrt0.o" // CHECK-STATIC-PIE-NOT: "-nopie" // CHECK-NOPIE: "-nopie" "{{.*}}crt0.o" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35986: [clangd] Add ':' to completion trigger characters.
krasimir accepted this revision. krasimir added a comment. This revision is now accepted and ready to land. Looks good! https://reviews.llvm.org/D35986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r309527 - Mark LWG 2961 as complete
Author: ericwf Date: Sun Jul 30 15:16:30 2017 New Revision: 309527 URL: http://llvm.org/viewvc/llvm-project?rev=309527&view=rev Log: Mark LWG 2961 as complete Modified: libcxx/trunk/www/cxx2a_status.html Modified: libcxx/trunk/www/cxx2a_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=309527&r1=309526&r2=309527&view=diff == --- libcxx/trunk/www/cxx2a_status.html (original) +++ libcxx/trunk/www/cxx2a_status.html Sun Jul 30 15:16:30 2017 @@ -78,7 +78,7 @@ http://wg21.link/LWG2937";>2937Is equivalent("existing_thing", "not_existing_thing") an errorTorontoComplete http://wg21.link/LWG2940";>2940result_of specification also needs a little cleanupToronto http://wg21.link/LWG2942";>2942LWG 2873's resolution missed weak_ptr::owner_beforeToronto - http://wg21.link/LWG2954";>2954Specialization of the convenience variable templates should be prohibitedToronto + http://wg21.link/LWG2954";>2954Specialization of the convenience variable templates should be prohibitedTorontoComplete http://wg21.link/LWG2961";>2961Bad postcondition for set_default_resourceToronto http://wg21.link/LWG2966";>2966Incomplete resolution of US 74TorontoNothing to do http://wg21.link/LWG2974";>2974Diagnose out of bounds tuple_element/variant_alternativeTorontoComplete ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
EricWF added a comment. @rsmith Ping. This should be super simple to review. https://reviews.llvm.org/D35297 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r309528 - Mark LWG 2942 as complete
Author: ericwf Date: Sun Jul 30 15:28:08 2017 New Revision: 309528 URL: http://llvm.org/viewvc/llvm-project?rev=309528&view=rev Log: Mark LWG 2942 as complete Modified: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp libcxx/trunk/www/cxx2a_status.html Modified: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp?rev=309528&r1=309527&r2=309528&view=diff == --- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp Sun Jul 30 15:28:08 2017 @@ -29,6 +29,5 @@ int main() assert(!w2.owner_before(p1)); assert(w1.owner_before(p3) || w3.owner_before(p1)); assert(w3.owner_before(p1) == w3.owner_before(p2)); -// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted -LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(p2)); +ASSERT_NOEXCEPT(w1.owner_before(p2)); } Modified: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp?rev=309528&r1=309527&r2=309528&view=diff == --- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp Sun Jul 30 15:28:08 2017 @@ -29,6 +29,5 @@ int main() assert(!w2.owner_before(w1)); assert(w1.owner_before(w3) || w3.owner_before(w1)); assert(w3.owner_before(w1) == w3.owner_before(w2)); -// change to 'ASSERT_NOEXCEPT' when LWG2942 is adopted -LIBCPP_ASSERT_NOEXCEPT(w1.owner_before(w2)); +ASSERT_NOEXCEPT(w1.owner_before(w2)); } Modified: libcxx/trunk/www/cxx2a_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=309528&r1=309527&r2=309528&view=diff == --- libcxx/trunk/www/cxx2a_status.html (original) +++ libcxx/trunk/www/cxx2a_status.html Sun Jul 30 15:28:08 2017 @@ -77,7 +77,7 @@ http://wg21.link/LWG2932";>2932Constraints on parallel algorithm implementations are underspecifiedToronto http://wg21.link/LWG2937";>2937Is equivalent("existing_thing", "not_existing_thing") an errorTorontoComplete http://wg21.link/LWG2940";>2940result_of specification also needs a little cleanupToronto - http://wg21.link/LWG2942";>2942LWG 2873's resolution missed weak_ptr::owner_beforeToronto + http://wg21.link/LWG2942";>2942LWG 2873's resolution missed weak_ptr::owner_beforeTorontoComplete http://wg21.link/LWG2954";>2954Specialization of the convenience variable templates should be prohibitedTorontoComplete http://wg21.link/LWG2961";>2961Bad postcondition for set_default_resourceToronto http://wg21.link/LWG2966";>2966Incomplete resolution of US 74TorontoNothing to do ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
rsmith added inline comments. Comment at: lib/Sema/SemaLookup.cpp:229 assert(!Redeclaration && "cannot do redeclaration operator lookup"); -IDNS = Decl::IDNS_NonMemberOperator; +IDNS = Decl::IDNS_NonMemberOperator | Decl::IDNS_LocalExtern; break; This isn't right; `IDNS_LocalExtern` finds local extern declarations in the namespace scope enclosing their declaration, so this will incorrectly allow: ``` struct A {} a; void f() { extern bool operator==(A, A); } bool b = a == a; ``` As far as I can see, the problem is that the constructor of `FindLocalExternScope` only enables finding local extern declarations if we're also looking for `IDNS_Ordinary`; the right fix would presumably be for it to also check for `IDNS_NonMemberOperator`. https://reviews.llvm.org/D35297 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
EricWF updated this revision to Diff 108845. EricWF added a comment. - Address issues in inline comments. The patch should be ready to go now :-) https://reviews.llvm.org/D35297 Files: lib/Sema/SemaLookup.cpp test/SemaCXX/overloaded-operator.cpp Index: test/SemaCXX/overloaded-operator.cpp === --- test/SemaCXX/overloaded-operator.cpp +++ test/SemaCXX/overloaded-operator.cpp @@ -531,3 +531,22 @@ b3 / 0; // expected-note {{in instantiation of}} expected-error {{invalid operands to}} } } + + +namespace PR27027 { + template void operator+(T, T) = delete; // expected-note 4 {{candidate}} + template void operator+(T) = delete; // expected-note 4 {{candidate}} + + struct A {} a_global; + void f() { +A a; ++a; // expected-error {{overload resolution selected deleted operator '+'}} +a + a; // expected-error {{overload resolution selected deleted operator '+'}} +bool operator+(A); +extern bool operator+(A, A); ++a; // OK +a + a; + } + bool test_global_1 = +a_global; // expected-error {{overload resolution selected deleted operator '+'}} + bool test_global_2 = a_global + a_global; // expected-error {{overload resolution selected deleted operator '+'}} +} Index: lib/Sema/SemaLookup.cpp === --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -1031,7 +1031,8 @@ FindLocalExternScope(LookupResult &R) : R(R), OldFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_LocalExtern) { -R.setFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_Ordinary); +R.setFindLocalExtern(R.getIdentifierNamespace() & + (Decl::IDNS_Ordinary | Decl::IDNS_NonMemberOperator)); } void restore() { R.setFindLocalExtern(OldFindLocalExtern); Index: test/SemaCXX/overloaded-operator.cpp === --- test/SemaCXX/overloaded-operator.cpp +++ test/SemaCXX/overloaded-operator.cpp @@ -531,3 +531,22 @@ b3 / 0; // expected-note {{in instantiation of}} expected-error {{invalid operands to}} } } + + +namespace PR27027 { + template void operator+(T, T) = delete; // expected-note 4 {{candidate}} + template void operator+(T) = delete; // expected-note 4 {{candidate}} + + struct A {} a_global; + void f() { +A a; ++a; // expected-error {{overload resolution selected deleted operator '+'}} +a + a; // expected-error {{overload resolution selected deleted operator '+'}} +bool operator+(A); +extern bool operator+(A, A); ++a; // OK +a + a; + } + bool test_global_1 = +a_global; // expected-error {{overload resolution selected deleted operator '+'}} + bool test_global_2 = a_global + a_global; // expected-error {{overload resolution selected deleted operator '+'}} +} Index: lib/Sema/SemaLookup.cpp === --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -1031,7 +1031,8 @@ FindLocalExternScope(LookupResult &R) : R(R), OldFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_LocalExtern) { -R.setFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_Ordinary); +R.setFindLocalExtern(R.getIdentifierNamespace() & + (Decl::IDNS_Ordinary | Decl::IDNS_NonMemberOperator)); } void restore() { R.setFindLocalExtern(OldFindLocalExtern); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM, thanks! https://reviews.llvm.org/D35297 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309530 - [Sema] Fix operator lookup to consider local extern declarations.
Author: ericwf Date: Sun Jul 30 17:24:28 2017 New Revision: 309530 URL: http://llvm.org/viewvc/llvm-project?rev=309530&view=rev Log: [Sema] Fix operator lookup to consider local extern declarations. Summary: Previously Clang was not considering operator declarations that occur at function scope. This is incorrect according to [over.match.oper]p3 > The set of non-member candidates is the result of the unqualified lookup of > operator@ in the context of the expression according to the usual rules for > name lookup in unqualified function calls. This patch changes operator name lookup to consider block scope declarations. This patch fixes PR27027. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D35297 Modified: cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/test/SemaCXX/overloaded-operator.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=309530&r1=309529&r2=309530&view=diff == --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) +++ cfe/trunk/lib/Sema/SemaLookup.cpp Sun Jul 30 17:24:28 2017 @@ -1031,7 +1031,8 @@ struct FindLocalExternScope { FindLocalExternScope(LookupResult &R) : R(R), OldFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_LocalExtern) { -R.setFindLocalExtern(R.getIdentifierNamespace() & Decl::IDNS_Ordinary); +R.setFindLocalExtern(R.getIdentifierNamespace() & + (Decl::IDNS_Ordinary | Decl::IDNS_NonMemberOperator)); } void restore() { R.setFindLocalExtern(OldFindLocalExtern); Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=309530&r1=309529&r2=309530&view=diff == --- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original) +++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Sun Jul 30 17:24:28 2017 @@ -531,3 +531,22 @@ namespace NoADLForMemberOnlyOperators { b3 / 0; // expected-note {{in instantiation of}} expected-error {{invalid operands to}} } } + + +namespace PR27027 { + template void operator+(T, T) = delete; // expected-note 4 {{candidate}} + template void operator+(T) = delete; // expected-note 4 {{candidate}} + + struct A {} a_global; + void f() { +A a; ++a; // expected-error {{overload resolution selected deleted operator '+'}} +a + a; // expected-error {{overload resolution selected deleted operator '+'}} +bool operator+(A); +extern bool operator+(A, A); ++a; // OK +a + a; + } + bool test_global_1 = +a_global; // expected-error {{overload resolution selected deleted operator '+'}} + bool test_global_2 = a_global + a_global; // expected-error {{overload resolution selected deleted operator '+'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35297: [Sema] Fix operator lookup to consider local extern declarations.
EricWF added a comment. @rsmith Should this be considered for the `5.0` release? https://reviews.llvm.org/D35297 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r307357 - cmath: Support clang's -fdelayed-template-parsing
This particular issue isn't clang-specific; it affects MSVC as well, and I believe clang's -fdelayed-template-parsing attempts to model MSVC's behavior. See https://godbolt.org/g/xrbpgX (code in https://reviews.llvm.org/P8012). On 7/6/17, 10:13 PM, "cfe-commits on behalf of Duncan P. N. Exon Smith via cfe-commits" wrote: Author: dexonsmith Date: Thu Jul 6 22:13:36 2017 New Revision: 307357 URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D307357-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=o6R6kWs06fy4y3yudHS7ouD3qLli5cEEup3WfWjRcMs&s=PioNWTk_Um87Of5MvbiR2ZwZ-4q9vzPpxtXF32ZfQBg&e= Log: cmath: Support clang's -fdelayed-template-parsing r283051 added some functions to cmath (in namespace std) that have the same name as functions in math.h (in the global namespace). Clang's limited support for `-fdelayed-template-parsing` chokes on this. Rename the ones in `cmath` and their uses in `complex` and the test. rdar://problem/32848355 Added: libcxx/trunk/test/libcxx/numerics/c.math/fdelayed-template-parsing.sh.cpp Modified: libcxx/trunk/include/cmath libcxx/trunk/include/complex libcxx/trunk/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp libcxx/trunk/utils/libcxx/test/config.py Modified: libcxx/trunk/include/cmath URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_cmath-3Frev-3D307357-26r1-3D307356-26r2-3D307357-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=o6R6kWs06fy4y3yudHS7ouD3qLli5cEEup3WfWjRcMs&s=NWs6PACrKef_QFgyQ2KM9eE9Dz8Dbr07BUJQjrFIi4I&e= == --- libcxx/trunk/include/cmath (original) +++ libcxx/trunk/include/cmath Thu Jul 6 22:13:36 2017 @@ -549,7 +549,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __ template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isnan) return __builtin_isnan(__lcpp_x); @@ -561,7 +561,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT { return isnan(__lcpp_x); } @@ -569,7 +569,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isinf) return __builtin_isinf(__lcpp_x); @@ -581,7 +581,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT { return isinf(__lcpp_x); } @@ -589,7 +589,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isfinite) return __builtin_isfinite(__lcpp_x); @@ -601,7 +601,7 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEP template _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR typename enable_if::value, bool>::type -__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT +__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT { return isfinite(__lcpp_x); } Modified: libcxx/trunk/include/complex URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_complex-3Frev-3D307357-26r1-3D307356-26r2-3D307357-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=o6R6kWs06fy4y3yudHS7ouD3qLli5cEEup3WfWjRcMs&s=gSQEaw0DpuyIxhF_QJ1_qCCBABy3sLNJa23DDPj6A-Q&e= == --- libcxx/trunk/include/complex (original) +++ libcxx/trunk/include/complex Thu Jul 6 22:13:36 2017 @@ -599,39 +599,39 @@ operator*(const complex<_Tp>& __z, const _Tp __bc = __b * __c; _Tp __x = __ac - __bd; _Tp __y = __ad + __bc; -if (__libcpp_isnan(__x) && __libcpp_isnan(__y)) +if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y)) { bool __recalc = false; -if (__libcpp_isinf(__a) || __libcpp_isinf(__b)) +if (__
[PATCH] D18174: Fix libcxx build on musl
raj.khem updated this revision to Diff 108853. raj.khem edited the summary of this revision. Herald added a reviewer: EricWF. https://reviews.llvm.org/D18174 Files: include/__mutex_base Index: include/__mutex_base === --- include/__mutex_base +++ include/__mutex_base @@ -48,7 +48,10 @@ public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_CXX03_LANG -constexpr mutex() = default; +#ifdef __GLIBC__ +constexpr +#endif +mutex() = default; #else mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} #endif @@ -296,7 +299,10 @@ public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_CXX03_LANG -constexpr condition_variable() _NOEXCEPT = default; +#ifdef __GLIBC__ +constexpr +#endif +condition_variable() _NOEXCEPT = default; #else condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} #endif Index: include/__mutex_base === --- include/__mutex_base +++ include/__mutex_base @@ -48,7 +48,10 @@ public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_CXX03_LANG -constexpr mutex() = default; +#ifdef __GLIBC__ +constexpr +#endif +mutex() = default; #else mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} #endif @@ -296,7 +299,10 @@ public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_CXX03_LANG -constexpr condition_variable() _NOEXCEPT = default; +#ifdef __GLIBC__ +constexpr +#endif +condition_variable() _NOEXCEPT = default; #else condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36070: [coroutines] Evaluate the operand of void `co_return` expressions.
EricWF created this revision. Previously Clang incorrectly ignored the expression of a void `co_return`. This patch addresses that bug. I'm not quite sure if I got the code-gen right, but this patch is at least a start. https://reviews.llvm.org/D36070 Files: lib/CodeGen/CGCoroutine.cpp test/CodeGenCoroutines/coro-ret-void.cpp Index: test/CodeGenCoroutines/coro-ret-void.cpp === --- test/CodeGenCoroutines/coro-ret-void.cpp +++ test/CodeGenCoroutines/coro-ret-void.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -munwind-tables -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s #include "Inputs/coroutine.h" @@ -21,6 +21,20 @@ // CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"* // CHECK: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* %__promise) +struct A { + A(); + ~A(); +}; + +coro1 f2() { + co_return(void) A{}; +} + +// CHECK-LABEL: define void @_Z2f2v( +// CHECK: call void @_ZN1AC1Ev(%struct.A* %[[AVar:.*]]) +// CHECK-NEXT: call void @_ZN1AD1Ev(%struct.A* %[[AVar]]) +// CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* + struct coro2 { struct promise_type { coro2 get_return_object(); Index: lib/CodeGen/CGCoroutine.cpp === --- lib/CodeGen/CGCoroutine.cpp +++ lib/CodeGen/CGCoroutine.cpp @@ -234,6 +234,13 @@ void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) { ++CurCoro.Data->CoreturnCount; + const Expr *RV = S.getOperand(); + if (RV && RV->getType()->isVoidType()) { +// Make sure to evaluate the expression of a co_return with a void +// expression for side effects. +RunCleanupsScope cleanupScope(*this); +EmitIgnoredExpr(RV); + } EmitStmt(S.getPromiseCall()); EmitBranchThroughCleanup(CurCoro.Data->FinalJD); } Index: test/CodeGenCoroutines/coro-ret-void.cpp === --- test/CodeGenCoroutines/coro-ret-void.cpp +++ test/CodeGenCoroutines/coro-ret-void.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -munwind-tables -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s #include "Inputs/coroutine.h" @@ -21,6 +21,20 @@ // CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"* // CHECK: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* %__promise) +struct A { + A(); + ~A(); +}; + +coro1 f2() { + co_return(void) A{}; +} + +// CHECK-LABEL: define void @_Z2f2v( +// CHECK: call void @_ZN1AC1Ev(%struct.A* %[[AVar:.*]]) +// CHECK-NEXT: call void @_ZN1AD1Ev(%struct.A* %[[AVar]]) +// CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* + struct coro2 { struct promise_type { coro2 get_return_object(); Index: lib/CodeGen/CGCoroutine.cpp === --- lib/CodeGen/CGCoroutine.cpp +++ lib/CodeGen/CGCoroutine.cpp @@ -234,6 +234,13 @@ void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) { ++CurCoro.Data->CoreturnCount; + const Expr *RV = S.getOperand(); + if (RV && RV->getType()->isVoidType()) { +// Make sure to evaluate the expression of a co_return with a void +// expression for side effects. +RunCleanupsScope cleanupScope(*this); +EmitIgnoredExpr(RV); + } EmitStmt(S.getPromiseCall()); EmitBranchThroughCleanup(CurCoro.Data->FinalJD); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18174: Fix libcxx build on musl
EricWF requested changes to this revision. EricWF added a comment. This revision now requires changes to proceed. This patch is not OK, since it affects way more that just MUSL libc. Also can you please provide a reduced reproducer as two why `pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER` is not a constant expression with MUSL? Comment at: include/__mutex_base:51 #ifndef _LIBCPP_CXX03_LANG -constexpr mutex() = default; +#ifdef __GLIBC__ +constexpr Limiting `constexpr` to GLIBC implementations only is incorrect; you want to exclude MUSL. Also MUSL is wrong for not allowing `pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER` to be a constant expression, and MUSL should fix that. https://reviews.llvm.org/D18174 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36070: [coroutines] Evaluate the operand of void `co_return` expressions.
GorNishanov accepted this revision. GorNishanov added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D36070 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18174: Fix libcxx build on musl
smeenai added inline comments. Comment at: include/__mutex_base:51 #ifndef _LIBCPP_CXX03_LANG -constexpr mutex() = default; +#ifdef __GLIBC__ +constexpr EricWF wrote: > Limiting `constexpr` to GLIBC implementations only is incorrect; you want to > exclude MUSL. > > Also MUSL is wrong for not allowing `pthread_mutex_t mut = > PTHREAD_MUTEX_INITIALIZER` to be a constant expression, and MUSL should fix > that. I've used `__builtin_constant_p` to wok around a similarly non-conforming `PTHREAD_MUTEX_INITIALIZER` (from pthread-win32, which defines it to be `(void *)-1`): see the last part of https://stackoverflow.com/a/10376574/382079. It's a terrible hack, but it works. https://reviews.llvm.org/D18174 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D18174: Fix libcxx build on musl
raj.khem added a comment. @EricWF you are right. I have made the changes accordingly. This patch can be ignored. https://reviews.llvm.org/D18174 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines
djasper added a comment. Could you explain this in more detail? Which subtraction is underflowing? Why can't we just add a ternary expression there to handle the case? https://reviews.llvm.org/D36019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines
jtbandes added a comment. I can add some clarity but I can't claim to fully understand the whole program flow here yet, so my explanation is probably insufficient. The overflow (underflow? but I think that means something specific to FP) is on line formerly-650: `EscapedNewlineColumn - Offset - 1`. This expression computes number of spaces required to place the `\` in the correct position. When EscapedNewlineColumn was 0, the Offset would end up being large enough for the computation on line 650 to roll over to a large value. Here is where my understanding is a bit fuzzier, and perhaps I should spend more time reading the code. When the alignment style is **not** `ENAS_DontAlign`, the function `alignEscapedNewlines()` adjusts the EscapedNewlineColumn of each line, **including blank lines**, which seems to result in EscapedNewlineColumn being always sufficiently large to do this subtraction without wrapping. (The approach of immediately `return;`ing for `ENAS_DontAlign`, committed in https://reviews.llvm.org/rL302428, was causing the EscapedNewlineColumn to be 0 here.) It is a possibility to simply check the EscapedNewlineColumn and do something different inside of appendNewlineText(). I'd be interested to hear your thoughts on which approach is better. Perhaps if I study the code some more there will a nice simplification will reveal itself to me... https://reviews.llvm.org/D36019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines
jtbandes updated this revision to Diff 108860. jtbandes added a comment. Okay, I think this approach is better: - Rename the version of `appendNewlineText` used for escaped newlines to `appendEscapedNewlineText` to reduce confusability. - If `ENAS_DontAlign`, skip all of the offset calculation logic. Just append space-backslash-newline. - Restore the offset calculation to use `EscapedNewlineColumn - 1`, which it was before https://reviews.llvm.org/D32733. I don't think there was a good reason to change this. - Leave in the `assert`. https://reviews.llvm.org/D36019 Files: lib/Format/WhitespaceManager.cpp lib/Format/WhitespaceManager.h unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2309,6 +2309,30 @@ EXPECT_EQ("template f();", format("\\\ntemplate f();")); EXPECT_EQ("/* \\ \\ \\\n */", format("\\\n/* \\ \\ \\\n */")); EXPECT_EQ("", format("")); + + FormatStyle DontAlign = getLLVMStyle(); + DontAlign.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; + DontAlign.MaxEmptyLinesToKeep = 3; + // FIXME: can't use verifyFormat here because the newline before + // "public:" is not inserted the first time it's reformatted + EXPECT_EQ("#define A \\\n" +" class Foo { \\\n" +"void bar(); \\\n" +" \\\n" +" \\\n" +" \\\n" +" public: \\\n" +"void baz(); \\\n" +" };", +format("#define A \\\n" + " class Foo { \\\n" + "void bar(); \\\n" + " \\\n" + " \\\n" + " \\\n" + " public: \\\n" + "void baz(); \\\n" + " };", DontAlign)); } TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) { Index: lib/Format/WhitespaceManager.h === --- lib/Format/WhitespaceManager.h +++ lib/Format/WhitespaceManager.h @@ -195,9 +195,7 @@ /// \brief Stores \p Text as the replacement for the whitespace in \p Range. void storeReplacement(SourceRange Range, StringRef Text); void appendNewlineText(std::string &Text, unsigned Newlines); - void appendNewlineText(std::string &Text, unsigned Newlines, - unsigned PreviousEndOfTokenColumn, - unsigned EscapedNewlineColumn); + void appendEscapedNewlineText(std::string &Text, const Change &C); void appendIndentText(std::string &Text, unsigned IndentLevel, unsigned Spaces, unsigned WhitespaceStartColumn); Index: lib/Format/WhitespaceManager.cpp === --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -603,8 +603,7 @@ if (C.CreateReplacement) { std::string ReplacementText = C.PreviousLinePostfix; if (C.ContinuesPPDirective) -appendNewlineText(ReplacementText, C.NewlinesBefore, - C.PreviousEndOfTokenColumn, C.EscapedNewlineColumn); +appendEscapedNewlineText(ReplacementText, C); else appendNewlineText(ReplacementText, C.NewlinesBefore); appendIndentText(ReplacementText, C.Tok->IndentLevel, @@ -640,14 +639,19 @@ Text.append(UseCRLF ? "\r\n" : "\n"); } -void WhitespaceManager::appendNewlineText(std::string &Text, unsigned Newlines, - unsigned PreviousEndOfTokenColumn, - unsigned EscapedNewlineColumn) { - if (Newlines > 0) { +void WhitespaceManager::appendEscapedNewlineText(std::string &Text, const Change &C) { + if (Style.AlignEscapedNewlines == FormatStyle::ENAS_DontAlign) { +for (unsigned i = 0; i < C.NewlinesBefore; ++i) + Text.append(UseCRLF ? " \\\r\n" : " \\\n"); +return; + } + + if (C.NewlinesBefore > 0) { +assert(C.EscapedNewlineColumn >= 1); unsigned Offset = -std::min(EscapedNewlineColumn - 2, PreviousEndOfTokenColumn); -for (unsigned i = 0; i < Newlines; ++i) { - Text.append(EscapedNewlineColumn - Offset - 1, ' '); +std::min(C.EscapedNewlineColumn - 1, C.PreviousEndOfTokenColumn); +for (unsigned i = 0; i < C.NewlinesBefore; ++i) { + Text.append(C.EscapedNewlineColumn - Offset - 1, ' '); Text.append(UseCRLF ? "\\\r\n" : "\\\n"); Offset = 0; } Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2309,6 +2309,30 @@ EXPECT_EQ("template f();", format("\\\ntemplate f();")); EXPECT_EQ("/* \\ \\ \\\n */", format("\\\n/* \\ \\ \\\n */")); EXPECT_EQ("", format("")); + + FormatStyle DontAlign = getLLVMStyle();
[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines
jtbandes updated this revision to Diff 108863. jtbandes added a comment. - Undo change in argument list https://reviews.llvm.org/D36019 Files: lib/Format/WhitespaceManager.cpp lib/Format/WhitespaceManager.h unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2309,6 +2309,30 @@ EXPECT_EQ("template f();", format("\\\ntemplate f();")); EXPECT_EQ("/* \\ \\ \\\n */", format("\\\n/* \\ \\ \\\n */")); EXPECT_EQ("", format("")); + + FormatStyle DontAlign = getLLVMStyle(); + DontAlign.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; + DontAlign.MaxEmptyLinesToKeep = 3; + // FIXME: can't use verifyFormat here because the newline before + // "public:" is not inserted the first time it's reformatted + EXPECT_EQ("#define A \\\n" +" class Foo { \\\n" +"void bar(); \\\n" +" \\\n" +" \\\n" +" \\\n" +" public: \\\n" +"void baz(); \\\n" +" };", +format("#define A \\\n" + " class Foo { \\\n" + "void bar(); \\\n" + " \\\n" + " \\\n" + " \\\n" + " public: \\\n" + "void baz(); \\\n" + " };", DontAlign)); } TEST_F(FormatTest, CalculateSpaceOnConsecutiveLinesInMacro) { Index: lib/Format/WhitespaceManager.h === --- lib/Format/WhitespaceManager.h +++ lib/Format/WhitespaceManager.h @@ -195,9 +195,9 @@ /// \brief Stores \p Text as the replacement for the whitespace in \p Range. void storeReplacement(SourceRange Range, StringRef Text); void appendNewlineText(std::string &Text, unsigned Newlines); - void appendNewlineText(std::string &Text, unsigned Newlines, - unsigned PreviousEndOfTokenColumn, - unsigned EscapedNewlineColumn); + void appendEscapedNewlineText(std::string &Text, unsigned Newlines, +unsigned PreviousEndOfTokenColumn, +unsigned EscapedNewlineColumn); void appendIndentText(std::string &Text, unsigned IndentLevel, unsigned Spaces, unsigned WhitespaceStartColumn); Index: lib/Format/WhitespaceManager.cpp === --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -603,8 +603,9 @@ if (C.CreateReplacement) { std::string ReplacementText = C.PreviousLinePostfix; if (C.ContinuesPPDirective) -appendNewlineText(ReplacementText, C.NewlinesBefore, - C.PreviousEndOfTokenColumn, C.EscapedNewlineColumn); +appendEscapedNewlineText(ReplacementText, C.NewlinesBefore, + C.PreviousEndOfTokenColumn, + C.EscapedNewlineColumn); else appendNewlineText(ReplacementText, C.NewlinesBefore); appendIndentText(ReplacementText, C.Tok->IndentLevel, @@ -640,12 +641,20 @@ Text.append(UseCRLF ? "\r\n" : "\n"); } -void WhitespaceManager::appendNewlineText(std::string &Text, unsigned Newlines, - unsigned PreviousEndOfTokenColumn, - unsigned EscapedNewlineColumn) { +void WhitespaceManager::appendEscapedNewlineText(std::string &Text, + unsigned Newlines, + unsigned PreviousEndOfTokenColumn, + unsigned EscapedNewlineColumn) { + if (Style.AlignEscapedNewlines == FormatStyle::ENAS_DontAlign) { +for (unsigned i = 0; i < Newlines; ++i) + Text.append(UseCRLF ? " \\\r\n" : " \\\n"); +return; + } + if (Newlines > 0) { +assert(EscapedNewlineColumn >= 1); unsigned Offset = -std::min(EscapedNewlineColumn - 2, PreviousEndOfTokenColumn); +std::min(EscapedNewlineColumn - 1, PreviousEndOfTokenColumn); for (unsigned i = 0; i < Newlines; ++i) { Text.append(EscapedNewlineColumn - Offset - 1, ' '); Text.append(UseCRLF ? "\\\r\n" : "\\\n"); Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -2309,6 +2309,30 @@ EXPECT_EQ("template f();", format("\\\ntemplate f();")); EXPECT_EQ("/* \\ \\ \\\n */", format("\\\n/* \\ \\ \\\n */")); EXPECT_EQ("", format("")); + + FormatStyle DontAlign = getLLVMStyle(); + DontAlign.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; + DontAlign.MaxEmptyLinesToKeep = 3; + // FIXME: can't use verifyFormat
[PATCH] D34873: Fix miscompiled 32bit binaries by mingw
yvvan added a comment. Ok, i will make safer solution... https://reviews.llvm.org/D34873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36070: [coroutines] Evaluate the operand of void `co_return` expressions.
rsmith accepted this revision. rsmith added inline comments. Comment at: test/CodeGenCoroutines/coro-ret-void.cpp:30 +coro1 f2() { + co_return(void) A{}; +} This seems like an extremely confusing way to format this statement. Maybe move the space left a bit? https://reviews.llvm.org/D36070 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36072: [Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)
mstorsjo created this revision. This fixes a dependency inconsistency, where addMinGWDefines in Targets.cpp (used from other architectures than X86) called the addCygMingDefines function in X86.h. This was inconsistently split in SVN r308791 (https://reviews.llvm.org/D35701). https://reviews.llvm.org/D36072 Files: lib/Basic/Targets.cpp lib/Basic/Targets.h lib/Basic/Targets/X86.h Index: lib/Basic/Targets/X86.h === --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -691,30 +691,6 @@ } }; -static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) { - // Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang - // supports __declspec natively under -fms-extensions, but we define a no-op - // __declspec macro anyway for pre-processor compatibility. - if (Opts.MicrosoftExt) -Builder.defineMacro("__declspec", "__declspec"); - else -Builder.defineMacro("__declspec(a)", "__attribute__((a))"); - - if (!Opts.MicrosoftExt) { -// Provide macros for all the calling convention keywords. Provide both -// single and double underscore prefixed variants. These are available on -// x64 as well as x86, even though they have no effect. -const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"}; -for (const char *CC : CCs) { - std::string GCCSpelling = "__attribute__((__"; - GCCSpelling += CC; - GCCSpelling += "__))"; - Builder.defineMacro(Twine("_") + CC, GCCSpelling); - Builder.defineMacro(Twine("__") + CC, GCCSpelling); -} - } -} - // x86-32 MinGW target class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo { Index: lib/Basic/Targets.h === --- lib/Basic/Targets.h +++ lib/Basic/Targets.h @@ -42,6 +42,10 @@ LLVM_LIBRARY_VISIBILITY void addMinGWDefines(const clang::LangOptions &Opts, clang::MacroBuilder &Builder); + +LLVM_LIBRARY_VISIBILITY +void addCygMingDefines(const clang::LangOptions &Opts, + clang::MacroBuilder &Builder); } // namespace targets } // namespace clang #endif // LLVM_CLANG_LIB_BASIC_TARGETS_H Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -73,6 +73,30 @@ Builder.defineMacro("__tune_" + CPUName + "__"); } +void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) { + // Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang + // supports __declspec natively under -fms-extensions, but we define a no-op + // __declspec macro anyway for pre-processor compatibility. + if (Opts.MicrosoftExt) +Builder.defineMacro("__declspec", "__declspec"); + else +Builder.defineMacro("__declspec(a)", "__attribute__((a))"); + + if (!Opts.MicrosoftExt) { +// Provide macros for all the calling convention keywords. Provide both +// single and double underscore prefixed variants. These are available on +// x64 as well as x86, even though they have no effect. +const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"}; +for (const char *CC : CCs) { + std::string GCCSpelling = "__attribute__((__"; + GCCSpelling += CC; + GCCSpelling += "__))"; + Builder.defineMacro(Twine("_") + CC, GCCSpelling); + Builder.defineMacro(Twine("__") + CC, GCCSpelling); +} + } +} + void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) { Builder.defineMacro("__MSVCRT__"); Builder.defineMacro("__MINGW32__"); Index: lib/Basic/Targets/X86.h === --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -691,30 +691,6 @@ } }; -static void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) { - // Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang - // supports __declspec natively under -fms-extensions, but we define a no-op - // __declspec macro anyway for pre-processor compatibility. - if (Opts.MicrosoftExt) -Builder.defineMacro("__declspec", "__declspec"); - else -Builder.defineMacro("__declspec(a)", "__attribute__((a))"); - - if (!Opts.MicrosoftExt) { -// Provide macros for all the calling convention keywords. Provide both -// single and double underscore prefixed variants. These are available on -// x64 as well as x86, even though they have no effect. -const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"}; -for (const char *CC : CCs) { - std::string GCCSpelling = "__attribute__((__"; - GCCSpelling += CC; - GCCSpelling += "__))"; - Builder.defineMacro(Twine("_") + CC, GCCSpelling); - Builder.defineMacro(Twine("__") + CC, GCCSpelling); -} - } -} - // x86-32 MinGW target class LLVM_LIBR