Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
ichesnokov added a comment. Please review and commit. There's no patch, but only unit tests. Repository: rL LLVM http://reviews.llvm.org/D16682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16460: Bug 10002 - [opencl] Wrongfully assuming RHS is always unsigned
ichesnokov added a comment. Please review and commit. Repository: rL LLVM http://reviews.llvm.org/D16460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16574: Bug 15685 - OpenCL 'char' is not signed
ichesnokov added a comment. Please review and commit. Repository: rL LLVM http://reviews.llvm.org/D16574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType
ichesnokov added inline comments. Comment at: lib/AST/ItaniumMangle.cpp:1799 @@ -1798,2 +1798,3 @@ case LangAS::opencl_constant: ASString = "CLconstant"; break; + case LangAS::opencl_generic: ASString = "CLgeneric"; break; // ::= "CU" [ "device" | "constant" | "shared" ] ichesnokov wrote: > The Windows mangler is pretty different and doesn't have this issue. I'll try to fix on the Windows. Repository: rL LLVM http://reviews.llvm.org/D16539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r258768 - [Sema] Incomplete types are OK for covariant returns
Hi David, Should this be guarded by if(cxx14)? I think the complete type was required by earlier standards. - Kim Den 26 jan 2016 2:40 fm skrev "David Majnemer via cfe-commits" < cfe-commits@lists.llvm.org>: > Author: majnemer > Date: Mon Jan 25 19:37:01 2016 > New Revision: 258768 > > URL: http://llvm.org/viewvc/llvm-project?rev=258768&view=rev > Log: > [Sema] Incomplete types are OK for covariant returns > > Per C++14 [class.virtual]p8, it is OK for the return type's class type > to be incomplete so long as the return type is the same between the base > and complete classes. > > This fixes PR26297. > > Modified: > cfe/trunk/lib/Sema/SemaDeclCXX.cpp > cfe/trunk/test/SemaCXX/virtual-override.cpp > > Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=258768&r1=258767&r2=258768&view=diff > > == > --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jan 25 19:37:01 2016 > @@ -13020,19 +13020,20 @@ bool Sema::CheckOverridingFunctionReturn > return true; >} > > - // C++ [class.virtual]p6: > - // If the return type of D::f differs from the return type of B::f, > the > - // class type in the return type of D::f shall be complete at the > point of > - // declaration of D::f or shall be the class type D. > - if (const RecordType *RT = NewClassTy->getAs()) { > -if (!RT->isBeingDefined() && > -RequireCompleteType(New->getLocation(), NewClassTy, > -diag::err_covariant_return_incomplete, > -New->getDeclName())) > -return true; > - } > - >if (!Context.hasSameUnqualifiedType(NewClassTy, OldClassTy)) { > +// C++14 [class.virtual]p8: > +// If the class type in the covariant return type of D::f differs > from > +// that of B::f, the class type in the return type of D::f shall be > +// complete at the point of declaration of D::f or shall be the > class > +// type D. > +if (const RecordType *RT = NewClassTy->getAs()) { > + if (!RT->isBeingDefined() && > + RequireCompleteType(New->getLocation(), NewClassTy, > + diag::err_covariant_return_incomplete, > + New->getDeclName())) > +return true; > +} > + > // Check if the new class derives from the old class. > if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) { >Diag(New->getLocation(), diag::err_covariant_return_not_derived) > > Modified: cfe/trunk/test/SemaCXX/virtual-override.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtual-override.cpp?rev=258768&r1=258767&r2=258768&view=diff > > == > --- cfe/trunk/test/SemaCXX/virtual-override.cpp (original) > +++ cfe/trunk/test/SemaCXX/virtual-override.cpp Mon Jan 25 19:37:01 2016 > @@ -289,3 +289,15 @@ namespace PR8168 { > static void foo() {} // expected-error{{'static' member function > 'foo' overrides a virtual function}} >}; > } > + > +namespace PR26297 { > +struct Incomplete; > + > +struct Base { > + virtual const Incomplete *meow() = 0; > +}; > + > +struct Derived : Base { > + virtual Incomplete *meow() override { return nullptr; } > +}; > +} > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types
ichesnokov created this revision. ichesnokov added a reviewer: asl. ichesnokov added a subscriber: cfe-commits. ichesnokov set the repository for this revision to rL LLVM. Not a bug, thus empty patch. Older patch handles the case. Please look at comments at: https://llvm.org/bugs/show_bug.cgi?id=15785 Repository: rL LLVM http://reviews.llvm.org/D16754 Files: empty ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types
ichesnokov added a comment. BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=15785 Please review and close the bug. Repository: rL LLVM http://reviews.llvm.org/D16754 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
alexfh added a comment. Thank you for addressing (most of) the comments! I have a few more comments and the comment about the implementation of `asRawStringLiteral` still applies. Also, please remove unrelated files from the patch. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:68 @@ +67,3 @@ + // The NUL character disqualifies this literal. + if (Bytes.find_first_of(StringRef("\000", 1)) != StringRef::npos) +return false; A `.find('\0')` should be enough, no need for `.find_first_of()`. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:78 @@ +77,3 @@ + // Already a raw string literal if R comes before ". + if (Text.find('R') < Text.find('"')) +return false; I think 'R' in string literals can't be anywhere but at the very beginning. So I'd prefer `Text.front() == 'R'` as a simpler and a more straightforward alternative. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:86 @@ +85,3 @@ + + return containsEscapes(Text, R"lit('\"?x01)lit"); +} What's the reason to make the code longer and less readable by usingb `lit` here? Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:115 @@ +114,3 @@ + if (const auto *Literal = Result.Nodes.getNodeAs("lit")) { +if (containsEscapedCharacters(Result, Literal)) + replaceWithRawStringLiteral(Result, Literal); This is purely a matter of preference, but I personally don't find that, for example, `R"(\)"` is better that `"\\"`, and in general, that removing one backslash from a string literal is worth adding three more special characters (`R`, `(` and `)`). I think, the check should either be more conservative (e.g. leave alone string literals that don't become shorter, when rewritten as raw string literals) or be configurable in this regard. Another concern is that replacing a large number of `\n` sequences with actual newlines might make the code less readable (also a matter of preference, I guess). This also deserves either a cleverer analysis to prevent undesirable replacements and/or a separate configuration option. Comment at: docs/clang-tidy/checks/modernize-raw-string-literal.rst:45 @@ +44,3 @@ +Trailing whitespace at the end of a source code line is not visible in an +editor. Trailing whitespace is likely to be stripped by editors and other +tools, changing the meaning of the literal. I'm not a native speaker, but it seems that the rule to use two spaces after a period is outdated. Also, a quick search shows that in LLVM/Clang documentation a majority of files use exclusively one space after a period. That said, I don't feel strongly about that and this comment is just FYI. http://reviews.llvm.org/D16529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
alexfh added a comment. In http://reviews.llvm.org/D16529#340240, @alexfh wrote: > Also, please remove unrelated files from the patch. Please ignore this part, I missed the new diff. http://reviews.llvm.org/D16529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h
ariccio added a comment. Oops. The funny thing about the extra spaces is that I wasn't sure why there were spaces after the casts already, so I figured that I should keep it that way. I shall fix. http://reviews.llvm.org/D16748 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16748: Cleanup MemRegion.cpp/MemRegion.h
ariccio updated this revision to Diff 46481. ariccio marked 10 inline comments as done. ariccio added a comment. Removed extra spaces. http://reviews.llvm.org/D16748 Files: C:/LLVM/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp Index: C:/LLVM/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h === --- C:/LLVM/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ C:/LLVM/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -1319,8 +1319,8 @@ void setTrait(SymbolRef Sym, InvalidationKinds IK); void setTrait(const MemRegion *MR, InvalidationKinds IK); - bool hasTrait(SymbolRef Sym, InvalidationKinds IK); - bool hasTrait(const MemRegion *MR, InvalidationKinds IK); + bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const; + bool hasTrait(const MemRegion *MR, InvalidationKinds IK) const; }; } // end GR namespace Index: C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp === --- C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp +++ C:/LLVM/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -46,7 +46,7 @@ InsertPos)); if (!R) { -R = (RegionTy*) A.Allocate(); +R = A.Allocate(); new (R) RegionTy(a1, superRegion); Regions.InsertNode(R, InsertPos); } @@ -64,7 +64,7 @@ InsertPos)); if (!R) { -R = (RegionTy*) A.Allocate(); +R = A.Allocate(); new (R) RegionTy(a1, superRegion); Regions.InsertNode(R, InsertPos); } @@ -85,7 +85,7 @@ InsertPos)); if (!R) { -R = (RegionTy*) A.Allocate(); +R = A.Allocate(); new (R) RegionTy(a1, a2, superRegion); Regions.InsertNode(R, InsertPos); } @@ -104,7 +104,7 @@ InsertPos)); if (!R) { -R = (RegionTy*) A.Allocate(); +R = A.Allocate(); new (R) RegionTy(a1, a2, superRegion); Regions.InsertNode(R, InsertPos); } @@ -123,7 +123,7 @@ InsertPos)); if (!R) { -R = (RegionTy*) A.Allocate(); +R = A.Allocate(); new (R) RegionTy(a1, a2, a3, superRegion); Regions.InsertNode(R, InsertPos); } @@ -246,39 +246,39 @@ //===--===// void MemSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const { - ID.AddInteger((unsigned)getKind()); + ID.AddInteger(static_cast(getKind())); } void StackSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const { - ID.AddInteger((unsigned)getKind()); + ID.AddInteger(static_cast(getKind())); ID.AddPointer(getStackFrame()); } void StaticGlobalSpaceRegion::Profile(llvm::FoldingSetNodeID &ID) const { - ID.AddInteger((unsigned)getKind()); + ID.AddInteger(static_cast(getKind())); ID.AddPointer(getCodeRegion()); } void StringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const StringLiteral* Str, const MemRegion* superRegion) { - ID.AddInteger((unsigned) StringRegionKind); + ID.AddInteger(static_cast(StringRegionKind)); ID.AddPointer(Str); ID.AddPointer(superRegion); } void ObjCStringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const ObjCStringLiteral* Str, const MemRegion* superRegion) { - ID.AddInteger((unsigned) ObjCStringRegionKind); + ID.AddInteger(static_cast(ObjCStringRegionKind)); ID.AddPointer(Str); ID.AddPointer(superRegion); } void AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr *Ex, unsigned cnt, const MemRegion *superRegion) { - ID.AddInteger((unsigned) AllocaRegionKind); + ID.AddInteger(static_cast(AllocaRegionKind)); ID.AddPointer(Ex); ID.AddInteger(cnt); ID.AddPointer(superRegion); @@ -295,15 +295,15 @@ void CompoundLiteralRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const CompoundLiteralExpr *CL, const MemRegion* superRegion) { - ID.AddInteger((unsigned) CompoundLiteralRegionKind); + ID.AddInteger(static_cast(CompoundLiteralRegionKind)); ID.AddPointer(CL); ID.AddPointer(superRegion); } void CXXThisRegion::ProfileRegion(llvm::FoldingSetNodeID &ID, const PointerType *PT, const MemRegion *sRegion) { - ID.AddInteger((unsigned)
Re: r258768 - [Sema] Incomplete types are OK for covariant returns
On Sunday, January 31, 2016, Kim Gräsman wrote: > Hi David, > > Should this be guarded by if(cxx14)? I think the complete type was > required by earlier standards. > It is the same issue as CWG defect report 1250: http://wg21.cmeerw.net/cwg/issue1250 I forget how to tell how far back a DR applies but I'd guess this one goes as far back as C++11. > - Kim > Den 26 jan 2016 2:40 fm skrev "David Majnemer via cfe-commits" < > cfe-commits@lists.llvm.org > >: > >> Author: majnemer >> Date: Mon Jan 25 19:37:01 2016 >> New Revision: 258768 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=258768&view=rev >> Log: >> [Sema] Incomplete types are OK for covariant returns >> >> Per C++14 [class.virtual]p8, it is OK for the return type's class type >> to be incomplete so long as the return type is the same between the base >> and complete classes. >> >> This fixes PR26297. >> >> Modified: >> cfe/trunk/lib/Sema/SemaDeclCXX.cpp >> cfe/trunk/test/SemaCXX/virtual-override.cpp >> >> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=258768&r1=258767&r2=258768&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jan 25 19:37:01 2016 >> @@ -13020,19 +13020,20 @@ bool Sema::CheckOverridingFunctionReturn >> return true; >>} >> >> - // C++ [class.virtual]p6: >> - // If the return type of D::f differs from the return type of B::f, >> the >> - // class type in the return type of D::f shall be complete at the >> point of >> - // declaration of D::f or shall be the class type D. >> - if (const RecordType *RT = NewClassTy->getAs()) { >> -if (!RT->isBeingDefined() && >> -RequireCompleteType(New->getLocation(), NewClassTy, >> -diag::err_covariant_return_incomplete, >> -New->getDeclName())) >> -return true; >> - } >> - >>if (!Context.hasSameUnqualifiedType(NewClassTy, OldClassTy)) { >> +// C++14 [class.virtual]p8: >> +// If the class type in the covariant return type of D::f differs >> from >> +// that of B::f, the class type in the return type of D::f shall be >> +// complete at the point of declaration of D::f or shall be the >> class >> +// type D. >> +if (const RecordType *RT = NewClassTy->getAs()) { >> + if (!RT->isBeingDefined() && >> + RequireCompleteType(New->getLocation(), NewClassTy, >> + diag::err_covariant_return_incomplete, >> + New->getDeclName())) >> +return true; >> +} >> + >> // Check if the new class derives from the old class. >> if (!IsDerivedFrom(New->getLocation(), NewClassTy, OldClassTy)) { >>Diag(New->getLocation(), diag::err_covariant_return_not_derived) >> >> Modified: cfe/trunk/test/SemaCXX/virtual-override.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtual-override.cpp?rev=258768&r1=258767&r2=258768&view=diff >> >> == >> --- cfe/trunk/test/SemaCXX/virtual-override.cpp (original) >> +++ cfe/trunk/test/SemaCXX/virtual-override.cpp Mon Jan 25 19:37:01 2016 >> @@ -289,3 +289,15 @@ namespace PR8168 { >> static void foo() {} // expected-error{{'static' member function >> 'foo' overrides a virtual function}} >>}; >> } >> + >> +namespace PR26297 { >> +struct Incomplete; >> + >> +struct Base { >> + virtual const Incomplete *meow() = 0; >> +}; >> + >> +struct Derived : Base { >> + virtual Incomplete *meow() override { return nullptr; } >> +}; >> +} >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16460: Bug 10002 - [opencl] Wrongfully assuming RHS is always unsigned
ichesnokov added a comment. BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=10002 Repository: rL LLVM http://reviews.llvm.org/D16460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
ichesnokov added a comment. BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=19957 Repository: rL LLVM http://reviews.llvm.org/D16682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16539: [FIX] 26194 - LLVM crash in CXXNameMangler::mangleType
ichesnokov added a comment. BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=26194 Repository: rL LLVM http://reviews.llvm.org/D16539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0
ichesnokov added a comment. majnemer, I'll try to find answer to your question tomorrow. Repository: rL LLVM http://reviews.llvm.org/D16351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0
ichesnokov added a comment. BugZilla page: https://llvm.org/bugs/show_bug.cgi?id=25404 Repository: rL LLVM http://reviews.llvm.org/D16351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r258768 - [Sema] Incomplete types are OK for covariant returns
On Sun, Jan 31, 2016 at 2:50 PM, David Majnemer wrote: > > It is the same issue as CWG defect report 1250: > http://wg21.cmeerw.net/cwg/issue1250 > > I forget how to tell how far back a DR applies but I'd guess this one goes > as far back as C++11. Thanks, I didn't know there was a DR for this. I find the standards text is a little vague but your change seems to indicate that cv-qualifiers never weighs into covariance. The reason I ask is we handle this explicitly in IWYU, and we treat cv-qual differences as covariant (requiring the complete type). It doesn't look like that was the standard's intent. We should probably follow Clang here in a coming release, assuming other compilers agree. It looks from the bug-report that they do, at least newer versions. Thanks, - Kim ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types
asl requested changes to this revision. asl added a comment. This revision now requires changes to proceed. Please don't create empty review requests. This is ridiculous. Repository: rL LLVM http://reviews.llvm.org/D16754 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types
Hi Anton, Okey, nevermore. But what to do with a bug which needs simply be closed (NABs)? I believe they also need a review/approval. Igor -Original Message- From: Anton Korobeynikov [mailto:an...@korobeynikov.info] Sent: Sunday, January 31, 2016 8:19 PM To: Igor Chesnokov; an...@korobeynikov.info Cc: cfe-commits@lists.llvm.org Subject: Re: [PATCH] D16754: Bug 15785 - OpenCL errors using vector/scalar conditionals and short integer types asl requested changes to this revision. asl added a comment. This revision now requires changes to proceed. Please don't create empty review requests. This is ridiculous. Repository: rL LLVM http://reviews.llvm.org/D16754 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r258768 - [Sema] Incomplete types are OK for covariant returns
On Sun, Jan 31, 2016 at 5:24 PM, Kim Gräsman wrote: > On Sun, Jan 31, 2016 at 2:50 PM, David Majnemer > wrote: >> >> It is the same issue as CWG defect report 1250: >> http://wg21.cmeerw.net/cwg/issue1250 >> >> I forget how to tell how far back a DR applies but I'd guess this one goes >> as far back as C++11. > > Thanks, I didn't know there was a DR for this. Oh, this should probably be updated: http://clang.llvm.org/cxx_dr_status.html#1250 - K ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16758: [OpenMP] Prevent nesting of target constructs within target code execution regions.
arpith-jacob created this revision. arpith-jacob added reviewers: hfinkel, kkwli0, sfantao, carlo.bertolli, ABataev. arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin. This patch enhances Sema to check for the following restriction: OpenMP 4.5 [2.17 Nesting of Regions] If a target, target update, target data, target enter data, or target exit data construct is encountered during execution of a target region, the behavior is unspecified. http://reviews.llvm.org/D16758 Files: include/clang/Basic/OpenMPKinds.h lib/Basic/OpenMPKinds.cpp lib/Sema/SemaOpenMP.cpp test/OpenMP/distribute_private_messages.cpp test/OpenMP/nesting_of_regions.cpp test/OpenMP/target_data_device_messages.cpp test/OpenMP/target_device_messages.cpp test/OpenMP/target_if_messages.cpp test/OpenMP/target_messages.cpp test/OpenMP/target_parallel_default_messages.cpp test/OpenMP/target_parallel_device_messages.cpp test/OpenMP/target_parallel_firstprivate_messages.cpp test/OpenMP/target_parallel_if_messages.cpp test/OpenMP/target_parallel_map_messages.cpp test/OpenMP/target_parallel_messages.cpp test/OpenMP/target_parallel_num_threads_messages.cpp test/OpenMP/target_parallel_private_messages.cpp test/OpenMP/target_parallel_proc_bind_messages.cpp test/OpenMP/target_parallel_reduction_messages.cpp test/OpenMP/target_parallel_shared_messages.cpp test/OpenMP/target_private_messages.cpp test/OpenMP/teams_reduction_messages.cpp Index: test/OpenMP/teams_reduction_messages.cpp === --- test/OpenMP/teams_reduction_messages.cpp +++ test/OpenMP/teams_reduction_messages.cpp @@ -175,13 +175,15 @@ #pragma omp teams #pragma omp parallel for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); #pragma omp target #pragma omp teams #pragma omp parallel for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); @@ -306,13 +308,15 @@ #pragma omp teams #pragma omp parallel for private(fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); #pragma omp target #pragma omp teams #pragma omp parallel for reduction(- : fl) for (int i = 0; i < 10; ++i) + {} #pragma omp target #pragma omp teams reduction(+ : fl) foo(); Index: test/OpenMP/target_private_messages.cpp === --- test/OpenMP/target_private_messages.cpp +++ test/OpenMP/target_private_messages.cpp @@ -90,28 +90,39 @@ int i; int &j = i; #pragma omp target private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private() // expected-error {{expected expression}} +{} #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target private(argc) +{} #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}} +{} #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}} +{} #pragma omp target private(argv[1]) // expected-error {{expected variable name}} +{} #pragma omp target private(e, g) +{} #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}} +{} #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} #pragma omp parallel { int v = 0; int i; -#pragma omp target private(i) -{} } #pragma omp parallel shared(i) #pragma omp parallel private(i) #pragma omp target private(j) +{} #pragma omp target private(i) {} return 0; @@ -139,28 +150,40 @@ int i; int &j = i; #pragma omp target private // expected-error {{expected '(' after 'private'}} +{} #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private() // expected-error {{expected expression}} +{} #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} +{} #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} +{} #pragma omp target private(argc) +{} #pragma omp target private(S1) // expected-error {{'S1' does not ref
[PATCH] D16761: clang-cl: Support loading plugins on Windows
ehsan created this revision. ehsan added a reviewer: rnk. ehsan added a subscriber: cfe-commits. This builds on the support being added to LLVM to import and export registries from DLLs. This will allow us to pick up the registry entries added in the DLL's copy of FrontendPluginRegistry. This will allow us to use plugins on Windows using: $ clang-cl -Xclang -load -Xclang plugin.dll \ -Xclang -add-plugin -Xclang foo clang-cl: Enable plugins on Windows http://reviews.llvm.org/D16761 Files: docs/ClangPlugins.rst examples/PrintFunctionNames/PrintFunctionNames.cpp lib/FrontendTool/ExecuteCompilerInvocation.cpp test/Frontend/plugins.c test/lit.cfg Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -196,7 +196,7 @@ # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. -if sys.platform in ['win32', 'cygwin']: +if sys.platform in ['cygwin']: has_plugins = (config.enable_shared == 1) else: has_plugins = True Index: test/Frontend/plugins.c === --- test/Frontend/plugins.c +++ test/Frontend/plugins.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s +// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s // REQUIRES: plugins, examples // CHECK: top-level-decl: "x" Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp === --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -184,9 +184,18 @@ e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) { const std::string &Path = Clang->getFrontendOpts().Plugins[i]; std::string Error; -if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) +llvm::sys::DynamicLibrary DL( +llvm::sys::DynamicLibrary::getPermanentLibrary(Path.c_str(), &Error)); +if (DL.isValid()) { +#ifdef _MSC_VER + // On Windows, we need to import the plugin front-end action + // dynamically. + LLVM_IMPORT_REGISTRY(FrontendPluginRegistry, DL); +#endif +} else { Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) << Path << Error; +} } // Honor -mllvm. Index: examples/PrintFunctionNames/PrintFunctionNames.cpp === --- examples/PrintFunctionNames/PrintFunctionNames.cpp +++ examples/PrintFunctionNames/PrintFunctionNames.cpp @@ -121,3 +121,6 @@ static FrontendPluginRegistry::Add X("print-fns", "print function names"); +#ifdef _MSC_VER +LLVM_EXPORT_REGISTRY(FrontendPluginRegistry) +#endif Index: docs/ClangPlugins.rst === --- docs/ClangPlugins.rst +++ docs/ClangPlugins.rst @@ -37,11 +37,16 @@ A plugin is loaded from a dynamic library at runtime by the compiler. To -register a plugin in a library, use ``FrontendPluginRegistry::Add<>``: +register a plugin in a library, use ``FrontendPluginRegistry::Add<>``. +Note that on Windows, you also need to export your plugin registry using +``LLVM_EXPORT_REGISTRY``. Here is an example: .. code-block:: c++ static FrontendPluginRegistry::Add X("my-plugin-name", "my plugin description"); + #ifdef _MSC_VER + LLVM_EXPORT_REGISTRY(FrontendPluginRegistry) + #endif Putting it all together === Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -196,7 +196,7 @@ # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. -if sys.platform in ['win32', 'cygwin']: +if sys.platform in ['cygwin']: has_plugins = (config.enable_shared == 1) else: has_plugins = True Index: test/Frontend/plugins.c === --- test/Frontend/plugins.c +++ test/Frontend/plugins.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -load %llvmshlibdir/PrintFunctionNames%pluginext -plugin print-fns %s 2>&1 | FileCheck %s +// RUN: %clang_cl -Xclang -load -Xclang %llvmshlibdir/PrintFunctionNames%pluginext -Xclang -plugin -Xclang print-fns %s 2>&1 | FileCheck %s // REQUIRES: plugins, examples // CHECK: top-level-decl: "x" Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp === --- lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -184,9 +184,18 @@ e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) { const std::string &Path = Clang->getFrontendOpts().Plugins[i]; std::string Error; -if (llvm::sys::DynamicLibrary::Loa
Re: [PATCH] D16708: Add a new attribute CFNoRelease.
> On Jan 29, 2016, at 6:02 AM, Aaron Ballman wrote: > > aaron.ballman added a subscriber: aaron.ballman. > aaron.ballman added a reviewer: aaron.ballman. > aaron.ballman added a comment. > > It's a bit strange to add an attribute that has absolutely no semantic effect > whatsoever. Where is this attribute intended to be queried within the > compiler? Are there additional functionality patches coming for this? Yes there is a forthcoming patch for CodeGen which will place an attribute on the relevant functions. The attribute will be queried in the middle end optimizer. The reason why there has been a bit of a delay is I realized I wanted to talk to a few more people about this attribute internally. We may want to expand its use to essentially mean "no-arc", i.e. this is a c function that uses pure c-code. There are other possibilities as well. > > > > Comment at: include/clang/Basic/Attr.td:540 > @@ +539,3 @@ > + let Subjects = SubjectList<[Function]>; > + let Documentation = [Undocumented]; > +} > > Please, no undocumented new attributes. You should modify AttrDocs.td and > include that reference here. I was just following the model of the code that was already there and documented the attribute in a comment above the attribute. I am fine with adding specific documentation for the attribute. > > > Comment at: test/SemaObjC/attr-cf_no_release.m:31 > @@ +30,2 @@ > + void *d CF_NO_RELEASE, // > expected-warning{{'cf_no_release' attribute only applies to functions}} > + CFFooRef e CF_NO_RELEASE); // > expected-warning{{'cf_no_release' attribute only applies to functions}} > > Not that lots of test are bad, but a lot of these tests are duplicates and > can be removed. For instance, really only need one test for ObjC methods, one > for properties, one for params, etc. It would be good to add a test ensuring > that the attribute accepts no arguments. Ok. Michael > > > http://reviews.llvm.org/D16708 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r259335 - Mark DR1250 as implemented
Author: majnemer Date: Sun Jan 31 19:33:17 2016 New Revision: 259335 URL: http://llvm.org/viewvc/llvm-project?rev=259335&view=rev Log: Mark DR1250 as implemented We implemented this DR back in r258768 but forgot to mark it as implemented. Added: cfe/trunk/test/CXX/drs/dr12xx.cpp Modified: cfe/trunk/test/SemaCXX/virtual-override.cpp cfe/trunk/www/cxx_dr_status.html Added: cfe/trunk/test/CXX/drs/dr12xx.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr12xx.cpp?rev=259335&view=auto == --- cfe/trunk/test/CXX/drs/dr12xx.cpp (added) +++ cfe/trunk/test/CXX/drs/dr12xx.cpp Sun Jan 31 19:33:17 2016 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors + +// expected-no-diagnostics + +namespace dr1250 { // dr1250: 3.9 +struct Incomplete; + +struct Base { + virtual const Incomplete *meow() = 0; +}; + +struct Derived : Base { + virtual Incomplete *meow(); +}; +} // dr1250 Modified: cfe/trunk/test/SemaCXX/virtual-override.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtual-override.cpp?rev=259335&r1=259334&r2=259335&view=diff == --- cfe/trunk/test/SemaCXX/virtual-override.cpp (original) +++ cfe/trunk/test/SemaCXX/virtual-override.cpp Sun Jan 31 19:33:17 2016 @@ -289,15 +289,3 @@ namespace PR8168 { static void foo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}} }; } - -namespace PR26297 { -struct Incomplete; - -struct Base { - virtual const Incomplete *meow() = 0; -}; - -struct Derived : Base { - virtual Incomplete *meow() override { return nullptr; } -}; -} Modified: cfe/trunk/www/cxx_dr_status.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=259335&r1=259334&r2=259335&view=diff == --- cfe/trunk/www/cxx_dr_status.html (original) +++ cfe/trunk/www/cxx_dr_status.html Sun Jan 31 19:33:17 2016 @@ -7315,7 +7315,7 @@ and POD class http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1250";>1250 CD3 Cv-qualification of incomplete virtual function return types -Unknown +SVN http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1251";>1251 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r258768 - [Sema] Incomplete types are OK for covariant returns
Done in r258768. On Sun, Jan 31, 2016 at 10:49 AM, Kim Gräsman wrote: > On Sun, Jan 31, 2016 at 5:24 PM, Kim Gräsman > wrote: > > On Sun, Jan 31, 2016 at 2:50 PM, David Majnemer > > wrote: > >> > >> It is the same issue as CWG defect report 1250: > >> http://wg21.cmeerw.net/cwg/issue1250 > >> > >> I forget how to tell how far back a DR applies but I'd guess this one > goes > >> as far back as C++11. > > > > Thanks, I didn't know there was a DR for this. > > Oh, this should probably be updated: > http://clang.llvm.org/cxx_dr_status.html#1250 > > - K > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16708: Add a new attribute CFNoRelease.
gottesmm added a comment. I think that my response via email did not hit phabriactor. So sorry for the delay. Yes there is a forthcoming patch for CodeGen which will place an attribute on the relevant functions. The attribute will be queried in the middle end optimizer. The reason why there has been a bit of a delay is I realized I wanted to talk to a few more people about this attribute internally. We may want to expand its use to essentially mean "no-arc", i.e. this is a c function that uses pure c-code. There are other possibilities as well so stay tuned. http://reviews.llvm.org/D16708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16708: Add a new attribute CFNoRelease.
gottesmm added inline comments. Comment at: include/clang/Basic/Attr.td:540 @@ +539,3 @@ + let Subjects = SubjectList<[Function]>; + let Documentation = [Undocumented]; +} aaron.ballman wrote: > Please, no undocumented new attributes. You should modify AttrDocs.td and > include that reference here. Ok. I was just following what was done in the surrounding code. I am fine with adding something to AttrDocs.td once we pin down exactly what we want. Comment at: test/SemaObjC/attr-cf_no_release.m:31 @@ +30,2 @@ + void *d CF_NO_RELEASE, // expected-warning{{'cf_no_release' attribute only applies to functions}} + CFFooRef e CF_NO_RELEASE); // expected-warning{{'cf_no_release' attribute only applies to functions}} aaron.ballman wrote: > Not that lots of test are bad, but a lot of these tests are duplicates and > can be removed. For instance, really only need one test for ObjC methods, one > for properties, one for params, etc. It would be good to add a test ensuring > that the attribute accepts no arguments. Ok. http://reviews.llvm.org/D16708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
LegalizeAdulthood marked an inline comment as done. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:79 @@ +78,3 @@ + if (Text.find('R') < Text.find('"')) +return false; + Take a look at http://en.cppreference.com/w/cpp/language/string_literal There can be a prefix before the R, it's not always the first character. Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:87 @@ +86,3 @@ + return containsEscapes(Text, R"lit('\"?x01)lit"); +} + Without R"()", the \ and " have to be escaped. Running this check on this code would turn this into a raw string literal. Comment at: docs/clang-tidy/checks/modernize-raw-string-literal.rst:46 @@ +45,3 @@ +editor. Trailing whitespace is likely to be stripped by editors and other +tools, changing the meaning of the literal. + It's a habit my fingers learned when they taught me to type on typewriters in high school. http://reviews.llvm.org/D16529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
LegalizeAdulthood added inline comments. Comment at: docs/clang-tidy/checks/modernize-raw-string-literal.rst:46 @@ +45,3 @@ +editor. Trailing whitespace is likely to be stripped by editors and other +tools, changing the meaning of the literal. + LegalizeAdulthood wrote: > It's a habit my fingers learned when they taught me to type on typewriters in > high school. ...also, AFAIK, it doesn't matter in terms of the output produced. http://reviews.llvm.org/D16529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
LegalizeAdulthood updated this revision to Diff 46504. LegalizeAdulthood added a comment. Update from comments http://reviews.llvm.org/D16529 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tidy/modernize/RawStringLiteralCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-raw-string-literal.rst test/clang-tidy/modernize-raw-string-literal.cpp Index: test/clang-tidy/modernize-raw-string-literal.cpp === --- /dev/null +++ test/clang-tidy/modernize-raw-string-literal.cpp @@ -0,0 +1,68 @@ +// RUN: %check_clang_tidy %s modernize-raw-string-literal %t + +char const *const BackSlash{"goink\\frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal] +// CHECK-FIXES: {{^}}char const *const BackSlash{R"(goink\frob)"};{{$}} + +char const *const Bell{"goink\\\afrob"}; +char const *const BackSpace{"goink\\\bfrob"}; +char const *const FormFeed{"goink\\\ffrob"}; +char const *const CarraigeReturn{"goink\\\rfrob"}; +char const *const HorizontalTab{"goink\\\tfrob"}; +char const *const VerticalTab{"goink\\\vfrob"}; +char const *const OctalNonPrintable{"\\\003"}; +char const *const HexNonPrintable{"\\\x03"}; +char const *const Delete{"\\\177"}; +char const *const TrailingSpace{"A line \\with space. \n"}; +char const *const TrailingNewLine{"A single \\line.\n"}; +char const *const AlreadyRaw{R"(foobie\\bletch)"}; +char const *const UTF8Literal{u8"foobie\\bletch"}; +char const *const UTF8RawLiteral{u8R"(foobie\\bletch)"}; +char16_t const *const UTF16Literal{u"foobie\\bletch"}; +char16_t const *const UTF16RawLiteral{uR"(foobie\\bletch)"}; +char32_t const *const UTF32Literal{U"foobie\\bletch"}; +char32_t const *const UTF32RawLiteral{UR"(foobie\\bletch)"}; +wchar_t const *const WideLiteral{L"foobie\\bletch"}; +wchar_t const *const WideRawLiteral{LR"(foobie\\bletch)"}; + +char const *const NewLine{"goink\nfrob\n"}; +// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const NewLine{R"(goink{{$}} +// CHECK-FIXES-NEXT: {{^}}frob{{$}} +// CHECK-FIXES-NEXT: {{^}})"};{{$}} + +char const *const SingleQuote{"goink\'frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal +// CHECK-XFIXES: {{^}}char const *const SingleQuote{R"(goink'frob)"};{{$}} + +char const *const DoubleQuote{"goink\"frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const DoubleQuote{R"(goink"frob)"};{{$}} + +char const *const QuestionMark{"goink\?frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const QuestionMark{R"(goink?frob)"};{{$}} + +char const *const RegEx{"goink\\(one|two\\)\\?.*\\nfrob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const RegEx{R"(goink\(one|two\)\\\?.*\nfrob)"};{{$}} + +char const *const Path{"C:\\Program Files\\Vendor\\Application\\Application.exe"}; +// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const Path{R"(C:\Program Files\Vendor\Application\Application.exe)"};{{$}} + +char const *const ContainsSentinel{"who\\ops)\""}; +// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const ContainsSentinel{R"lit(who\ops)")lit"};{{$}} + +char const *const ContainsDelim{"whoops)\")lit\""}; +// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const ContainsDelim{R"lit1(whoops)")lit")lit1"};{{$}} + +char const *const OctalPrintable{"\100\\"}; +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const OctalPrintable{R"(@\)"};{{$}} + +char const *const HexPrintable{"\x40\\"}; +// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const HexPrintable{R"(@\)"};{{$}} Index: docs/clang-tidy/checks/modernize-raw-string-literal.rst === --- /dev/null +++ docs/clang-tidy/checks/modernize-raw-string-literal.rst @@ -0,0 +1,56 @@ +.. title:: clang-tidy - modernize-raw-string-literal + +modernize-raw-string-literal + + +This check selectively replaces string literals containing escaped characters +with raw string literals. + +Example: + +.. code-blocK:: c++ + + const char *const Quotes{"embedded \"quotes\""}; + const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood updated this revision to Diff 46505. LegalizeAdulthood added a comment. Update from review comments. trunk clang-format http://reviews.llvm.org/D16308 Files: clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.h docs/clang-tidy/checks/readability-simplify-boolean-expr.rst test/clang-tidy/readability-simplify-bool-expr.cpp Index: test/clang-tidy/readability-simplify-bool-expr.cpp === --- test/clang-tidy/readability-simplify-bool-expr.cpp +++ test/clang-tidy/readability-simplify-bool-expr.cpp @@ -690,7 +690,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i & 1);{{$}} +// CHECK-FIXES: {{^}} return (i & 1) != 0;{{$}} bool negated_if_implicit_bool_expr(int i) { if (i - 1) { @@ -700,7 +700,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return !static_cast(i - 1);{{$}} +// CHECK-FIXES: {{^}} return (i - 1) == 0;{{$}} bool implicit_int(int i) { if (i) { @@ -710,7 +710,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i);{{$}} +// CHECK-FIXES: {{^}} return i != 0;{{$}} bool explicit_bool(bool b) { if (b) { @@ -757,7 +757,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(~i);{{$}} +// CHECK-FIXES: {{^}} return ~i != 0;{{$}} bool logical_or(bool a, bool b) { if (a || b) { @@ -830,7 +830,7 @@ bool b = i ? true : false; } // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: {{.*}} in ternary expression result -// CHECK-FIXES: bool b = static_cast(i);{{$}} +// CHECK-FIXES: bool b = i != 0;{{$}} bool non_null_pointer_condition(int *p1) { if (p1) { @@ -895,3 +895,38 @@ // CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: {{^}} if (b) { // CHECK-FIXES: {{^}}#define SOMETHING_WICKED false + +bool integer_not_zero(int i) { + if (i) { +return false; + } else { +return true; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} return i == 0;{{$}} + +class A { +public: +int m; +}; + +bool member_pointer_nullptr(int A::*p) { + if (p) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p != nullptr;{{$}} + +bool integer_member_implicit_cast(A *p) { + if (p->m) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p->m != 0;{{$}} Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst === --- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst +++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst @@ -35,11 +35,14 @@ 2. Negated applications of ``!`` are eliminated. 3. Negated applications of comparison operators are changed to use the opposite condition. - 4. Implicit conversions of pointer to ``bool`` are replaced with explicit - comparisons to ``nullptr``. + 4. Implicit conversions of pointers, including pointers to members, to + ``bool`` are replaced with explicit comparisons to ``nullptr`` in C++11 + or ``NULL`` in C++98/03. 5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``. 6. Object expressions with ``explicit operator bool`` conversion operators are replaced with explicit casts to ``bool``. + 7. Implicit conversions of integral types to ``bool`` are replaced with + explicit comparisons to ``0``. Examples: 1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant @@ -60,11 +63,11 @@ The ternary assignment ``bool b = (i & 1) ? true : false;`` has an implicit conversion of ``i & 1`` to ``bool`` and becomes - ``bool b = static_cast(i & 1);``. + ``bool b = (i & 1) != 0;``. 5. The conditional return ``if (i & 1) return true; else return false;`` has an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and - becomes ``return static_cast(i & 1);`` + becomes ``return (i & 1) != 0;`` 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of ``struct X``, the conditional return ``if (x) return true; return false;`` Index: clang-tidy/readability/SimplifyBooleanExprCheck.h === --- clang-tidy/readability/SimplifyBooleanExprCheck.h +++ clang-tidy/readability/SimplifyBooleanExprCheck.h @@ -19,75 +19,8 @@ /// Looks for boolean expressions involving boolean constants and simplifies /// them to use the appropriate bo
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood updated this revision to Diff 46506. LegalizeAdulthood added a comment. Inline Variable http://reviews.llvm.org/D16308 Files: clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.h docs/clang-tidy/checks/readability-simplify-boolean-expr.rst test/clang-tidy/readability-simplify-bool-expr.cpp Index: test/clang-tidy/readability-simplify-bool-expr.cpp === --- test/clang-tidy/readability-simplify-bool-expr.cpp +++ test/clang-tidy/readability-simplify-bool-expr.cpp @@ -690,7 +690,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i & 1);{{$}} +// CHECK-FIXES: {{^}} return (i & 1) != 0;{{$}} bool negated_if_implicit_bool_expr(int i) { if (i - 1) { @@ -700,7 +700,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return !static_cast(i - 1);{{$}} +// CHECK-FIXES: {{^}} return (i - 1) == 0;{{$}} bool implicit_int(int i) { if (i) { @@ -710,7 +710,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i);{{$}} +// CHECK-FIXES: {{^}} return i != 0;{{$}} bool explicit_bool(bool b) { if (b) { @@ -757,7 +757,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(~i);{{$}} +// CHECK-FIXES: {{^}} return ~i != 0;{{$}} bool logical_or(bool a, bool b) { if (a || b) { @@ -830,7 +830,7 @@ bool b = i ? true : false; } // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: {{.*}} in ternary expression result -// CHECK-FIXES: bool b = static_cast(i);{{$}} +// CHECK-FIXES: bool b = i != 0;{{$}} bool non_null_pointer_condition(int *p1) { if (p1) { @@ -895,3 +895,38 @@ // CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: {{^}} if (b) { // CHECK-FIXES: {{^}}#define SOMETHING_WICKED false + +bool integer_not_zero(int i) { + if (i) { +return false; + } else { +return true; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} return i == 0;{{$}} + +class A { +public: +int m; +}; + +bool member_pointer_nullptr(int A::*p) { + if (p) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p != nullptr;{{$}} + +bool integer_member_implicit_cast(A *p) { + if (p->m) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p->m != 0;{{$}} Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst === --- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst +++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst @@ -35,11 +35,14 @@ 2. Negated applications of ``!`` are eliminated. 3. Negated applications of comparison operators are changed to use the opposite condition. - 4. Implicit conversions of pointer to ``bool`` are replaced with explicit - comparisons to ``nullptr``. + 4. Implicit conversions of pointers, including pointers to members, to + ``bool`` are replaced with explicit comparisons to ``nullptr`` in C++11 + or ``NULL`` in C++98/03. 5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``. 6. Object expressions with ``explicit operator bool`` conversion operators are replaced with explicit casts to ``bool``. + 7. Implicit conversions of integral types to ``bool`` are replaced with + explicit comparisons to ``0``. Examples: 1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant @@ -60,11 +63,11 @@ The ternary assignment ``bool b = (i & 1) ? true : false;`` has an implicit conversion of ``i & 1`` to ``bool`` and becomes - ``bool b = static_cast(i & 1);``. + ``bool b = (i & 1) != 0;``. 5. The conditional return ``if (i & 1) return true; else return false;`` has an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and - becomes ``return static_cast(i & 1);`` + becomes ``return (i & 1) != 0;`` 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of ``struct X``, the conditional return ``if (x) return true; return false;`` Index: clang-tidy/readability/SimplifyBooleanExprCheck.h === --- clang-tidy/readability/SimplifyBooleanExprCheck.h +++ clang-tidy/readability/SimplifyBooleanExprCheck.h @@ -19,75 +19,8 @@ /// Looks for boolean expressions involving boolean constants and simplifies /// them to use the appropriate boolean expression directly. ///
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood updated this revision to Diff 46507. LegalizeAdulthood added a comment. Move local function to anonymous namespace http://reviews.llvm.org/D16308 Files: clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.h docs/clang-tidy/checks/readability-simplify-boolean-expr.rst test/clang-tidy/readability-simplify-bool-expr.cpp Index: test/clang-tidy/readability-simplify-bool-expr.cpp === --- test/clang-tidy/readability-simplify-bool-expr.cpp +++ test/clang-tidy/readability-simplify-bool-expr.cpp @@ -690,7 +690,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i & 1);{{$}} +// CHECK-FIXES: {{^}} return (i & 1) != 0;{{$}} bool negated_if_implicit_bool_expr(int i) { if (i - 1) { @@ -700,7 +700,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return !static_cast(i - 1);{{$}} +// CHECK-FIXES: {{^}} return (i - 1) == 0;{{$}} bool implicit_int(int i) { if (i) { @@ -710,7 +710,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i);{{$}} +// CHECK-FIXES: {{^}} return i != 0;{{$}} bool explicit_bool(bool b) { if (b) { @@ -757,7 +757,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(~i);{{$}} +// CHECK-FIXES: {{^}} return ~i != 0;{{$}} bool logical_or(bool a, bool b) { if (a || b) { @@ -830,7 +830,7 @@ bool b = i ? true : false; } // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: {{.*}} in ternary expression result -// CHECK-FIXES: bool b = static_cast(i);{{$}} +// CHECK-FIXES: bool b = i != 0;{{$}} bool non_null_pointer_condition(int *p1) { if (p1) { @@ -895,3 +895,38 @@ // CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: {{^}} if (b) { // CHECK-FIXES: {{^}}#define SOMETHING_WICKED false + +bool integer_not_zero(int i) { + if (i) { +return false; + } else { +return true; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} return i == 0;{{$}} + +class A { +public: +int m; +}; + +bool member_pointer_nullptr(int A::*p) { + if (p) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p != nullptr;{{$}} + +bool integer_member_implicit_cast(A *p) { + if (p->m) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p->m != 0;{{$}} Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst === --- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst +++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst @@ -35,11 +35,14 @@ 2. Negated applications of ``!`` are eliminated. 3. Negated applications of comparison operators are changed to use the opposite condition. - 4. Implicit conversions of pointer to ``bool`` are replaced with explicit - comparisons to ``nullptr``. + 4. Implicit conversions of pointers, including pointers to members, to + ``bool`` are replaced with explicit comparisons to ``nullptr`` in C++11 + or ``NULL`` in C++98/03. 5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``. 6. Object expressions with ``explicit operator bool`` conversion operators are replaced with explicit casts to ``bool``. + 7. Implicit conversions of integral types to ``bool`` are replaced with + explicit comparisons to ``0``. Examples: 1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant @@ -60,11 +63,11 @@ The ternary assignment ``bool b = (i & 1) ? true : false;`` has an implicit conversion of ``i & 1`` to ``bool`` and becomes - ``bool b = static_cast(i & 1);``. + ``bool b = (i & 1) != 0;``. 5. The conditional return ``if (i & 1) return true; else return false;`` has an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and - becomes ``return static_cast(i & 1);`` + becomes ``return (i & 1) != 0;`` 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of ``struct X``, the conditional return ``if (x) return true; return false;`` Index: clang-tidy/readability/SimplifyBooleanExprCheck.h === --- clang-tidy/readability/SimplifyBooleanExprCheck.h +++ clang-tidy/readability/SimplifyBooleanExprCheck.h @@ -19,75 +19,8 @@ /// Looks for boolean expressions involving boolean constants and simplifies /// them to use the appropriate boolean
Re: [PATCH] D16758: [OpenMP] Prevent nesting of target constructs within target code execution regions.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG http://reviews.llvm.org/D16758 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits