r317993 - Fix AST matcher documentation typo
Author: kastiglione Date: Sat Nov 11 15:53:27 2017 New Revision: 317993 URL: http://llvm.org/viewvc/llvm-project?rev=317993=rev Log: Fix AST matcher documentation typo Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=317993=317992=317993=diff == --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Sat Nov 11 15:53:27 2017 @@ -1255,7 +1255,7 @@ NSString's "alloc". This matcher should Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcThrowStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html;>ObjCAtThrowStmt... -Matches Objective-C @try statements. +Matches Objective-C @throw statements. Example matches @throw @throw obj; Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=317993=317992=317993=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Nov 11 15:53:27 2017 @@ -1265,7 +1265,7 @@ const internal::VariadicDynCastAllOfMatc Decl, ObjCPropertyDecl> objcPropertyDecl; -/// \brief Matches Objective-C @try statements. +/// \brief Matches Objective-C @throw statements. /// /// Example matches @throw /// \code ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39940: Add ObjC exception statement AST matchers
This revision was automatically updated to reflect the committed changes. Closed by commit rL317992: Add ObjC exception statement AST matchers (authored by kastiglione). Repository: rL LLVM https://reviews.llvm.org/D39940 Files: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp === --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp @@ -388,16 +388,20 @@ REGISTER_MATCHER(nullStmt); REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); + REGISTER_MATCHER(objcCatchStmt); REGISTER_MATCHER(objcCategoryDecl); REGISTER_MATCHER(objcCategoryImplDecl); + REGISTER_MATCHER(objcFinallyStmt); REGISTER_MATCHER(objcImplementationDecl); REGISTER_MATCHER(objcInterfaceDecl); REGISTER_MATCHER(objcIvarDecl); REGISTER_MATCHER(objcMessageExpr); REGISTER_MATCHER(objcMethodDecl); REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcThrowStmt); + REGISTER_MATCHER(objcTryStmt); REGISTER_MATCHER(on); REGISTER_MATCHER(onImplicitObjectArgument); REGISTER_MATCHER(opaqueValueExpr); Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1639,5 +1639,28 @@ objcPropertyDecl(hasName("enabled"; } +TEST(ObjCStmtMatcher, ExceptionStmts) { + std::string ObjCString = +"void f(id obj) {" +" @try {" +"@throw obj;" +" } @catch (...) {" +" } @finally {}" +"}"; + + EXPECT_TRUE(matchesObjC( +ObjCString, +objcTryStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcThrowStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcCatchStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcFinallyStmt())); +} + } // namespace ast_matchers } // namespace clang Index: cfe/trunk/docs/LibASTMatchersReference.html === --- cfe/trunk/docs/LibASTMatchersReference.html +++ cfe/trunk/docs/LibASTMatchersReference.html @@ -1225,6 +1225,24 @@ +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcCatchStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html;>ObjCAtCatchStmt... +Matches Objective-C @catch statements. + +Example matches @catch + @try {} + @catch (...) {} + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcFinallyStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html;>ObjCAtFinallyStmt... +Matches Objective-C @finally statements. + +Example matches @finally + @try {} + @finally {} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcMessageExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExpr... Matches ObjectiveC Message invocation expressions. @@ -1236,6 +1254,23 @@ +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcThrowStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html;>ObjCAtThrowStmt... +Matches Objective-C @try statements. + +Example matches @throw + @throw obj; + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcTryStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html;>ObjCAtTryStmt... +Matches Objective-C @try statements. + +Example matches @try + @try {} + @catch (...) {} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtopaqueValueExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html;>OpaqueValueExpr... Matches opaque value expressions. They are used as helpers to reference another expressions and can be met Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h === --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -1265,6 +1265,49 @@ Decl, ObjCPropertyDecl> objcPropertyDecl; +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @throw +/// \code +/// @throw obj; +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtThrowStmt> objcThrowStmt; + +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @try +/// \code +/// @try {} +/// @catch (...) {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtTryStmt> objcTryStmt; + +/// \brief Matches Objective-C @catch statements. +/// +/// Example matches @catch +/// \code
r317992 - Add ObjC exception statement AST matchers
Author: kastiglione Date: Sat Nov 11 14:46:15 2017 New Revision: 317992 URL: http://llvm.org/viewvc/llvm-project?rev=317992=rev Log: Add ObjC exception statement AST matchers Summary: Add AST matchers for Objective-C @throw, @try, @catch and @finally. Reviewers: aaron.ballman, malcolm.parsons, alexshap, compnerd Reviewed By: aaron.ballman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D39940 Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=317992=317991=317992=diff == --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Sat Nov 11 14:46:15 2017 @@ -1225,6 +1225,24 @@ nullStmt() +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcCatchStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html;>ObjCAtCatchStmt... +Matches Objective-C @catch statements. + +Example matches @catch + @try {} + @catch (...) {} + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcFinallyStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html;>ObjCAtFinallyStmt... +Matches Objective-C @finally statements. + +Example matches @finally + @try {} + @finally {} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcMessageExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExpr... Matches ObjectiveC Message invocation expressions. @@ -1236,6 +1254,23 @@ NSString's "alloc". This matcher should +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcThrowStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html;>ObjCAtThrowStmt... +Matches Objective-C @try statements. + +Example matches @throw + @throw obj; + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcTryStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html;>ObjCAtTryStmt... +Matches Objective-C @try statements. + +Example matches @try + @try {} + @catch (...) {} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtopaqueValueExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html;>OpaqueValueExpr... Matches opaque value expressions. They are used as helpers to reference another expressions and can be met Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=317992=317991=317992=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Nov 11 14:46:15 2017 @@ -1265,6 +1265,49 @@ const internal::VariadicDynCastAllOfMatc Decl, ObjCPropertyDecl> objcPropertyDecl; +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @throw +/// \code +/// @throw obj; +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtThrowStmt> objcThrowStmt; + +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @try +/// \code +/// @try {} +/// @catch (...) {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtTryStmt> objcTryStmt; + +/// \brief Matches Objective-C @catch statements. +/// +/// Example matches @catch +/// \code +/// @try {} +/// @catch (...) {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtCatchStmt> objcCatchStmt; + +/// \brief Matches Objective-C @finally statements. +/// +/// Example matches @finally +/// \code +/// @try {} +/// @finally {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtFinallyStmt> objcFinallyStmt; + /// \brief Matches expressions that introduce cleanups to be run at the end /// of the sub-expression's evaluation. /// Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=317992=317991=317992=diff == --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original) +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sat Nov 11 14:46:15 2017 @@ -388,8 +388,10 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(nullStmt); REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); + REGISTER_MATCHER(objcCatchStmt); REGISTER_MATCHER(objcCategoryDecl); REGISTER_MATCHER(objcCategoryImplDecl); +
[PATCH] D39462: [Sema] Implement -Wmaybe-tautological-constant-compare for when the tautologicalness is data model dependent
lebedev.ri added a comment. In https://reviews.llvm.org/D39462#917421, @rjmccall wrote: > So, that change makes this very interesting, because I think the right way of > looking at it is as the first in a larger family of warnings that attempt to > treat typedefs as if they were a much stronger type-system feature, i.e. that > warn about all sorts of conversions between different typedef types. That > should be good enough to serve as a basic rule for a stronger portability > warning, as well as generally pointing out all sorts of potential logical > errors like passing a bit_offset_t off as a byte_offset_t. > > Such a warning really needs more exceptions than a simple exact-type-spelling > rule would give you. There are several language features that add type sugar > which should really be ignored for the purposes of the warning, such as > typeof and decltype; and conversely, there are several features that remove > (or just never add) type sugar that also shouldn't cause problems, like > literals or C++ templates. > > I think that feature could be really useful as a major new diagnostic That is all very cool and shiny, but could we please go back to the real world, please? :) In https://reviews.llvm.org/D39462#917421, @rjmccall wrote: > but I do want to warn you that it's probably a pretty large project, somewhat > on the scale of implementing -Wconversion in the first place. Exactly. My expirience shows that unless i'm actually interested, i will either fail, or it will work poorly. And i can tell you that i'm not quite interested in implementing what you seem to suggest to implement. What i would like to do, is to finish *this* differential, that would make https://reviews.llvm.org/D38101 less noisy for some questionable edge-cases, without In https://reviews.llvm.org/D39462#917421, @rjmccall wrote: > a pretty large project, somewhat on the scale of implementing -Wconversion in > the first place. Can that happen? :) In https://reviews.llvm.org/D39462#917421, @rjmccall wrote: > Also, yeah, my first thought is that it's probably outside of a reasonable > rubric for even -Wextra, especially while it's being actively developed. For that other diagnostic you suggest - sure. --- I think the general direction is correct, but there are unhandled cases yet, e.g , so I'm somewhat lost here, and would love to hear some actual feedback for the suggested code. Repository: rL LLVM https://reviews.llvm.org/D39462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer
lichray added a comment. In https://reviews.llvm.org/D38216#922709, @Rakete wrote: > @lichray Isn't [dcl.type.auto.deduct] only for `auto` and `decltype(auto)`? Sorry, reasoned on a confusingly similar part... Here is updated information: > 10.1.7.5 [dcl.type.class.deduct] > If a placeholder for a deduced class type appears as a decl-specifier in > the decl-specifier-seq of an initializing declaration (11.6) of a variable, > [...]. > 11.6 [dcl.init]/22 > A declaration that specifies the initialization of a variable, whether from > an explicit initializer or by default initialization, is called the > initializing > declaration of that variable. [ Note: In most cases this is the defining > declaration (6.1) of the variable, but the initializing declaration of a non- > inline static data member (12.2.3.2) might be the declaration within the > class definition and not the definition at namespace scope. —end note ] So deducing from default initialization is indeed allowed, but `extern` could be interpreted as outlawed because similar to the case of non- inline static data member, where the declaration doesn't give **the** initialization of that variable. @rsmith, comments? https://reviews.llvm.org/D38216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39161: [bindings] remove unique_external test failure
frutiger abandoned this revision. frutiger added a comment. Fixed by r317986. https://reviews.llvm.org/D39161 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39810: [python] [tests] Fix test_linkage for unique external linkage
This revision was automatically updated to reflect the committed changes. Closed by commit rL317986: [python] [tests] Fix test_linkage for unique external linkage (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D39810?vs=122575=122590#toc Repository: rL LLVM https://reviews.llvm.org/D39810 Files: cfe/trunk/bindings/python/tests/cindex/test_linkage.py Index: cfe/trunk/bindings/python/tests/cindex/test_linkage.py === --- cfe/trunk/bindings/python/tests/cindex/test_linkage.py +++ cfe/trunk/bindings/python/tests/cindex/test_linkage.py @@ -15,7 +15,8 @@ tu = get_tu(""" void foo() { int no_linkage; } static int internal; -namespace { extern int unique_external; } +namespace { struct unique_external_type {} } +unique_external_type unique_external; extern int external; """, lang = 'cpp') Index: cfe/trunk/bindings/python/tests/cindex/test_linkage.py === --- cfe/trunk/bindings/python/tests/cindex/test_linkage.py +++ cfe/trunk/bindings/python/tests/cindex/test_linkage.py @@ -15,7 +15,8 @@ tu = get_tu(""" void foo() { int no_linkage; } static int internal; -namespace { extern int unique_external; } +namespace { struct unique_external_type {} } +unique_external_type unique_external; extern int external; """, lang = 'cpp') ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r317986 - [python] [tests] Fix test_linkage for unique external linkage
Author: mgorny Date: Sat Nov 11 12:01:41 2017 New Revision: 317986 URL: http://llvm.org/viewvc/llvm-project?rev=317986=rev Log: [python] [tests] Fix test_linkage for unique external linkage Starting with r314037, anonymous namespaces no longer give unique-external linkage to variables. However, this linkage can still be achieved by using a type which is not exterally visible, e.g. through being declared in an anonymous namespace but used outside it. Fix the test to take advantage of that. Differential Revision: https://reviews.llvm.org/D39810 Modified: cfe/trunk/bindings/python/tests/cindex/test_linkage.py Modified: cfe/trunk/bindings/python/tests/cindex/test_linkage.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_linkage.py?rev=317986=317985=317986=diff == --- cfe/trunk/bindings/python/tests/cindex/test_linkage.py (original) +++ cfe/trunk/bindings/python/tests/cindex/test_linkage.py Sat Nov 11 12:01:41 2017 @@ -15,7 +15,8 @@ class TestLinkage(unittest.TestCase): tu = get_tu(""" void foo() { int no_linkage; } static int internal; -namespace { extern int unique_external; } +namespace { struct unique_external_type {} } +unique_external_type unique_external; extern int external; """, lang = 'cpp') ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39940: Add ObjC exception statement AST matchers
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D39940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39810: [python] [tests] Fix test_linkage for unique external linkage
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! https://reviews.llvm.org/D39810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39166: [NFC] Add some assertions to placate my paranoia about sharing a variant bit across FunctionDecl and CXXDeductionGuideDecl - should I do this?
faisalv abandoned this revision. faisalv added a comment. Just added an additional bit-field to FunctionDecl in https://reviews.llvm.org/rL317984 Comment at: include/clang/AST/InlineDeclMembers.h:35 + +#endif //LLVM_CLANG_AST_INLINEDECLMEMBERS_H + aaron.ballman wrote: > Whitespace is incorrect here. not sure I follow? Repository: rL LLVM https://reviews.llvm.org/D39166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r317984 - Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl.
Author: faisalv Date: Sat Nov 11 10:02:29 2017 New Revision: 317984 URL: http://llvm.org/viewvc/llvm-project?rev=317984=rev Log: Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl. The anonymous union did NOT save us storage, but instead behaved as if we added an additional integer data member to FunctionDecl. For additional context, the anonymous union renders the bit fields as non-adjacent and prevents them from sharing the same 'memory location' (i.e. bit-storage) by requiring the anonymous union object to be appropriately aligned. This was confirmed through discussion with Richard Smith in Albuquerque (ISO C++ Meeting) https://reviews.llvm.org/rL316292 Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=317984=317983=317984=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Sat Nov 11 10:02:29 2017 @@ -1678,17 +1678,17 @@ private: /// skipped. unsigned HasSkippedBody : 1; + /// Indicates if the function declaration will have a body, once we're done + /// parsing it. + unsigned WillHaveBody : 1; + protected: - // Since a Deduction Guide [C++17] will never have a body, we can share the - // storage, and use a different name. - union { -/// Indicates if the function declaration will have a body, once we're done -/// parsing it. -unsigned WillHaveBody : 1; -/// Indicates that the Deduction Guide is the implicitly generated 'copy -/// deduction candidate' (is used during overload resolution). -unsigned IsCopyDeductionCandidate : 1; - }; + /// [C++17] Only used by CXXDeductionGuideDecl. Declared here to avoid + /// increasing the size of CXXDeductionGuideDecl by the size of an unsigned + /// int as opposed to adding a single bit to FunctionDecl. + /// Indicates that the Deduction Guide is the implicitly generated 'copy + /// deduction candidate' (is used during overload resolution). + unsigned IsCopyDeductionCandidate : 1; private: /// \brief End part of this FunctionDecl's source range. /// @@ -1767,15 +1767,14 @@ protected: DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(), SClass(S), IsInline(isInlineSpecified), IsInlineSpecified(isInlineSpecified), IsExplicitSpecified(false), -IsVirtualAsWritten(false), IsPure(false), -HasInheritedPrototype(false), HasWrittenPrototype(true), -IsDeleted(false), IsTrivial(false), IsDefaulted(false), -IsExplicitlyDefaulted(false), HasImplicitReturnZero(false), -IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified), -InstantiationIsPending(false), +IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false), +HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false), +IsDefaulted(false), IsExplicitlyDefaulted(false), +HasImplicitReturnZero(false), IsLateTemplateParsed(false), +IsConstexpr(isConstexprSpecified), InstantiationIsPending(false), UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false), -EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(), -DNLoc(NameInfo.getInfo()) {} +IsCopyDeductionCandidate(false), EndRangeLoc(NameInfo.getEndLoc()), +TemplateOrSpecialization(), DNLoc(NameInfo.getInfo()) {} typedef Redeclarable redeclarable_base; FunctionDecl *getNextRedeclarationImpl() override { Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=317984=317983=317984=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Sat Nov 11 10:02:29 2017 @@ -1881,10 +1881,6 @@ private: if (EndLocation.isValid()) setRangeEnd(EndLocation); IsExplicitSpecified = IsExplicit; - -// IsCopyDeductionCandidate is a union variant member, so ensure it is the -// active member by storing to it. -IsCopyDeductionCandidate = false; } public: Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=317984=317983=317984=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sat Nov 11 10:02:29 2017 @@ -1863,8 +1863,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) {
r317983 - [cxx_status] Add resolution of CWG issue 1581, since it's an important, visible change.
Author: rsmith Date: Sat Nov 11 10:00:16 2017 New Revision: 317983 URL: http://llvm.org/viewvc/llvm-project?rev=317983=rev Log: [cxx_status] Add resolution of CWG issue 1581, since it's an important, visible change. Modified: cfe/trunk/www/cxx_status.html Modified: cfe/trunk/www/cxx_status.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=317983=317982=317983=diff == --- cfe/trunk/www/cxx_status.html (original) +++ cfe/trunk/www/cxx_status.html Sat Nov 11 10:00:16 2017 @@ -847,7 +847,7 @@ as the draft C++2a standard evolves. Simplifying implicit lambda capture http://wg21.link/p0588r1;>P0588R1 - No + No (14) ADL and function templates that are not visible @@ -860,6 +860,11 @@ as the draft C++2a standard evolves. No + Less eager instantiation of constexpr functions + http://wg21.link/p0859r0;>P0859R0 + No (15) + + Consistent comparison (operator=) http://wg21.link/p0515r3;>P0515R3 No @@ -885,6 +890,12 @@ as the draft C++2a standard evolves. (13): This is the resolution to a Defect Report, so is applied to all language versions supporting class template argument deduction. + +(14): This is the resolution to a Defect Report, so will be applied +to all language versions supporting lamba expressions. + +(15): This is the resolution to a Defect Report, so will be applied +to all language versions supporting constexpr. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r317982 - [cxx_status] Update for moved Albuquerque papers.
Author: rsmith Date: Sat Nov 11 09:54:46 2017 New Revision: 317982 URL: http://llvm.org/viewvc/llvm-project?rev=317982=rev Log: [cxx_status] Update for moved Albuquerque papers. Modified: cfe/trunk/www/cxx_status.html Modified: cfe/trunk/www/cxx_status.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=317982=317981=317982=diff == --- cfe/trunk/www/cxx_status.html (original) +++ cfe/trunk/www/cxx_status.html Sat Nov 11 09:54:46 2017 @@ -830,9 +830,53 @@ as the draft C++2a standard evolves. http://wg21.link/p0702r1;>P0702R1 SVN (13) - - Concepts + + Concepts http://wg21.link/p0734r0;>P0734R0 + No + + +http://wg21.link/p0857r0;>P0857R0 + + + + Range-based for statements with initializer + http://wg21.link/p0614r1;>P0614R1 + No + + + Simplifying implicit lambda capture + http://wg21.link/p0588r1;>P0588R1 + No + + + ADL and function templates that are not visible + http://wg21.link/p0846r0;>P0846R0 + No + + + const mismatch with defaulted copy constructor + http://wg21.link/p0641r2;>P0641R2 + No + + + Consistent comparison (operator=) + http://wg21.link/p0515r3;>P0515R3 + No + + + Access checking on specializations + http://wg21.link/p0692r1;>P0692R1 + Partial + + + Default constructible and assignable stateless lambdas + http://wg21.link/p0624r2;>P0624R2 + No + + + Lambdas in unevaluated contexts + http://wg21.link/p0315r4;>P0315R4 No @@ -900,7 +944,7 @@ and library features that are not part o [TS] Concepts http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0121r0.pdf;>P0121R0 - Superseded by P0734R0 + Superseded by P0734R0 [DRAFT TS] Coroutines ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39940: Add ObjC exception statement AST matchers
kastiglione created this revision. Herald added a subscriber: klimek. Add AST matchers for Objective-C @throw, @try, @catch and @finally. https://reviews.llvm.org/D39940 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/Dynamic/Registry.cpp unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1639,5 +1639,28 @@ objcPropertyDecl(hasName("enabled"; } +TEST(ObjCStmtMatcher, ExceptionStmts) { + std::string ObjCString = +"void f(id obj) {" +" @try {" +"@throw obj;" +" } @catch (...) {" +" } @finally {}" +"}"; + + EXPECT_TRUE(matchesObjC( +ObjCString, +objcTryStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcThrowStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcCatchStmt())); + EXPECT_TRUE(matchesObjC( +ObjCString, +objcFinallyStmt())); +} + } // namespace ast_matchers } // namespace clang Index: lib/ASTMatchers/Dynamic/Registry.cpp === --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -388,16 +388,20 @@ REGISTER_MATCHER(nullStmt); REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); + REGISTER_MATCHER(objcCatchStmt); REGISTER_MATCHER(objcCategoryDecl); REGISTER_MATCHER(objcCategoryImplDecl); + REGISTER_MATCHER(objcFinallyStmt); REGISTER_MATCHER(objcImplementationDecl); REGISTER_MATCHER(objcInterfaceDecl); REGISTER_MATCHER(objcIvarDecl); REGISTER_MATCHER(objcMessageExpr); REGISTER_MATCHER(objcMethodDecl); REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcThrowStmt); + REGISTER_MATCHER(objcTryStmt); REGISTER_MATCHER(on); REGISTER_MATCHER(onImplicitObjectArgument); REGISTER_MATCHER(opaqueValueExpr); Index: include/clang/ASTMatchers/ASTMatchers.h === --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -1265,6 +1265,49 @@ Decl, ObjCPropertyDecl> objcPropertyDecl; +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @throw +/// \code +/// @throw obj; +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtThrowStmt> objcThrowStmt; + +/// \brief Matches Objective-C @try statements. +/// +/// Example matches @try +/// \code +/// @try {} +/// @catch (...) {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtTryStmt> objcTryStmt; + +/// \brief Matches Objective-C @catch statements. +/// +/// Example matches @catch +/// \code +/// @try {} +/// @catch (...) {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtCatchStmt> objcCatchStmt; + +/// \brief Matches Objective-C @finally statements. +/// +/// Example matches @finally +/// \code +/// @try {} +/// @finally {} +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Stmt, + ObjCAtFinallyStmt> objcFinallyStmt; + /// \brief Matches expressions that introduce cleanups to be run at the end /// of the sub-expression's evaluation. /// Index: docs/LibASTMatchersReference.html === --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -1225,6 +1225,24 @@ +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcCatchStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html;>ObjCAtCatchStmt... +Matches Objective-C @catch statements. + +Example matches @catch + @try {} + @catch (...) {} + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcFinallyStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html;>ObjCAtFinallyStmt... +Matches Objective-C @finally statements. + +Example matches @finally + @try {} + @finally {} + + + Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcMessageExprMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExpr... Matches ObjectiveC Message invocation expressions. @@ -1236,6 +1254,23 @@ +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcThrowStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html;>ObjCAtThrowStmt... +Matches Objective-C @try statements. + +Example matches @throw + @throw obj; + + + +Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtobjcTryStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html;>ObjCAtTryStmt... +Matches Objective-C @try statements. + +Example matches @try + @try {} + @catch
[PATCH] D39768: [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame
This revision was automatically updated to reflect the committed changes. Closed by commit rL317981: [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it… (authored by GorNishanov). Changed prior to commit: https://reviews.llvm.org/D39768?vs=122004=122585#toc Repository: rL LLVM https://reviews.llvm.org/D39768 Files: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGenCoroutines/coro-dest-slot.cpp Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp === --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp @@ -33,9 +33,11 @@ #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Operator.h" +#include "llvm/Transforms/Utils/PromoteMemToReg.h" using namespace clang; using namespace CodeGen; @@ -419,6 +421,18 @@ I->first->replaceAllUsesWith(I->second); I->first->eraseFromParent(); } + + // Eliminate CleanupDestSlot alloca by replacing it with SSA values and + // PHIs if the current function is a coroutine. We don't do it for all + // functions as it may result in slight increase in numbers of instructions + // if compiled with no optimizations. We do it for coroutine as the lifetime + // of CleanupDestSlot alloca make correct coroutine frame building very + // difficult. + if (NormalCleanupDest && isCoroutine()) { +llvm::DominatorTree DT(*CurFn); +llvm::PromoteMemToReg(NormalCleanupDest, DT); +NormalCleanupDest = nullptr; + } } /// ShouldInstrumentFunction - Return true if the current function should be Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h === --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -225,6 +225,10 @@ }; CGCoroInfo CurCoro; + bool isCoroutine() const { +return CurCoro.Data != nullptr; + } + /// CurGD - The GlobalDecl for the current function being compiled. GlobalDecl CurGD; @@ -764,7 +768,7 @@ ForceCleanup(); } -/// Checks if the global variable is captured in current function. +/// Checks if the global variable is captured in current function. bool isGlobalVarCaptured(const VarDecl *VD) const { VD = VD->getCanonicalDecl(); return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0; @@ -826,7 +830,7 @@ /// block through the normal cleanup handling code (if any) and then /// on to \arg Dest. void EmitBranchThroughCleanup(JumpDest Dest); - + /// isObviouslyBranchWithoutCleanups - Return true if a branch to the /// specified destination obviously has no cleanups to run. 'false' is always /// a conservatively correct answer for this method. @@ -1045,7 +1049,7 @@ if (Data.isValid()) Data.unbind(CGF); } }; - + private: CGDebugInfo *DebugInfo; bool DisableDebugInfo; @@ -1434,19 +1438,19 @@ /// Add OpenCL kernel arg metadata and the kernel attribute meatadata to /// the function metadata. - void EmitOpenCLKernelMetadata(const FunctionDecl *FD, + void EmitOpenCLKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn); public: CodeGenFunction(CodeGenModule , bool suppressNewContext=false); ~CodeGenFunction(); CodeGenTypes () const { return CGM.getTypes(); } ASTContext () const { return CGM.getContext(); } - CGDebugInfo *getDebugInfo() { -if (DisableDebugInfo) + CGDebugInfo *getDebugInfo() { +if (DisableDebugInfo) return nullptr; -return DebugInfo; +return DebugInfo; } void disableDebugInfo() { DisableDebugInfo = true; } void enableDebugInfo() { DisableDebugInfo = false; } @@ -2509,7 +2513,7 @@ }; AutoVarEmission EmitAutoVarAlloca(const VarDecl ); void EmitAutoVarInit(const AutoVarEmission ); - void EmitAutoVarCleanups(const AutoVarEmission ); + void EmitAutoVarCleanups(const AutoVarEmission ); void emitAutoVarTypeCleanup(const AutoVarEmission , QualType::DestructionKind dtorKind); @@ -2531,7 +2535,7 @@ bool isIndirect() const { return Alignment != 0; } llvm::Value *getAnyValue() const { return Value; } - + llvm::Value *getDirectValue() const { assert(!isIndirect()); return Value; @@ -3188,7 +3192,7 @@ LValue EmitCastLValue(const CastExpr *E); LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e); - + Address EmitExtVectorElementLValue(LValue V); RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc); @@ -3305,12 +3309,12 @@ void EmitNoreturnRuntimeCallOrInvoke(llvm::Value
r317981 - [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame
Author: gornishanov Date: Sat Nov 11 09:00:43 2017 New Revision: 317981 URL: http://llvm.org/viewvc/llvm-project?rev=317981=rev Log: [coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame Summary: We don't want to store cleanup dest slot saved into the coroutine frame (as some of the cleanup code may access them after coroutine frame destroyed). This is an alternative to https://reviews.llvm.org/D37093 It is possible to do this for all functions, but, cursory check showed that in -O0, we get slightly longer function (by 1-3 instructions), thus, we are only limiting cleanup.dest.slot elimination to coroutines. Reviewers: rjmccall, hfinkel, eric_niebler Reviewed By: eric_niebler Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D39768 Added: cfe/trunk/test/CodeGenCoroutines/coro-dest-slot.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=317981=317980=317981=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Sat Nov 11 09:00:43 2017 @@ -33,9 +33,11 @@ #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Operator.h" +#include "llvm/Transforms/Utils/PromoteMemToReg.h" using namespace clang; using namespace CodeGen; @@ -419,6 +421,18 @@ void CodeGenFunction::FinishFunction(Sou I->first->replaceAllUsesWith(I->second); I->first->eraseFromParent(); } + + // Eliminate CleanupDestSlot alloca by replacing it with SSA values and + // PHIs if the current function is a coroutine. We don't do it for all + // functions as it may result in slight increase in numbers of instructions + // if compiled with no optimizations. We do it for coroutine as the lifetime + // of CleanupDestSlot alloca make correct coroutine frame building very + // difficult. + if (NormalCleanupDest && isCoroutine()) { +llvm::DominatorTree DT(*CurFn); +llvm::PromoteMemToReg(NormalCleanupDest, DT); +NormalCleanupDest = nullptr; + } } /// ShouldInstrumentFunction - Return true if the current function should be Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=317981=317980=317981=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Nov 11 09:00:43 2017 @@ -225,6 +225,10 @@ public: }; CGCoroInfo CurCoro; + bool isCoroutine() const { +return CurCoro.Data != nullptr; + } + /// CurGD - The GlobalDecl for the current function being compiled. GlobalDecl CurGD; @@ -764,7 +768,7 @@ public: ForceCleanup(); } -/// Checks if the global variable is captured in current function. +/// Checks if the global variable is captured in current function. bool isGlobalVarCaptured(const VarDecl *VD) const { VD = VD->getCanonicalDecl(); return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0; @@ -826,7 +830,7 @@ public: /// block through the normal cleanup handling code (if any) and then /// on to \arg Dest. void EmitBranchThroughCleanup(JumpDest Dest); - + /// isObviouslyBranchWithoutCleanups - Return true if a branch to the /// specified destination obviously has no cleanups to run. 'false' is always /// a conservatively correct answer for this method. @@ -1045,7 +1049,7 @@ public: if (Data.isValid()) Data.unbind(CGF); } }; - + private: CGDebugInfo *DebugInfo; bool DisableDebugInfo; @@ -1434,7 +1438,7 @@ private: /// Add OpenCL kernel arg metadata and the kernel attribute meatadata to /// the function metadata. - void EmitOpenCLKernelMetadata(const FunctionDecl *FD, + void EmitOpenCLKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn); public: @@ -1443,10 +1447,10 @@ public: CodeGenTypes () const { return CGM.getTypes(); } ASTContext () const { return CGM.getContext(); } - CGDebugInfo *getDebugInfo() { -if (DisableDebugInfo) + CGDebugInfo *getDebugInfo() { +if (DisableDebugInfo) return nullptr; -return DebugInfo; +return DebugInfo; } void disableDebugInfo() { DisableDebugInfo = true; } void enableDebugInfo() { DisableDebugInfo = false; } @@ -2509,7 +2513,7 @@ public: }; AutoVarEmission EmitAutoVarAlloca(const VarDecl ); void EmitAutoVarInit(const AutoVarEmission ); - void
[PATCH] D39641: [CodeGen] make cbrt and fma constant (never set errno)
spatel updated this revision to Diff 122584. spatel marked an inline comment as done. spatel added a comment. Patch updated: 1. Fix predicate for detecting MSVC - isOSMSVCRT(). 2. Use switch on BuiltinID instead of string matching for "fma". https://reviews.llvm.org/D39641 Files: include/clang/Basic/Builtins.def lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaDecl.cpp test/CodeGen/libcalls.c test/CodeGen/math-builtins.c test/CodeGen/math-libcalls.c Index: test/CodeGen/math-libcalls.c === --- test/CodeGen/math-libcalls.c +++ test/CodeGen/math-libcalls.c @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm %s | FileCheck %s -check-prefix=NO__ERRNO -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm %s | FileCheck %s --check-prefix=NO__ERRNO +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO +// RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU +// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN // Test attributes and builtin codegen of math library calls. @@ -145,9 +147,9 @@ // NO__ERRNO: declare double @cbrt(double) [[READNONE]] // NO__ERRNO: declare float @cbrtf(float) [[READNONE]] // NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]] -// HAS_ERRNO: declare double @cbrt(double) [[NOT_READNONE]] -// HAS_ERRNO: declare float @cbrtf(float) [[NOT_READNONE]] -// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[NOT_READNONE]] +// HAS_ERRNO: declare double @cbrt(double) [[READNONE]] +// HAS_ERRNO: declare float @cbrtf(float) [[READNONE]] +// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80) [[READNONE]] ceil(f); ceilf(f); ceill(f); @@ -244,9 +246,20 @@ // NO__ERRNO: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC]] // NO__ERRNO: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]] // NO__ERRNO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]] -// HAS_ERRNO: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]] -// HAS_ERRNO: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]] -// HAS_ERRNO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]] +// HAS_ERRNO: declare double @fma(double, double, double) [[NOT_READNONE]] +// HAS_ERRNO: declare float @fmaf(float, float, float) [[NOT_READNONE]] +// HAS_ERRNO: declare x86_fp80 @fmal(x86_fp80, x86_fp80, x86_fp80) [[NOT_READNONE]] + +// On GNU or Win, fma never sets errno, so we can convert to the intrinsic. + +// HAS_ERRNO_GNU: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]] +// HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]] +// HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]] + +// HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]] +// HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]] +// Long double is just double on win, so no f80 use/declaration. +// HAS_ERRNO_WIN-NOT: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) fmax(f,f); fmaxf(f,f); fmaxl(f,f); @@ -528,5 +541,6 @@ // HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } // HAS_ERRNO: attributes [[READONLY]] = { {{.*}}readonly{{.*}} } -// HAS_ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} } +// HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} } +// HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} } Index: test/CodeGen/math-builtins.c === --- test/CodeGen/math-builtins.c +++ test/CodeGen/math-builtins.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm %s | FileCheck %s -check-prefix=NO__ERRNO // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO +// RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU +// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN // Test attributes and codegen of math builtins. @@ -175,9 +177,9 @@ // NO__ERRNO: declare double
[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer
Rakete added a comment. @lichray Isn't [dcl.type.auto.deduct] only for `auto` and `decltype(auto)`? Class template argument deduction is in [dcl.type.class.deduct], which doesn't seem to disallow declarations without an initializer. About that `extern` business, yes that's indeed counter intuitive and weird. Couldn't find anything in the standard prohibiting this though, but I'm not so good at that either. https://reviews.llvm.org/D38216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer
lichray added a comment. The standard hasn't allowed deducing any placeholder type without an initializer (10.1.7.4.1 [dcl.type.auto.deduct]/2) yet. It's unclear to me what extern A x; wants to archive. Usually when people writing `extern` then expect an initializer to appear somewhere else, but with this declaration, defining A x = ...; later may fail by resolving to a different type, which feels... interesting. https://reviews.llvm.org/D38216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r315614 - [Sema] Diagnose tautological comparison with type's min/max values
On Fri, Nov 10, 2017 at 9:14 PM, Hans Wennborgwrote: > On Thu, Oct 12, 2017 at 2:33 PM, Roman Lebedev via cfe-commits > wrote: >> On Fri, Oct 13, 2017 at 12:12 AM, Nico Weber wrote: >>> Huh, I consider clang not warning on this a feature, not a bug. Why are we >>> trying to match what gcc does here? >> Because i have been bitten by this more than once. >> It did result in big amount of wasted time, and this "thread": >> https://lists.llvm.org/pipermail/llvm-dev/2017-August/116390.html >> >> As with all the clang diagnostics, you can disable them >> I personally don't have any opinion on comparisons with >> std::numeric_limits<...>::{min,max}() > To disable the new warning Will the https://reviews.llvm.org/D39462 address the reasons for disabling it? > but keep the ones we used to have enabled, > we now need to pass -Wno-tautological-constant-compare > -Wtautological-unsigned-zero-compare > -Wtautological-constant-out-of-range-compare, which is quite a > mouthful. It would perhaps be better if the new warning could have > been behind a flag that could be disabled separately. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38216: [C++17] Fix class template argument deduction for default constructors without an initializer
Rakete updated this revision to Diff 122576. Rakete added a comment. Slight change + rebased + friendly ping :) https://reviews.llvm.org/D38216 Files: lib/Sema/SemaDecl.cpp test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp test/Parser/cxx1z-class-template-argument-deduction.cpp Index: test/Parser/cxx1z-class-template-argument-deduction.cpp === --- test/Parser/cxx1z-class-template-argument-deduction.cpp +++ test/Parser/cxx1z-class-template-argument-deduction.cpp @@ -52,7 +52,7 @@ operator A(); // expected-error {{requires template arguments; argument deduction not allowed in conversion function type}} - static A x; // expected-error {{declaration of variable 'x' with deduced type 'A' requires an initializer}} + static A x; static constexpr A y = 0; }; @@ -114,7 +114,6 @@ (void)A{n}; (void)new A(n); (void)new A{n}; -// FIXME: We should diagnose the lack of an initializer here. (void)new A; } } @@ -127,7 +126,7 @@ auto k() -> A; // expected-error{{requires template arguments}} - A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}} + A a; A b = 0; const A c = 0; A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}} Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp === --- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp +++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp @@ -5,8 +5,7 @@ A(int) -> A; static constexpr inline const volatile A a = {}; // ok, specifiers are permitted -// FIXME: There isn't really a good reason to reject this. -A b; // expected-error {{requires an initializer}} +A b; A c [[]] {}; A d = {}, e = {}; @@ -13,6 +12,6 @@ A f(0), g{}; // expected-error {{template arguments deduced as 'A' in declaration of 'f' and deduced as 'A' in declaration of 'g'}} struct B { - static A a; // expected-error {{requires an initializer}} + static A a; }; -extern A x; // expected-error {{requires an initializer}} +extern A x; Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10182,7 +10182,8 @@ assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type"); // C++11 [dcl.spec.auto]p3 - if (!Init) { + // Except for class argument deduction. + if (!Init && !isa(Deduced)) { assert(VDecl && "no init for init capture deduction?"); Diag(VDecl->getLocation(), diag::err_auto_var_requires_init) << VDecl->getDeclName() << Type; @@ -10202,8 +10203,9 @@ VDecl->getLocation(), DirectInit, Init); // FIXME: Initialization should not be taking a mutable list of inits. SmallVectorInitsCopy(DeduceInits.begin(), DeduceInits.end()); -return DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind, - InitsCopy); + +return DeduceTemplateSpecializationFromInitializer( + TSI, Entity, Kind, Init ? InitsCopy : MutableArrayRef ()); } if (DirectInit) { Index: test/Parser/cxx1z-class-template-argument-deduction.cpp === --- test/Parser/cxx1z-class-template-argument-deduction.cpp +++ test/Parser/cxx1z-class-template-argument-deduction.cpp @@ -52,7 +52,7 @@ operator A(); // expected-error {{requires template arguments; argument deduction not allowed in conversion function type}} - static A x; // expected-error {{declaration of variable 'x' with deduced type 'A' requires an initializer}} + static A x; static constexpr A y = 0; }; @@ -114,7 +114,6 @@ (void)A{n}; (void)new A(n); (void)new A{n}; -// FIXME: We should diagnose the lack of an initializer here. (void)new A; } } @@ -127,7 +126,7 @@ auto k() -> A; // expected-error{{requires template arguments}} - A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}} + A a; A b = 0; const A c = 0; A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}} Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp === --- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp +++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp @@ -5,8 +5,7 @@ A(int) -> A; static constexpr inline const volatile A a = {}; // ok, specifiers are permitted -// FIXME: There isn't really a good reason to reject this. -A b; // expected-error {{requires an initializer}} +A b; A c [[]] {}; A d = {}, e = {};
[PATCH] D39810: [python] [tests] Fix test_linkage for unique external linkage
mgorny updated this revision to Diff 122575. mgorny retitled this revision from "[clang] [python] [tests] Disable the broken unique-external linkage test" to "[python] [tests] Fix test_linkage for unique external linkage". mgorny edited the summary of this revision. mgorny added reviewers: jbcoe, aaron.ballman, frutiger. mgorny added a comment. Yay, I've found a way to get the desired linkage! ;-) https://reviews.llvm.org/D39810 Files: bindings/python/tests/cindex/test_linkage.py Index: bindings/python/tests/cindex/test_linkage.py === --- bindings/python/tests/cindex/test_linkage.py +++ bindings/python/tests/cindex/test_linkage.py @@ -15,7 +15,8 @@ tu = get_tu(""" void foo() { int no_linkage; } static int internal; -namespace { extern int unique_external; } +namespace { struct unique_external_type {} } +unique_external_type unique_external; extern int external; """, lang = 'cpp') Index: bindings/python/tests/cindex/test_linkage.py === --- bindings/python/tests/cindex/test_linkage.py +++ bindings/python/tests/cindex/test_linkage.py @@ -15,7 +15,8 @@ tu = get_tu(""" void foo() { int no_linkage; } static int internal; -namespace { extern int unique_external; } +namespace { struct unique_external_type {} } +unique_external_type unique_external; extern int external; """, lang = 'cpp') ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39937: [Sema] Improve diagnostics for const- and ref-qualified member functions
jtbandes created this revision. Adjust wording for const-qualification mismatch to be a little more clear. Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see https://reviews.llvm.org/rL119336): Before: error: cannot initialize object parameter of type 'X0' with an expression of type 'X0' After: error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier https://reviews.llvm.org/D39937 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaOverload.cpp test/CXX/over/over.match/over.match.funcs/p4-0x.cpp test/SemaCXX/copy-initialization.cpp Index: test/SemaCXX/copy-initialization.cpp === --- test/SemaCXX/copy-initialization.cpp +++ test/SemaCXX/copy-initialization.cpp @@ -26,7 +26,7 @@ }; // PR3600 -void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}} +void test(const foo *P) { P->bar(); } // expected-error{{'this' argument to member function 'bar' has type 'const foo', but function is not marked const}} namespace PR6757 { struct Foo { Index: test/CXX/over/over.match/over.match.funcs/p4-0x.cpp === --- test/CXX/over/over.match/over.match.funcs/p4-0x.cpp +++ test/CXX/over/over.match/over.match.funcs/p4-0x.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics template T (); template T &(); @@ -20,6 +19,10 @@ void g(); + void lvalue() &; // expected-note 2 {{'lvalue' declared here}} + void const_lvalue() const&; + void rvalue() &&; // expected-note {{'rvalue' declared here}} + int +(const X0&) &; float +(const X0&) &&; @@ -44,6 +47,18 @@ int = lvalue().ft(1); float = xvalue().ft(2); float = prvalue().ft(3); + + lvalue().lvalue(); + lvalue().const_lvalue(); + lvalue().rvalue(); // expected-error {{'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier}} + + xvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}} + xvalue().const_lvalue(); + xvalue().rvalue(); + + prvalue().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}} + prvalue().const_lvalue(); + prvalue().rvalue(); } void test_ref_qualifier_binding_with_surrogates() { Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -5145,7 +5145,8 @@ *this, From->getLocStart(), From->getType(), FromClassification, Method, Method->getParent()); if (ICS.isBad()) { -if (ICS.Bad.Kind == BadConversionSequence::bad_qualifiers) { +switch (ICS.Bad.Kind) { +case BadConversionSequence::bad_qualifiers: { Qualifiers FromQs = FromRecordType.getQualifiers(); Qualifiers ToQs = DestType.getQualifiers(); unsigned CVR = FromQs.getCVRQualifiers() & ~ToQs.getCVRQualifiers(); @@ -5158,10 +5159,27 @@ << Method->getDeclName(); return ExprError(); } + break; +} + +case BadConversionSequence::lvalue_ref_to_rvalue: +case BadConversionSequence::rvalue_ref_to_lvalue: { + bool IsRValueQualified = +Method->getRefQualifier() == RefQualifierKind::RQ_RValue; + Diag(From->getLocStart(), diag::err_member_function_call_bad_ref) +<< Method->getDeclName() << FromClassification.isRValue() +<< IsRValueQualified; + Diag(Method->getLocation(), diag::note_previous_decl) +<< Method->getDeclName(); + return ExprError(); +} + +default: + break; } return Diag(From->getLocStart(), -diag::err_implicit_object_parameter_init) +diag::err_member_function_call_other) << ImplicitParamRecordType << FromRecordType << From->getSourceRange(); } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -1582,12 +1582,20 @@ def ext_pure_function_definition : ExtWarn< "function definition with pure-specifier is a Microsoft extension">, InGroup; -def err_implicit_object_parameter_init : Error< - "cannot initialize object parameter of type %0 with an expression " - "of type %1">; def err_qualified_member_of_unrelated : Error< "%q0 is not a member of class %1">; +def err_member_function_call_bad_ref : Error< + "'this' argument to member function %0 is an %select{lvalue|rvalue}1, " + "but function has %select{non-const lvalue|rvalue}2