Re: [PATCH] D16579: Warn if friend function depends on template parameters.
Could someone provide a feedback? Thanks, --Serge 2016-01-26 20:55 GMT+06:00 Serge Pavlov : > sepavloff created this revision. > sepavloff added a subscriber: cfe-commits. > > Declaration of friend function may depend on template parameters, > however it does not become a template function: > > template class C1 { > friend void func(T x); > }; > > It may be not obvious for user, so compiler could emit a warning in > such case. This patch implements appropriate warning, the wording is > taken from GCC message. The patch fixes PR23342. > > http://reviews.llvm.org/D16579 > > Files: > include/clang/Basic/DiagnosticGroups.td > include/clang/Basic/DiagnosticSemaKinds.td > lib/Sema/SemaDecl.cpp > test/CXX/drs/dr3xx.cpp > test/CXX/drs/dr5xx.cpp > test/CXX/temp/temp.decls/temp.friend/p1.cpp > test/PCH/cxx-templates.cpp > test/PCH/cxx-templates.h > test/SemaCXX/friend.cpp > test/SemaCXX/overload-call.cpp > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.
djasper added a comment. Thanks for looking at this. Please also add a test in unittests/Format/FormatTest.cpp. Comment at: lib/Format/TokenAnnotator.cpp:507 @@ -506,3 +506,3 @@ !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) { -if (Tok->Previous->is(tok::r_paren)) +if (Tok->Previous->is(tok::r_paren) || Tok->Previous->is(tok::kw_noexcept)) Tok->Type = TT_CtorInitializerColon; Use Tok->Previous->isOneOf(tok::r_paren, tok_kw_noexcept) http://reviews.llvm.org/D17621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17622: [PGO] clang cc1 option change to enable IR level instrumenation
silvas added a comment. Thanks for splitting this out. I think the `-fprofile-instrument=llvm` is straightforward and uncontroversial. Let's focus this review on that and split the others into a separate review. But a quick preview of my thoughs about `-fprofile-instrument={llvm,clang}-use`: I think that fully decoupling the cc1 options from the driver options like you are doing here is a good cleanup, but we need a more refined approach. For example, the current patch has "use" modes as mutually exclusive with the "gen" modes, which doesn't make sense. In fact, we have already seen a situation where we may want to have "use" and "gen" in the same clang invocation: for profile guided MST instr. And I don't see a reason to artificially prohibit FE "use" to annotate MD_prof metadata and then use that metadata for profile guided MST instr (however, it would be a strange workflow for users...). Perhaps something like `-fprofile-instrument-use={llvm,clang}` which sets a CodeGenOpt `ProfileUse` which is either {None, Clang, LLVM}. We can use a common PGOInstrumentor enum for both, since there is a 1:1 mapping between the instrumentor and its corresponding "use" logic. In the long run I imagine we will want two mirror options `-fpgo-gen={none,llvm,clang}` and `-fpgo-use={none,llvm,clang}`, but the details of renaming to the final state can wait until we clearly see the right design (this is cc1 so it is easy to refactor as needed later). http://reviews.llvm.org/D17622 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17627: Fix false positives for for-loop-analysis warning
rtrieu added a comment. This seems rather strange. Usually, a OpaqueValueExpr will hold an expression that is held elsewhere in the AST. However, in this case, it appears that all the references to --i are all behind OpaqueValueExpr's, so they aren't processed. `-CStyleCastExpr 0x5675d30 'void' `-PseudoObjectExpr 0x5675d00 'id':'id' |-ObjCSubscriptRefExpr 0x5675c90 '' lvalue Kind=ArraySubscript GetterForArray="(null)" SetterForArray="(null) | |-OpaqueValueExpr 0x5675c50 'MyArray *' | | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | | `-DeclRefExpr 0x5675b80 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' | `-OpaqueValueExpr 0x5675c70 'unsigned int' | `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' | `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int' |-OpaqueValueExpr 0x5675c50 'MyArray *' | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | `-DeclRefExpr 0x5675b80 'void' `-PseudoObjectExpr 0x5675d00 'id':'id' |-ObjCSubscriptRefExpr 0x5675c90 '' lvalue Kind=ArraySubscript GetterForArray="(null)" SetterForArray="(null) | |-OpaqueValueExpr 0x5675c50 'MyArray *' | | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | | `-DeclRefExpr 0x5675b80 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' | `-OpaqueValueExpr 0x5675c70 'unsigned int' | `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' | `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int' |-OpaqueValueExpr 0x5675c50 'MyArray *' | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | `-DeclRefExpr 0x5675b80 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' |-OpaqueValueExpr 0x5675c70 'unsigned int' | `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' | `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int' `-ObjCMessageExpr 0x5675cc8 'id':'id' selector=objectAtIndexedSubscript: |-OpaqueValueExpr 0x5675c50 'MyArray *' | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | `-DeclRefExpr 0x5675b80 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' `-OpaqueValueExpr 0x5675c70 'unsigned int' `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int'l:11> 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' |-OpaqueValueExpr 0x5675c70 'unsigned int' | `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' | `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int' `-ObjCMessageExpr 0x5675cc8 'id':'id' selector=objectAtIndexedSubscript: |-OpaqueValueExpr 0x5675c50 'MyArray *' | `-ImplicitCastExpr 0x5675bf0 'MyArray *' | `-DeclRefExpr 0x5675b80 'MyArray *' lvalue Var 0x56756d0 'test' 'MyArray *' `-OpaqueValueExpr 0x5675c70 'unsigned int' `-UnaryOperator 0x5675bd0 'unsigned int' prefix '--' `-DeclRefExpr 0x5675ba8 'unsigned int' lvalue Var 0x56759e0 'i' 'unsigned int' Typically, we skip OpaqueValueExpr so that we don't process the same expression multiple times. I don't know enough about Objective C to know whether this is the intended pattern or an oversight. Instead of visiting all the sub-expressions of OpaqueValueExpr's, try to make a tighter visitor to avoid repeating work. I think checking the sub-expressions of ObjCSubscriptRefExpr, and looking through the OpaqueValueExpr's there would be the best way for this. http://reviews.llvm.org/D17627 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator
pxli168 added inline comments. Comment at: lib/Sema/SemaExpr.cpp:6194-6203 @@ +6193,12 @@ + + incompatTy = S.Context.getPointerType( + S.Context.getAddrSpaceQualType(S.Context.VoidTy, ResultAddrSpace)); + LHS = S.ImpCastExprToType(LHS.get(), incompatTy, +(lhQual.getAddressSpace() != ResultAddrSpace) +? CK_AddressSpaceConversion +: CK_BitCast); + RHS = S.ImpCastExprToType(RHS.get(), incompatTy, +(rhQual.getAddressSpace() != ResultAddrSpace) +? CK_AddressSpaceConversion +: CK_BitCast); +} else { I am quite confused by these codes. It seems in some situations you need both BitCast and AddressSpaceConversion. It seems the logic here is too complex. Maybe you can try to simplify it Comment at: lib/Sema/SemaExpr.cpp:6220-6232 @@ -6186,7 +6219,15 @@ ResultTy = S.Context.getBlockPointerType(ResultTy); - else + else { +auto ResultAddrSpace = ResultTy.getQualifiers().getAddressSpace(); +LHSCastKind = lhQual.getAddressSpace() == ResultAddrSpace + ? CK_BitCast + : CK_AddressSpaceConversion; +RHSCastKind = rhQual.getAddressSpace() == ResultAddrSpace + ? CK_BitCast + : CK_AddressSpaceConversion; ResultTy = S.Context.getPointerType(ResultTy); + } - LHS = S.ImpCastExprToType(LHS.get(), ResultTy, CK_BitCast); - RHS = S.ImpCastExprToType(RHS.get(), ResultTy, CK_BitCast); + LHS = S.ImpCastExprToType(LHS.get(), ResultTy, LHSCastKind); + RHS = S.ImpCastExprToType(RHS.get(), ResultTy, RHSCastKind); return ResultTy; Why change about block pointer? Block can not be used with ternary selection operator (?:) in OpenCL. Repository: rL LLVM http://reviews.llvm.org/D17412 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261976 - [Driver] Disable frame pointer elimination by default if target is
Author: ahatanak Date: Thu Feb 25 23:07:00 2016 New Revision: 261976 URL: http://llvm.org/viewvc/llvm-project?rev=261976&view=rev Log: [Driver] Disable frame pointer elimination by default if target is x86_64-pc-win32-macho. rdar://problem/24470634 Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/frame-pointer.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261976&r1=261975&r2=261976&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Thu Feb 25 23:07:00 2016 @@ -2955,6 +2955,8 @@ static bool shouldUseFramePointerForTarg switch (Triple.getArch()) { case llvm::Triple::x86: return !areOptimizationsEnabled(Args); +case llvm::Triple::x86_64: + return Triple.isOSBinFormatMachO(); case llvm::Triple::arm: case llvm::Triple::thumb: // Windows on ARM builds with FPO disabled to aid fast stack walking Modified: cfe/trunk/test/Driver/frame-pointer.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer.c?rev=261976&r1=261975&r2=261976&view=diff == --- cfe/trunk/test/Driver/frame-pointer.c (original) +++ cfe/trunk/test/Driver/frame-pointer.c Thu Feb 25 23:07:00 2016 @@ -10,6 +10,7 @@ // RUN: %clang -target x86_64-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-64 %s // RUN: %clang -target x86_64-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s // RUN: %clang -target x86_64-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s +// RUN: %clang -target x86_64-pc-win32-macho -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-MACHO-64 %s // Trust the above to get the optimizations right, and just test other targets // that want this by default. @@ -36,3 +37,4 @@ // CHECK2-64-NOT: -mdisable-fp-elim // CHECK3-64-NOT: -mdisable-fp-elim // CHECKs-64-NOT: -mdisable-fp-elim +// CHECK-MACHO-64: -mdisable-fp-elim ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker
rtrieu accepted this revision. rtrieu added a comment. This revision is now accepted and ready to land. LGTM The other issues brought up in this review can go in follow up patches. http://reviews.llvm.org/D15636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects
This revision was automatically updated to reflect the committed changes. Closed by commit rL261975: [MSVC Compat] Don't evaluate member base expressions w/o side effects (authored by majnemer). Changed prior to commit: http://reviews.llvm.org/D17619?vs=49109&id=49150#toc Repository: rL LLVM http://reviews.llvm.org/D17619 Files: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp Index: cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp === --- cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp +++ cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: cfe/trunk/lib/AST/ExprConstant.cpp === --- cfe/trunk/lib/AST/ExprConstant.cpp +++ cfe/trunk/lib/AST/ExprConstant.cpp @@ -4427,6 +4427,15 @@ void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); } + + /// Potentially visit a MemberExpr's base expression. + void VisitIgnoredBaseExpression(const Expr *E) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx)) + return; +VisitIgnoredValue(E); + } }; } @@ -4750,14 +4759,14 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { // Handle static data members. if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); +VisitIgnoredBaseExpression(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { if (MD->isStatic()) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return Success(MD); } } @@ -6078,7 +6087,7 @@ } bool VisitMemberExpr(const MemberExpr *E) { if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return true; } Index: cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp === --- cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp +++ cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: cfe/trunk/lib/AST/ExprConstant.cpp === --- cfe/trunk/lib/AST/ExprConstant.cpp +++ cfe/trunk/lib/AST/ExprConstant.cpp @@ -4427,6 +4427,15 @@ void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); } + + /// Potentially visit a MemberExpr's base expression. + void VisitIgnoredBaseExpression(const Expr *E) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx)) + return; +VisitIgnoredValue(E); + } }; } @@ -4750,14 +4759,14 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { // Handle static data members. if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); +VisitIgnoredBaseExpression(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { if (MD->isStatic()) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return Success(MD); } } @@ -6078,7 +6087,7 @@ } bool VisitMemberExpr(const MemberExpr *E) { if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261975 - [MSVC Compat] Don't evaluate member base expressions w/o side effects
Author: majnemer Date: Thu Feb 25 22:23:19 2016 New Revision: 261975 URL: http://llvm.org/viewvc/llvm-project?rev=261975&view=rev Log: [MSVC Compat] Don't evaluate member base expressions w/o side effects A member expression's base doesn't always have an impact on what the member decl would evaluate to. In such a case, the base is used as a poor man's scope qualifier. This fixes PR26738. Differential Revision: http://reviews.llvm.org/D17619 Added: cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=261975&r1=261974&r2=261975&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Feb 25 22:23:19 2016 @@ -4427,6 +4427,15 @@ public: void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); } + + /// Potentially visit a MemberExpr's base expression. + void VisitIgnoredBaseExpression(const Expr *E) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx)) + return; +VisitIgnoredValue(E); + } }; } @@ -4750,14 +4759,14 @@ bool LValueExprEvaluator::VisitCXXUuidof bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { // Handle static data members. if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); +VisitIgnoredBaseExpression(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { if (MD->isStatic()) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return Success(MD); } } @@ -6078,7 +6087,7 @@ public: } bool VisitMemberExpr(const MemberExpr *E) { if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return true; } Added: cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp?rev=261975&view=auto == --- cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp (added) +++ cfe/trunk/test/SemaCXX/ms-const-member-expr.cpp Thu Feb 25 22:23:19 2016 @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17367: [OpenMP] Code generation for target data directive
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2736-2738 @@ +2735,5 @@ + const Expr *IfCond = nullptr; + if (auto *C = S.getSingleClause()) { +IfCond = C->getCondition(); + } + Extra braces Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2742-2744 @@ +2741,5 @@ + const Expr *Device = nullptr; + if (auto *C = S.getSingleClause()) { +Device = C->getDevice(); + } + Extra braces http://reviews.llvm.org/D17367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17368: [OpenMP] Code generation for target enter data directive
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2758-2760 @@ +2757,5 @@ + const Expr *IfCond = nullptr; + if (auto *C = S.getSingleClause()) { +IfCond = C->getCondition(); + } + Extra braces Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2764-2766 @@ +2763,5 @@ + const Expr *Device = nullptr; + if (auto *C = S.getSingleClause()) { +Device = C->getDevice(); + } + Extra braces http://reviews.llvm.org/D17368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17629: [OpenMP] Fix parsing of delete map clause modifier in C++ mode.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG http://reviews.llvm.org/D17629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17369: [OpenMP] Code generation for target exit data directive
ABataev accepted this revision. This revision is now accepted and ready to land. Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2781-2783 @@ +2780,5 @@ + const Expr *IfCond = nullptr; + if (auto *C = S.getSingleClause()) { +IfCond = C->getCondition(); + } + Remove extra braces, not required for one line statement Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2787-2789 @@ +2786,5 @@ + const Expr *Device = nullptr; + if (auto *C = S.getSingleClause()) { +Device = C->getDevice(); + } + Extra braces http://reviews.llvm.org/D17369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261970 - [analyzer] Prune some incorrect \param doc comment annotations.
Author: dcoughlin Date: Thu Feb 25 21:41:31 2016 New Revision: 261970 URL: http://llvm.org/viewvc/llvm-project?rev=261970&view=rev Log: [analyzer] Prune some incorrect \param doc comment annotations. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=261970&r1=261969&r2=261970&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Feb 25 21:41:31 2016 @@ -506,7 +506,7 @@ void ObjCDeallocChecker::diagnoseMissing assert(!LCtx->inTopFrame() || State->get().isEmpty()); } -/// Emits a warning if the current context is -dealloc and \param ReleasedValue +/// Emits a warning if the current context is -dealloc and ReleasedValue /// must not be directly released in a -dealloc. Returns true if a diagnostic /// was emitted. bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue, @@ -626,7 +626,7 @@ void ObjCDeallocChecker::initIdentifierI ReleaseSel = Ctx.Selectors.getSelector(0, &ReleaseII); } -/// Returns true if \param M is a call to '[super dealloc]'. +/// Returns true if M is a call to '[super dealloc]'. bool ObjCDeallocChecker::isSuperDeallocMessage( const ObjCMethodCall &M) const { if (M.getOriginExpr()->getReceiverKind() != ObjCMessageExpr::SuperInstance) @@ -642,7 +642,7 @@ ObjCDeallocChecker::getContainingObjCImp return cast(MD->getDeclContext()); } -/// Returns the property that shadowed by \param PropImpl if one exists and +/// Returns the property that shadowed by PropImpl if one exists and /// nullptr otherwise. const ObjCPropertyDecl *ObjCDeallocChecker::findShadowedPropertyDecl( const ObjCPropertyImplDecl *PropImpl) const { @@ -674,8 +674,8 @@ const ObjCPropertyDecl *ObjCDeallocCheck return nullptr; } -/// Remove the \param Value requiring a release from the tracked set for -/// \param Instance and return the resultant state. +/// Remove the Value requiring a release from the tracked set for +/// Instance and return the resultant state. ProgramStateRef ObjCDeallocChecker::removeValueRequiringRelease( ProgramStateRef State, SymbolRef Instance, SymbolRef Value) const { assert(Instance); @@ -729,7 +729,7 @@ ReleaseRequirement ObjCDeallocChecker::g llvm_unreachable("Unrecognized setter kind"); } -/// Returns the released value if \param M is a call to -release. Returns +/// Returns the released value if M is a call to -release. Returns /// nullptr otherwise. SymbolRef ObjCDeallocChecker::getValueExplicitlyReleased(const ObjCMethodCall &M, @@ -740,7 +740,7 @@ ObjCDeallocChecker::getValueExplicitlyRe return M.getReceiverSVal().getAsSymbol(); } -/// Returns the released value if \param M is a call a setter that releases +/// Returns the released value if M is a call a setter that releases /// and nils out its underlying instance variable. SymbolRef ObjCDeallocChecker::getValueReleasedByNillingOut(const ObjCMethodCall &M, @@ -779,15 +779,15 @@ ObjCDeallocChecker::getValueReleasedByNi } /// Returns true if the current context is a call to -dealloc and false -/// otherwise. If true, it also sets \param SelfValOut to the value of +/// otherwise. If true, it also sets SelfValOut to the value of /// 'self'. bool ObjCDeallocChecker::isInInstanceDealloc(const CheckerContext &C, SVal &SelfValOut) const { return isInInstanceDealloc(C, C.getLocationContext(), SelfValOut); } -/// Returns true if \param LCtx is a call to -dealloc and false -/// otherwise. If true, it also sets \param SelfValOut to the value of +/// Returns true if LCtx is a call to -dealloc and false +/// otherwise. If true, it also sets SelfValOut to the value of /// 'self'. bool ObjCDeallocChecker::isInInstanceDealloc(const CheckerContext &C, const LocationContext *LCtx, @@ -805,7 +805,7 @@ bool ObjCDeallocChecker::isInInstanceDea } /// Returns true if there is a call to -dealloc anywhere on the stack and false -/// otherwise. If true, it also sets \param InstanceValOut to the value of +/// otherwise. If true, it also sets InstanceValOut to the value of /// 'self' in the frame for -dealloc. bool ObjCDeallocChecker::instanceDeallocIsOnStack(const CheckerContext &C, SVal &InstanceValOut) const { @@ -821,7 +821,7 @@ bool ObjCDeallocChecker::instanceDealloc return false; } -/// Returns true if the \param ID is a class in which which is known to have +/// Returns true if the ID is a class in which which is known to have /// a separate teardown lifecycle. In this case, -de
Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Repository: rL LLVM http://reviews.llvm.org/D17170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4002 @@ +4001,3 @@ +static llvm::Value * +emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF, + const OMPExecutableDirective &D, I still don't like the generation of some functions, that, generally speaking, are not required. Could you try to add a new 'class CGOpenMPInlinedRegionInfo' like class, that will be able to handle not captured variables in expressions? http://reviews.llvm.org/D17019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r261767 - Add whole-program vtable optimization feature to Clang.
Thanks a lot! Steven > On Feb 25, 2016, at 7:12 PM, Peter Collingbourne wrote: > > (I don't understand why this flag needs to exist, but) I've implemented a > fix in r261960. > > Peter > > On Thu, Feb 25, 2016 at 06:50:52PM -0800, Steven Wu wrote: >> Hi Peter >> >> I notice after this commit, I can no longer use cmake option >> -DCLANG_TOOL_DRIVER_BUILD=OFF to choose not to build and link the clang >> driver. When using -DCLANG_TOOL_DRIVER_BUILD=OFF, clang target will not >> exist so cmake will error on the line: >>> +add_dependencies(clang vtables_blacklist) >> >> Is it possible to move this line to tools/driver/CMakeLists.txt? >> >> Thanks >> >> Steven >> >> >>> On Feb 24, 2016, at 12:46 PM, Peter Collingbourne via cfe-commits >>> wrote: >>> >>> Author: pcc >>> Date: Wed Feb 24 14:46:36 2016 >>> New Revision: 261767 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=261767&view=rev >>> Log: >>> Add whole-program vtable optimization feature to Clang. >>> >>> This patch introduces the -fwhole-program-vtables flag, which enables the >>> whole-program vtable optimization feature (D16795) in Clang. >>> >>> Differential Revision: http://reviews.llvm.org/D16821 >>> >>> Added: >>> cfe/trunk/runtime/vtables_blacklist.txt >>> cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp >>> - copied, changed from r261762, >>> cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp >>> cfe/trunk/test/CodeGenCXX/bitsets.cpp >>> - copied, changed from r261762, cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp >>> cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt >>> cfe/trunk/test/Driver/whole-program-vtables.c >>> Removed: >>> cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp >>> cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp >>> Modified: >>> cfe/trunk/docs/UsersManual.rst >>> cfe/trunk/include/clang/Driver/Options.td >>> cfe/trunk/include/clang/Frontend/CodeGenOptions.def >>> cfe/trunk/include/clang/Frontend/CodeGenOptions.h >>> cfe/trunk/lib/CodeGen/CGClass.cpp >>> cfe/trunk/lib/CodeGen/CGExprCXX.cpp >>> cfe/trunk/lib/CodeGen/CGVTables.cpp >>> cfe/trunk/lib/CodeGen/CodeGenFunction.h >>> cfe/trunk/lib/CodeGen/CodeGenModule.cpp >>> cfe/trunk/lib/CodeGen/CodeGenModule.h >>> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >>> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp >>> cfe/trunk/lib/Driver/Tools.cpp >>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp >>> cfe/trunk/runtime/CMakeLists.txt >>> >>> Modified: cfe/trunk/docs/UsersManual.rst >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=261767&r1=261766&r2=261767&view=diff >>> == >>> --- cfe/trunk/docs/UsersManual.rst (original) >>> +++ cfe/trunk/docs/UsersManual.rst Wed Feb 24 14:46:36 2016 >>> @@ -1053,6 +1053,21 @@ are listed below. >>> the behavior of sanitizers in the ``cfi`` group to allow checking >>> of cross-DSO virtual and indirect calls. >>> >>> +.. option:: -fwhole-program-vtables >>> + >>> + Enable whole-program vtable optimizations, such as single-implementation >>> + devirtualization and virtual constant propagation. Requires ``-flto``. >>> + >>> + By default, the compiler will assume that all type hierarchies are >>> + closed except those in the ``std`` namespace, the ``stdext`` namespace >>> + and classes with the ``__declspec(uuid())`` attribute. >>> + >>> +.. option:: -fwhole-program-vtables-blacklist=path >>> + >>> + Allows the user to specify the path to a list of additional classes to >>> + blacklist from whole-program vtable optimizations. This list is in the >>> + :ref:`CFI blacklist ` format. >>> + >>> .. option:: -fno-assume-sane-operator-new >>> >>> Don't assume that the C++'s new operator is sane. >>> >>> Modified: cfe/trunk/include/clang/Driver/Options.td >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261767&r1=261766&r2=261767&view=diff >>> == >>> --- cfe/trunk/include/clang/Driver/Options.td (original) >>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 24 14:46:36 2016 >>> @@ -1124,6 +1124,13 @@ def fvisibility_inlines_hidden : Flag<[" >>> def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, >>> Group, >>> HelpText<"Give global types 'default' visibility and global functions and " >>> "variables 'hidden' visibility by default">; >>> +def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, >>> Group, >>> + Flags<[CC1Option]>, >>> + HelpText<"Enables whole-program vtable optimization. Requires -flto">; >>> +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, >>> Group; >>> +def fwhole_program_vtables_blacklist_EQ : Joined<["-"], >>> "fwhole-program-vtables-blacklist=">, >>> + Group, Flags<[CC1Option]>, >>> + HelpText<"Path to a blacklist file for whole-program vtable >>> optimi
Re: [PATCH] D17547: [OpenMP] Add support for multidimensional array sections in map clause SEMA.
ABataev added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7767-7768 @@ -7766,4 +7766,4 @@ "bit fields cannot be used to specify storage in a map clause">; -def err_omp_array_section_in_rightmost_expression : Error< - "array section can only be associated with the rightmost variable in a map clause expression">; +def err_omp_array_section_leads_to_non_contiguous_storage : Error< + "employed array section is or can be incompatible with contiguous storage requirements">; def err_omp_union_type_not_allowed : Error< If you say 'can be' incompatible, then this must be a warning, not an error Comment at: lib/Sema/SemaOpenMP.cpp:8988-8995 @@ +8987,10 @@ + + // If this is an array subscript, it refers to the whole size if the size of + // the dimension is constant and equals 1. Also, an array section assumes the + // format of an array subscript if no colon is used. + if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) { +if (auto *ATy = dyn_cast(BaseQTy.getTypePtr())) + return ATy->getSize().getSExtValue() == 1; +return false; + } + I can't agree with that. For example: ``` const int n = 0; arr[n:] ``` It won't work with your solution, though we shall support it Comment at: lib/Sema/SemaOpenMP.cpp:9208-9220 @@ -9113,6 +9207,15 @@ + // Determine the dimension we care about. We need to skip all the nested + // array sections to determine that. + unsigned Dimension = 0; + auto *BaseE = E; + while (auto *SE = dyn_cast(BaseE)) { +BaseE = SE->getBase()->IgnoreParenImpCasts(); +++Dimension; + } + // OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1] // If the type of a list item is a reference to a type T then the type // will be considered to be T for all purposes of this clause. - QualType CurType = E->getType(); + QualType CurType = BaseE->getType(); if (CurType->isReferenceType()) OMPArraySectionExpr has static function getBaseOriginalType() http://reviews.llvm.org/D17547 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261962 - OpenMPClause.h: Fix typo in \param. [-Wdocumentation]
Author: chapuni Date: Thu Feb 25 21:15:09 2016 New Revision: 261962 URL: http://llvm.org/viewvc/llvm-project?rev=261962&view=rev Log: OpenMPClause.h: Fix typo in \param. [-Wdocumentation] Modified: cfe/trunk/include/clang/AST/OpenMPClause.h Modified: cfe/trunk/include/clang/AST/OpenMPClause.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=261962&r1=261961&r2=261962&view=diff == --- cfe/trunk/include/clang/AST/OpenMPClause.h (original) +++ cfe/trunk/include/clang/AST/OpenMPClause.h Thu Feb 25 21:15:09 2016 @@ -1524,7 +1524,7 @@ public: /// lastprivate clause. /// \param PreInit Statement that must be executed before entering the OpenMP /// region with this clause. - /// \param PostInit Expression that must be executed after exit from the + /// \param PostUpdate Expression that must be executed after exit from the /// OpenMP region with this clause. /// static OMPLastprivateClause * ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261963 - Checkers/CheckObjCDealloc.cpp: Prune "\param". [-Wdocumentation]
Author: chapuni Date: Thu Feb 25 21:15:13 2016 New Revision: 261963 URL: http://llvm.org/viewvc/llvm-project?rev=261963&view=rev Log: Checkers/CheckObjCDealloc.cpp: Prune "\param". [-Wdocumentation] Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=261963&r1=261962&r2=261963&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Feb 25 21:15:13 2016 @@ -635,7 +635,7 @@ bool ObjCDeallocChecker::isSuperDeallocM return M.getSelector() == DeallocSel; } -/// Returns the ObjCImplDecl containing the method declaration in \param LCtx. +/// Returns the ObjCImplDecl containing the method declaration in LCtx. const ObjCImplDecl * ObjCDeallocChecker::getContainingObjCImpl(const LocationContext *LCtx) const { auto *MD = cast(LCtx->getDecl()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261961 - [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr
Author: pxl Date: Thu Feb 25 21:13:03 2016 New Revision: 261961 URL: http://llvm.org/viewvc/llvm-project?rev=261961&view=rev Log: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr Summary: OpenCL access qualifiers are now not only used for image types, refine it to avoid misleading, Add semacheck for OpenCL access qualifier as well as test caees. Reviewers: pekka.jaaskelainen, Anastasia, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D16040 Added: cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/Parser/opencl-image-access.cl cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl cfe/trunk/test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=261961&r1=261960&r2=261961&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Thu Feb 25 21:13:03 2016 @@ -664,7 +664,7 @@ def OpenCLUnrollHint : InheritableAttr { // This attribute is both a type attribute, and a declaration attribute (for // parameter variables). -def OpenCLImageAccess : Attr { +def OpenCLAccess : Attr { let Spellings = [Keyword<"__read_only">, Keyword<"read_only">, Keyword<"__write_only">, Keyword<"write_only">, Keyword<"__read_write">, Keyword<"read_write">]; @@ -675,7 +675,7 @@ def OpenCLImageAccess : Attr { Keyword<"read_write">]>, Accessor<"isWriteOnly", [Keyword<"__write_only">, Keyword<"write_only">]>]; - let Documentation = [Undocumented]; + let Documentation = [OpenCLAccessDocs]; } def OpenCLPrivateAddressSpace : TypeAttr { Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=261961&r1=261960&r2=261961&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Feb 25 21:13:03 2016 @@ -1581,6 +1581,32 @@ s6.11.5 for details. }]; } +def OpenCLAccessDocs : Documentation { + let Category = DocCatStmt; + let Content = [{ +The access qualifiers must be used with image object arguments or pipe arguments +to declare if they are being read or written by a kernel or function. + +The read_only/__read_only, write_only/__write_only and read_write/__read_write +names are reserved for use as access qualifiers and shall not be used otherwise. + + .. code-block:: c + kernel void + foo (read_only image2d_t imageA, + write_only image2d_t imageB) + { + ... + } + +In the above example imageA is a read-only 2D image object, and imageB is a +write-only 2D image object. + +The read_write (or __read_write) qualifier can not be used with pipe. + +More details can be found in the OpenCL C language Spec v2.0, Section 6.6. + }]; +} + def DocOpenCLAddressSpaces : DocumentationCategory<"OpenCL Address Spaces"> { let Content = [{ The address space qualifier may be used to specify the region of memory that is Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=261961&r1=261960&r2=261961&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Feb 25 21:13:03 2016 @@ -7735,6 +7735,14 @@ def err_opencl_builtin_pipe_invalid_arg def err_opencl_builtin_pipe_invalid_access_modifier : Error< "invalid pipe access modifier (expecting %0)">; +// OpenCL access qualifier +def err_opencl_invalid_access_qualifier : Error< + "access qualifier can only be used for pipe and image type">; +def err_opencl_invalid_read_write : Error< + "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL2.0 version}2">; +def err_opencl_multiple_access_qualifiers : Error< + "multiple access qualifiers">; + // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< "OpenCL does not support the '%0' %select{type qualifier|storage class specifier}1">; Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=26
Re: r261767 - Add whole-program vtable optimization feature to Clang.
(I don't understand why this flag needs to exist, but) I've implemented a fix in r261960. Peter On Thu, Feb 25, 2016 at 06:50:52PM -0800, Steven Wu wrote: > Hi Peter > > I notice after this commit, I can no longer use cmake option > -DCLANG_TOOL_DRIVER_BUILD=OFF to choose not to build and link the clang > driver. When using -DCLANG_TOOL_DRIVER_BUILD=OFF, clang target will not exist > so cmake will error on the line: > > +add_dependencies(clang vtables_blacklist) > > Is it possible to move this line to tools/driver/CMakeLists.txt? > > Thanks > > Steven > > > > On Feb 24, 2016, at 12:46 PM, Peter Collingbourne via cfe-commits > > wrote: > > > > Author: pcc > > Date: Wed Feb 24 14:46:36 2016 > > New Revision: 261767 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=261767&view=rev > > Log: > > Add whole-program vtable optimization feature to Clang. > > > > This patch introduces the -fwhole-program-vtables flag, which enables the > > whole-program vtable optimization feature (D16795) in Clang. > > > > Differential Revision: http://reviews.llvm.org/D16821 > > > > Added: > >cfe/trunk/runtime/vtables_blacklist.txt > >cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp > > - copied, changed from r261762, > > cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp > >cfe/trunk/test/CodeGenCXX/bitsets.cpp > > - copied, changed from r261762, cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp > >cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt > >cfe/trunk/test/Driver/whole-program-vtables.c > > Removed: > >cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp > >cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp > > Modified: > >cfe/trunk/docs/UsersManual.rst > >cfe/trunk/include/clang/Driver/Options.td > >cfe/trunk/include/clang/Frontend/CodeGenOptions.def > >cfe/trunk/include/clang/Frontend/CodeGenOptions.h > >cfe/trunk/lib/CodeGen/CGClass.cpp > >cfe/trunk/lib/CodeGen/CGExprCXX.cpp > >cfe/trunk/lib/CodeGen/CGVTables.cpp > >cfe/trunk/lib/CodeGen/CodeGenFunction.h > >cfe/trunk/lib/CodeGen/CodeGenModule.cpp > >cfe/trunk/lib/CodeGen/CodeGenModule.h > >cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp > >cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > >cfe/trunk/lib/Driver/Tools.cpp > >cfe/trunk/lib/Frontend/CompilerInvocation.cpp > >cfe/trunk/runtime/CMakeLists.txt > > > > Modified: cfe/trunk/docs/UsersManual.rst > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=261767&r1=261766&r2=261767&view=diff > > == > > --- cfe/trunk/docs/UsersManual.rst (original) > > +++ cfe/trunk/docs/UsersManual.rst Wed Feb 24 14:46:36 2016 > > @@ -1053,6 +1053,21 @@ are listed below. > >the behavior of sanitizers in the ``cfi`` group to allow checking > >of cross-DSO virtual and indirect calls. > > > > +.. option:: -fwhole-program-vtables > > + > > + Enable whole-program vtable optimizations, such as single-implementation > > + devirtualization and virtual constant propagation. Requires ``-flto``. > > + > > + By default, the compiler will assume that all type hierarchies are > > + closed except those in the ``std`` namespace, the ``stdext`` namespace > > + and classes with the ``__declspec(uuid())`` attribute. > > + > > +.. option:: -fwhole-program-vtables-blacklist=path > > + > > + Allows the user to specify the path to a list of additional classes to > > + blacklist from whole-program vtable optimizations. This list is in the > > + :ref:`CFI blacklist ` format. > > + > > .. option:: -fno-assume-sane-operator-new > > > >Don't assume that the C++'s new operator is sane. > > > > Modified: cfe/trunk/include/clang/Driver/Options.td > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261767&r1=261766&r2=261767&view=diff > > == > > --- cfe/trunk/include/clang/Driver/Options.td (original) > > +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 24 14:46:36 2016 > > @@ -1124,6 +1124,13 @@ def fvisibility_inlines_hidden : Flag<[" > > def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, > > Group, > > HelpText<"Give global types 'default' visibility and global functions and > > " > >"variables 'hidden' visibility by default">; > > +def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, > > Group, > > + Flags<[CC1Option]>, > > + HelpText<"Enables whole-program vtable optimization. Requires -flto">; > > +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, > > Group; > > +def fwhole_program_vtables_blacklist_EQ : Joined<["-"], > > "fwhole-program-vtables-blacklist=">, > > + Group, Flags<[CC1Option]>, > > + HelpText<"Path to a blacklist file for whole-program vtable > > optimization">; > > def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, >
r261960 - Make vtables_blacklist dependency conditional on existence of clang target.
Author: pcc Date: Thu Feb 25 21:07:33 2016 New Revision: 261960 URL: http://llvm.org/viewvc/llvm-project?rev=261960&view=rev Log: Make vtables_blacklist dependency conditional on existence of clang target. Modified: cfe/trunk/runtime/CMakeLists.txt Modified: cfe/trunk/runtime/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=261960&r1=261959&r2=261960&view=diff == --- cfe/trunk/runtime/CMakeLists.txt (original) +++ cfe/trunk/runtime/CMakeLists.txt Thu Feb 25 21:07:33 2016 @@ -142,5 +142,7 @@ add_custom_command(OUTPUT ${dst} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} COMMENT "Copying vtables blacklist") add_custom_target(vtables_blacklist DEPENDS ${dst}) -add_dependencies(clang vtables_blacklist) +if(TARGET clang) + add_dependencies(clang vtables_blacklist) +endif() install(FILES ${src} DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r261767 - Add whole-program vtable optimization feature to Clang.
Hi Peter I notice after this commit, I can no longer use cmake option -DCLANG_TOOL_DRIVER_BUILD=OFF to choose not to build and link the clang driver. When using -DCLANG_TOOL_DRIVER_BUILD=OFF, clang target will not exist so cmake will error on the line: > +add_dependencies(clang vtables_blacklist) Is it possible to move this line to tools/driver/CMakeLists.txt? Thanks Steven > On Feb 24, 2016, at 12:46 PM, Peter Collingbourne via cfe-commits > wrote: > > Author: pcc > Date: Wed Feb 24 14:46:36 2016 > New Revision: 261767 > > URL: http://llvm.org/viewvc/llvm-project?rev=261767&view=rev > Log: > Add whole-program vtable optimization feature to Clang. > > This patch introduces the -fwhole-program-vtables flag, which enables the > whole-program vtable optimization feature (D16795) in Clang. > > Differential Revision: http://reviews.llvm.org/D16821 > > Added: >cfe/trunk/runtime/vtables_blacklist.txt >cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp > - copied, changed from r261762, > cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp >cfe/trunk/test/CodeGenCXX/bitsets.cpp > - copied, changed from r261762, cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp >cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt >cfe/trunk/test/Driver/whole-program-vtables.c > Removed: >cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp >cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp > Modified: >cfe/trunk/docs/UsersManual.rst >cfe/trunk/include/clang/Driver/Options.td >cfe/trunk/include/clang/Frontend/CodeGenOptions.def >cfe/trunk/include/clang/Frontend/CodeGenOptions.h >cfe/trunk/lib/CodeGen/CGClass.cpp >cfe/trunk/lib/CodeGen/CGExprCXX.cpp >cfe/trunk/lib/CodeGen/CGVTables.cpp >cfe/trunk/lib/CodeGen/CodeGenFunction.h >cfe/trunk/lib/CodeGen/CodeGenModule.cpp >cfe/trunk/lib/CodeGen/CodeGenModule.h >cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp >cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp >cfe/trunk/lib/Driver/Tools.cpp >cfe/trunk/lib/Frontend/CompilerInvocation.cpp >cfe/trunk/runtime/CMakeLists.txt > > Modified: cfe/trunk/docs/UsersManual.rst > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=261767&r1=261766&r2=261767&view=diff > == > --- cfe/trunk/docs/UsersManual.rst (original) > +++ cfe/trunk/docs/UsersManual.rst Wed Feb 24 14:46:36 2016 > @@ -1053,6 +1053,21 @@ are listed below. >the behavior of sanitizers in the ``cfi`` group to allow checking >of cross-DSO virtual and indirect calls. > > +.. option:: -fwhole-program-vtables > + > + Enable whole-program vtable optimizations, such as single-implementation > + devirtualization and virtual constant propagation. Requires ``-flto``. > + > + By default, the compiler will assume that all type hierarchies are > + closed except those in the ``std`` namespace, the ``stdext`` namespace > + and classes with the ``__declspec(uuid())`` attribute. > + > +.. option:: -fwhole-program-vtables-blacklist=path > + > + Allows the user to specify the path to a list of additional classes to > + blacklist from whole-program vtable optimizations. This list is in the > + :ref:`CFI blacklist ` format. > + > .. option:: -fno-assume-sane-operator-new > >Don't assume that the C++'s new operator is sane. > > Modified: cfe/trunk/include/clang/Driver/Options.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261767&r1=261766&r2=261767&view=diff > == > --- cfe/trunk/include/clang/Driver/Options.td (original) > +++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 24 14:46:36 2016 > @@ -1124,6 +1124,13 @@ def fvisibility_inlines_hidden : Flag<[" > def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, > Group, > HelpText<"Give global types 'default' visibility and global functions and " >"variables 'hidden' visibility by default">; > +def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, > Group, > + Flags<[CC1Option]>, > + HelpText<"Enables whole-program vtable optimization. Requires -flto">; > +def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, > Group; > +def fwhole_program_vtables_blacklist_EQ : Joined<["-"], > "fwhole-program-vtables-blacklist=">, > + Group, Flags<[CC1Option]>, > + HelpText<"Path to a blacklist file for whole-program vtable optimization">; > def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>, > HelpText<"Treat signed integer overflow as two's complement">; > def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, > Flags<[CC1Option]>, > > Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=261767&r1=261766&r2=261767&view=diff > ==
Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target
pxli168 marked an inline comment as done. pxli168 added a comment. I think this is just a small change to help identify the which standard llvm-ir is using. And there is a SPIRV branch from Khronos https://github.com/KhronosGroup/SPIRV-LLVM We can start there and try to merge the spir-v support into the llvm.org trunk. http://reviews.llvm.org/D17596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16949: Fix for: Bug 5941 - improve diagnostic for * vs & confusion
On Tue, Feb 16, 2016 at 10:45 PM, David Blaikie wrote: > > > On Tue, Feb 16, 2016 at 10:01 PM, Ryan Yee via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> ryee88 updated this revision to Diff 48149. >> ryee88 added a comment. >> >> Keeping the number of test files to a minimum makes sense. >> >> Couldn't find an existing test for this diagnostic. > > > That would be a bit surprising - if you want to see if you can find one, > one way would be to add an "assert(false)" in where the diagnostic is > emitted, and see which test cases fail - see if any look useful. They might > not be testing tnhe whole diagnostic text, etc, but could be expanded to do > so. > Ping on this comment ^ are you sure there's no existing coverage you could attach your test to/modify to cover? > > >> I did find a cxx-reference.cpp that tests reference diagnostics so this >> seems like a reasonable location for this new test. >> >> >> http://reviews.llvm.org/D16949 >> >> Files: >> include/clang/Basic/DiagnosticSemaKinds.td >> lib/Sema/SemaOverload.cpp >> test/Parser/cxx-reference.cpp >> >> Index: test/Parser/cxx-reference.cpp >> === >> --- test/Parser/cxx-reference.cpp >> +++ test/Parser/cxx-reference.cpp >> @@ -24,3 +24,29 @@ >> #if __cplusplus <= 199711L >> // expected-warning@-2 {{rvalue references are a C++11 extension}} >> #endif >> + >> +namespace PointerVsReferenceSuggestion{ >> + class A; >> + >> + void f0(A *a); // expected-note {{candidate function not viable: >> cannot convert argument of incomplete type >> 'PointerVsReferenceSuggestion::A' to 'PointerVsReferenceSuggestion::A *' >> for 1st argument; take the address of the argument with &}} >> + void f1(A &a) { >> +f0(a); // expected-error {{no matching function for call to 'f0'}} >> + } >> + >> + void f2(A &a); // expected-note {{candidate function not viable: >> cannot convert argument of incomplete type 'PointerVsReferenceSuggestion::A >> *' to 'PointerVsReferenceSuggestion::A &' for 1st argument; dereference the >> argument with *}} >> + void f3(A *a) { >> +f2(a); // expected-error {{no matching function for call to 'f2'}} >> + } >> + >> + class B {}; >> + >> + void f4(B *b); // expected-note {{candidate function not viable: no >> known conversion from 'PointerVsReferenceSuggestion::B' to >> 'PointerVsReferenceSuggestion::B *' for 1st argument; take the address of >> the argument with &}} >> + void f5(B &b) { >> +f4(b); // expected-error {{no matching function for call to 'f4'}} >> + } >> + >> + void f6(B &b); // expected-note {{candidate function not viable: no >> known conversion from 'PointerVsReferenceSuggestion::B *' to >> 'PointerVsReferenceSuggestion::B &' for 1st argument; dereference the >> argument with *}} >> + void f7(B *b) { >> +f6(b); // expected-error {{no matching function for call to 'f6'}} >> + } >> +} >> Index: lib/Sema/SemaOverload.cpp >> === >> --- lib/Sema/SemaOverload.cpp >> +++ lib/Sema/SemaOverload.cpp >> @@ -9104,10 +9104,13 @@ >>if (const PointerType *PTy = TempFromTy->getAs()) >> TempFromTy = PTy->getPointeeType(); >>if (TempFromTy->isIncompleteType()) { >> +// Emit the generic diagnostic and, optionally, add the hints to it. >> S.Diag(Fn->getLocation(), >> diag::note_ovl_candidate_bad_conv_incomplete) >><< (unsigned) FnKind << FnDesc >><< (FromExpr ? FromExpr->getSourceRange() : SourceRange()) >> - << FromTy << ToTy << (unsigned) isObjectArgument << I+1; >> + << FromTy << ToTy << (unsigned) isObjectArgument << I+1 >> + << (unsigned) (Cand->Fix.Kind); >> + >> MaybeEmitInheritedConstructorNote(S, Fn); >> return; >>} >> Index: include/clang/Basic/DiagnosticSemaKinds.td >> === >> --- include/clang/Basic/DiagnosticSemaKinds.td >> +++ include/clang/Basic/DiagnosticSemaKinds.td >> @@ -3189,7 +3189,12 @@ >> "function (the implicit move assignment operator)|" >> "constructor (inherited)}0%1 " >> "not viable: cannot convert argument of incomplete type " >> -"%diff{$ to $|to parameter type}2,3">; >> +"%diff{$ to $|to parameter type}2,3 for " >> +"%select{%ordinal5 argument|object argument}4" >> +"%select{|; dereference the argument with *|" >> +"; take the address of the argument with &|" >> +"; remove *|" >> +"; remove &}6">; >> def note_ovl_candidate_bad_list_argument : Note<"candidate " >> "%select{function|function|constructor|" >> "function |function |constructor |" >> >> >> >> ___ >> 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/lis
Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target
pxli168 updated this revision to Diff 49136. http://reviews.llvm.org/D17596 Files: lib/CodeGen/TargetInfo.cpp test/CodeGenOpenCL/spir_version.cl Index: test/CodeGenOpenCL/spir_version.cl === --- /dev/null +++ test/CodeGenOpenCL/spir_version.cl @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | FileCheck %s --check-prefix=CL10 +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -cl-std=CL1.2 | FileCheck %s --check-prefix=CL12 +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CL20 +kernel void foo() {} +// CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CL10: [[SPIR]] = !{i32 2, i32 0} +// CL10: [[OCL]] = !{i32 1, i32 0} +// CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CL12: [[SPIR]] = !{i32 2, i32 0} +// CL12: [[OCL]] = !{i32 1, i32 2} +// CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} +// CL20: [[SPIR]] = !{i32 2, i32 0} Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7194,6 +7194,47 @@ } } +//===--===// +// SPIR ABI Implementation +//===--===// + +namespace { +class SPIRTargetCodeGenInfo : public TargetCodeGenInfo { +public: + SPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) +: TargetCodeGenInfo(new DefaultABIInfo(CGT)) {} + void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, +CodeGen::CodeGenModule &M) const override; +}; +} // End anonymous namespace. + +/// SPIR uses emitTargetMD to emit spir spec requried metadate. +void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const { + assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL\n"); + llvm::LLVMContext &Ctx = CGM.getModule().getContext(); + llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx); + llvm::Module &M = CGM.getModule(); + // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the + // opencl.spir.version named metadata. + llvm::Metadata *SPIRVerElts[] = { + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))}; + llvm::NamedMDNode *SPIRVerMD = + M.getOrInsertNamedMetadata("opencl.spir.version"); + SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); + // SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the + // opencl.ocl.version named metadata node. + llvm::Metadata *OCLVerElts[] = { + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (CGM.getLangOpts().OpenCLVersion % 100) / 10))}; + llvm::NamedMDNode *OCLVerMD = + M.getOrInsertNamedMetadata("opencl.ocl.version"); + OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts)); +} + static bool appendType(SmallStringEnc &Enc, QualType QType, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC); @@ -7684,5 +7725,8 @@ return *(TheTargetCodeGenInfo = new SparcV9TargetCodeGenInfo(Types)); case llvm::Triple::xcore: return *(TheTargetCodeGenInfo = new XCoreTargetCodeGenInfo(Types)); + case llvm::Triple::spir: + case llvm::Triple::spir64: +return *(TheTargetCodeGenInfo = new SPIRTargetCodeGenInfo(Types)); } } Index: test/CodeGenOpenCL/spir_version.cl === --- /dev/null +++ test/CodeGenOpenCL/spir_version.cl @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | FileCheck %s --check-prefix=CL10 +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -cl-std=CL1.2 | FileCheck %s --check-prefix=CL12 +// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CL20 +kernel void foo() {} +// CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CL10: [[SPIR]] = !{i32 2, i32 0} +// CL10: [[OCL]] = !{i32 1, i32 0} +// CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CL12: [[SPIR]] = !{i32 2, i32 0} +// CL12: [[OCL]] = !{i32 1, i32 2} +// CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} +// CL20: [[SPIR]] = !{i32 2, i32 0} Index: lib/CodeGen/TargetInfo.cpp ==
Re: [PATCH] D16949: Fix for: Bug 5941 - improve diagnostic for * vs & confusion
ryee88 added a comment. any comments? http://reviews.llvm.org/D16949 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17629: [OpenMP] Fix parsing of delete map clause modifier in C++ mode.
sfantao created this revision. sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0. sfantao added subscribers: caomhin, fraggamuffin, cfe-commits. The map modifier 'delete' is parser in c++ mode as a delete keyword, which requires special handling in the map clause parsing. http://reviews.llvm.org/D17629 Files: lib/Parse/ParseOpenMP.cpp test/OpenMP/target_enter_data_map_messages.c test/OpenMP/target_exit_data_ast_print.cpp test/OpenMP/target_exit_data_map_messages.c Index: test/OpenMP/target_exit_data_map_messages.c === --- test/OpenMP/target_exit_data_map_messages.c +++ test/OpenMP/target_exit_data_map_messages.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - -x c++ %s int main(int argc, char **argv) { Index: test/OpenMP/target_exit_data_ast_print.cpp === --- test/OpenMP/target_exit_data_ast_print.cpp +++ test/OpenMP/target_exit_data_ast_print.cpp @@ -23,6 +23,10 @@ #pragma omp target exit data map(release: x[0:10], c) +#pragma omp target exit data map(delete: x[0:10]) + +#pragma omp target exit data map(always, delete: x[0:10]) + #pragma omp target exit data map(from: c) map(release: d) #pragma omp target exit data map(always,release: e) @@ -71,6 +75,8 @@ // CHECK-NEXT: #pragma omp target exit data map(from: c) // CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e) // CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c) +// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10]) +// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10]) // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d) // CHECK-NEXT: #pragma omp target exit data map(always,release: e) // CHECK-NEXT: #pragma omp target exit data nowait map(from: i) @@ -98,6 +104,8 @@ // CHECK-NEXT: #pragma omp target exit data map(from: c) // CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e) // CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c) +// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10]) +// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10]) // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d) // CHECK-NEXT: #pragma omp target exit data map(always,release: e) // CHECK-NEXT: #pragma omp target exit data nowait map(from: i) @@ -125,6 +133,8 @@ // CHECK-NEXT: #pragma omp target exit data map(from: c) // CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e) // CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c) +// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10]) +// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10]) // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d) // CHECK-NEXT: #pragma omp target exit data map(always,release: e) // CHECK-NEXT: #pragma omp target exit data nowait map(from: i) @@ -168,6 +178,12 @@ #pragma omp target exit data map(from: x[0:10], c) // CHECK-NEXT: #pragma omp target exit data map(from: x[0:10],c) +#pragma omp target exit data map(delete: x[0:10]) +// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10]) + +#pragma omp target exit data map(always, delete: x[0:10]) +// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10]) + #pragma omp target exit data map(from: c) map(release: d) // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d) Index: test/OpenMP/target_enter_data_map_messages.c === --- test/OpenMP/target_enter_data_map_messages.c +++ test/OpenMP/target_enter_data_map_messages.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - -x c++ %s int main(int argc, char **argv) { Index: lib/Parse/ParseOpenMP.cpp === --- lib/Parse/ParseOpenMP.cpp +++ lib/Parse/ParseOpenMP.cpp @@ -1011,29 +1011,37 @@ // Handle map type for map clause. ColonProtectionRAIIObject ColonRAII(*this); -// the first identifier may be a list item, a map-type or -// a map-type-modifier +/// The map clause modifier token can be either a identifier or the C++ +/// delete keyword. +auto IsMapClauseModifierToken = [](const Token &Tok) { + return Tok.isOneOf(tok::identifier, tok::kw_delete); +}; + +// The first identifier may be a list item, a map-type or a +// map-type-modifier. The map modifier can also be delete which has the same +// spelling of the C++ delete keyword. MapType = static_cast(
[PATCH] D17627: Fix false positives for for-loop-analysis warning
steven_wu created this revision. steven_wu added reviewers: rtrieu, thakis. steven_wu added a subscriber: cfe-commits. -Wfor-loop-analysis was incorrectly warning about certain cases because the DeclMatcher is not looking pass OpaqueValueExpr. http://reviews.llvm.org/D17627 Files: lib/Sema/SemaStmt.cpp test/SemaObjC/warn-loop-analysis.m Index: test/SemaObjC/warn-loop-analysis.m === --- /dev/null +++ test/SemaObjC/warn-loop-analysis.m @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s +// expected-no-diagnostics + +@interface MyArray +- (id)objectAtIndexedSubscript:(unsigned int)idx; +@end + +// Do not warn on objc classes has objectAtIndexedSubscript method. +MyArray *test; +void foo(void); +void foo() +{ + unsigned int i; + for( i = 42 ; i > 0; ) // No warnings here + (void)test[ --i ]; +} Index: lib/Sema/SemaStmt.cpp === --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -1440,6 +1440,11 @@ FoundDecl = true; } +void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { + if (Expr *E = OVE->getSourceExpr()) +Visit(E); +} + bool FoundDeclInUse() { return FoundDecl; } }; // end class DeclMatcher Index: test/SemaObjC/warn-loop-analysis.m === --- /dev/null +++ test/SemaObjC/warn-loop-analysis.m @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s +// expected-no-diagnostics + +@interface MyArray +- (id)objectAtIndexedSubscript:(unsigned int)idx; +@end + +// Do not warn on objc classes has objectAtIndexedSubscript method. +MyArray *test; +void foo(void); +void foo() +{ + unsigned int i; + for( i = 42 ; i > 0; ) // No warnings here + (void)test[ --i ]; +} Index: lib/Sema/SemaStmt.cpp === --- lib/Sema/SemaStmt.cpp +++ lib/Sema/SemaStmt.cpp @@ -1440,6 +1440,11 @@ FoundDecl = true; } +void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) { + if (Expr *E = OVE->getSourceExpr()) +Visit(E); +} + bool FoundDeclInUse() { return FoundDecl; } }; // end class DeclMatcher ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261945 - [analyzer] Shorten ObjcSuperDeallocChecker diagnostics.
Author: dcoughlin Date: Thu Feb 25 18:47:42 2016 New Revision: 261945 URL: http://llvm.org/viewvc/llvm-project?rev=261945&view=rev Log: [analyzer] Shorten ObjcSuperDeallocChecker diagnostics. Change "use of 'self' after it has been freed with call to [super dealloc]" to "use of 'self' after it has been deallocated" and "use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]" to "use of instance variable '_ivar' after 'self' has been deallocated". Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=261945&r1=261944&r2=261945&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Thu Feb 25 18:47:42 2016 @@ -166,7 +166,7 @@ void ObjCSuperDeallocChecker::checkLocat llvm::raw_string_ostream OS(Buf); if (IvarRegion) { OS << "use of instance variable '" << *IvarRegion->getDecl() << - "' after the instance has been freed with call to [super dealloc]"; + "' after 'self' has been deallocated"; Desc = OS.str(); } @@ -189,7 +189,7 @@ void ObjCSuperDeallocChecker::reportUseA return; if (Desc.empty()) -Desc = "use of 'self' after it has been freed with call to [super dealloc]"; +Desc = "use of 'self' after it has been deallocated"; // Generate the report. std::unique_ptr BR( Modified: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m?rev=261945&r1=261944&r2=261945&view=diff == --- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m (original) +++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Thu Feb 25 18:47:42 2016 @@ -36,8 +36,8 @@ typedef struct objc_selector *SEL; } - (void)dealloc { [super dealloc]; // expected-note {{[super dealloc] called here}} - [_ivar release]; // expected-warning {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} - // expected-note@-1 {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} + [_ivar release]; // expected-warning {{use of instance variable '_ivar' after 'self' has been deallocated}} + // expected-note@-1 {{use of instance variable '_ivar' after 'self' has been deallocated}} } @end @@ -56,8 +56,8 @@ typedef struct objc_selector *SEL; } - (void)dealloc { [super dealloc]; // expected-note {{[super dealloc] called here}} - _delegate = nil; // expected-warning {{use of instance variable '_delegate' after the instance has been freed with call to [super dealloc]}} - // expected-note@-1 {{use of instance variable '_delegate' after the instance has been freed with call to [super dealloc]}} + _delegate = nil; // expected-warning {{use of instance variable '_delegate' after 'self' has been deallocated}} + // expected-note@-1 {{use of instance variable '_delegate' after 'self' has been deallocated}} } @end @@ -74,8 +74,8 @@ struct SomeStruct { @implementation SuperDeallocThenAssignIvarField - (void)dealloc { [super dealloc]; // expected-note {{[super dealloc] called here}} - _s.f = 7; // expected-warning {{use of instance variable '_s' after the instance has been freed with call to [super dealloc]}} - // expected-note@-1 {{use of instance variable '_s' after the instance has been freed with call to [super dealloc]}} + _s.f = 7; // expected-warning {{use of instance variable '_s' after 'self' has been deallocated}} + // expected-note@-1 {{use of instance variable '_s' after 'self' has been deallocated}} } @end @@ -93,8 +93,21 @@ struct SomeStruct { @implementation SuperDeallocThenAssignIvarIvar - (void)dealloc { [super dealloc]; // expected-note {{[super dealloc] called here}} - _ivar->_otherIvar = 7; // expected-warning {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} - // expected-note@-1 {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} + _ivar->_otherIvar = 7; // expected-warning {{use of instance variable '_ivar' after 'self' has been deallocated}} + // expected-note@-1 {{use of instance variable '_ivar' after 'self' has been deallocated}} +} +@end + +@interface SuperDeallocThenAssignSelfIvar : NSObject { + NSObject *_ivar; +} +@end + +@implementation SuperDeallocThenAssignSelfIvar +- (void)dealloc { + [super dealloc]; // expected-note {{[super dealloc] called here}} + se
Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. Looks terrible, please commit :) http://reviews.llvm.org/D17619 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261944 - [analyzer] Fix a memory error in r261935 caught by the Windows bots.
Author: dcoughlin Date: Thu Feb 25 18:23:41 2016 New Revision: 261944 URL: http://llvm.org/viewvc/llvm-project?rev=261944&view=rev Log: [analyzer] Fix a memory error in r261935 caught by the Windows bots. It was using a temporary StringRef after its underlying storage was freed. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=261944&r1=261943&r2=261944&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Thu Feb 25 18:23:41 2016 @@ -162,9 +162,9 @@ void ObjCSuperDeallocChecker::checkLocat StringRef Desc = StringRef(); auto *IvarRegion = dyn_cast_or_null(PriorSubRegion); + std::string Buf; + llvm::raw_string_ostream OS(Buf); if (IvarRegion) { -std::string Buf; -llvm::raw_string_ostream OS(Buf); OS << "use of instance variable '" << *IvarRegion->getDecl() << "' after the instance has been freed with call to [super dealloc]"; Desc = OS.str(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17002: [lanai] Add Lanai backend to clang driver
jpienaar added reviewers: eliben, jyknight, chandlerc. jpienaar updated this revision to Diff 49119. jpienaar added a comment. Updated preprocessor test init.c to use -match-full-lines. http://reviews.llvm.org/D17002 Files: lib/Basic/Targets.cpp lib/CodeGen/TargetInfo.cpp lib/Driver/Driver.cpp lib/Driver/ToolChains.h lib/Driver/Tools.cpp lib/Driver/Tools.h test/CodeGen/lanai-arguments.c test/CodeGen/lanai-regparm.c test/CodeGen/target-data.c test/Driver/lanai-toolchain.c test/Driver/lanai-unknown-unknown.cpp test/Preprocessor/init.c Index: test/Preprocessor/init.c === --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -8412,6 +8412,9 @@ // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s // ANDROID:#define __ANDROID__ 1 // +// RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s +// LANAI: #define __lanai__ 1 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-FREEBSD %s // PPC64-FREEBSD-NOT: #define __LONG_DOUBLE_128__ 1 // Index: test/Driver/lanai-unknown-unknown.cpp === --- test/Driver/lanai-unknown-unknown.cpp +++ test/Driver/lanai-unknown-unknown.cpp @@ -0,0 +1,86 @@ +// RUN: %clang -target lanai-unknown-unknown -### %s -emit-llvm-only -c 2>&1 \ +// RUN: | FileCheck %s -check-prefix=ECHO +// RUN: %clang -target lanai-unknown-unknown %s -emit-llvm -S -o - \ +// RUN: | FileCheck %s + +// ECHO: {{.*}} "-cc1" {{.*}}lanai-unknown-unknown.c + +typedef __builtin_va_list va_list; +typedef __SIZE_TYPE__ size_t; +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +extern "C" { + +// CHECK: @align_c = global i32 1 +int align_c = __alignof(char); + +// CHECK: @align_s = global i32 2 +int align_s = __alignof(short); + +// CHECK: @align_i = global i32 4 +int align_i = __alignof(int); + +// CHECK: @align_l = global i32 4 +int align_l = __alignof(long); + +// CHECK: @align_ll = global i32 8 +int align_ll = __alignof(long long); + +// CHECK: @align_p = global i32 4 +int align_p = __alignof(void*); + +// CHECK: @align_vl = global i32 4 +int align_vl = __alignof(va_list); + +// Check types + +// CHECK: signext i8 @check_char() +char check_char() { return 0; } + +// CHECK: signext i16 @check_short() +short check_short() { return 0; } + +// CHECK: i32 @check_int() +int check_int() { return 0; } + +// CHECK: i32 @check_long() +long check_long() { return 0; } + +// CHECK: i64 @check_longlong() +long long check_longlong() { return 0; } + +// CHECK: zeroext i8 @check_uchar() +unsigned char check_uchar() { return 0; } + +// CHECK: zeroext i16 @check_ushort() +unsigned short check_ushort() { return 0; } + +// CHECK: i32 @check_uint() +unsigned int check_uint() { return 0; } + +// CHECK: i32 @check_ulong() +unsigned long check_ulong() { return 0; } + +// CHECK: i64 @check_ulonglong() +unsigned long long check_ulonglong() { return 0; } + +// CHECK: i32 @check_size_t() +size_t check_size_t() { return 0; } + +} + +template void Switch(); +template<> void Switch<4>(); +template<> void Switch<8>(); +template<> void Switch<16>(); + +void check_pointer_size() { + // CHECK: SwitchILi4 + Switch(); + + // CHECK: SwitchILi8 + Switch(); + + // CHECK: SwitchILi4 + Switch(); +} Index: test/Driver/lanai-toolchain.c === --- test/Driver/lanai-toolchain.c +++ test/Driver/lanai-toolchain.c @@ -0,0 +1,2 @@ +// RUN: %clang -target lanai-unknown-unknown -v 2> %t +// RUN: grep 'Target: lanai-unknown-unknown' %t Index: test/CodeGen/target-data.c === --- test/CodeGen/target-data.c +++ test/CodeGen/target-data.c @@ -86,6 +86,10 @@ // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64 // WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" +// RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=LANAI +// LANAI: target datalayout = "E-m:e-p:32:32-i64:64-a:0:32-n32-S64" + // RUN: %clang_cc1 -triple powerpc-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=PPC // PPC: target datalayout = "E-m:e-p:32:32-i64:64-n32" Index: test/CodeGen/lanai-regparm.c === --- test/CodeGen/lanai-regparm.c +++ test/CodeGen/lanai-regparm.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple lanai-unknown-unknown -mregparm 4 %s -emit-llvm -o - | FileCheck %s + +void f1(int a, int b, int c, int d, +int e, int f, int g, int h); + +void f2(int a, int b) __attribute((regparm(0))); + +void f0() { +// CHECK: call void @f1(i32 inreg 1, i32 inreg 2, i32 inreg 3, i32 inreg 4, +// CHECK: i32 5, i32 6, i32 7, i32 8) + f1(1, 2,
[clang-tools-extra] r261940 - Remove a blank line at EOF. NFC
Author: alexfh Date: Thu Feb 25 17:57:30 2016 New Revision: 261940 URL: http://llvm.org/viewvc/llvm-project?rev=261940&view=rev Log: Remove a blank line at EOF. NFC Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst?rev=261940&r1=261939&r2=261940&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst Thu Feb 25 17:57:30 2016 @@ -13,4 +13,3 @@ Examples: // Initializing string with empty string literal is unnecessary. std::string a = ""; std::string b(""); - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r261939 - Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
Author: alexfh Date: Thu Feb 25 17:57:23 2016 New Revision: 261939 URL: http://llvm.org/viewvc/llvm-project?rev=261939&view=rev Log: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations. Reviewers: hokein, alexfh Subscribers: cfe-commits Patch by Shuai Wang! Differential Revision: http://reviews.llvm.org/D17586 Added: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=261939&r1=261938&r2=261939&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Feb 25 17:57:23 2016 @@ -338,10 +338,9 @@ void ClangTidyDiagnosticConsumer::Handle Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError)); } - // FIXME: Provide correct LangOptions for each file. - LangOptions LangOpts; ClangTidyDiagnosticRenderer Converter( - LangOpts, &Context.DiagEngine->getDiagnosticOptions(), Errors.back()); + Context.getLangOpts(), &Context.DiagEngine->getDiagnosticOptions(), + Errors.back()); SmallString<100> Message; Info.FormatDiagnostic(Message); SourceManager *Sources = nullptr; Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=261939&r1=261938&r2=261939&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Thu Feb 25 17:57:23 2016 @@ -151,7 +151,7 @@ public: void setASTContext(ASTContext *Context); /// \brief Gets the language options from the AST context. - LangOptions getLangOpts() const { return LangOpts; } + const LangOptions &getLangOpts() const { return LangOpts; } /// \brief Returns the name of the clang-tidy check which produced this /// diagnostic ID. Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=261939&r1=261938&r2=261939&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Thu Feb 25 17:57:23 2016 @@ -14,6 +14,7 @@ add_clang_library(clangTidyReadabilityMo RedundantControlFlowCheck.cpp RedundantStringCStrCheck.cpp RedundantSmartptrGetCheck.cpp + RedundantStringInitCheck.cpp SimplifyBooleanExprCheck.cpp UniqueptrDeleteReleaseCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=261939&r1=261938&r2=261939&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp Thu Feb 25 17:57:23 2016 @@ -21,6 +21,7 @@ #include "RedundantControlFlowCheck.h" #include "RedundantSmartptrGetCheck.h" #include "RedundantStringCStrCheck.h" +#include "RedundantStringInitCheck.h" #include "SimplifyBooleanExprCheck.h" #include "UniqueptrDeleteReleaseCheck.h" @@ -53,6 +54,8 @@ public: "readability-redundant-smartptr-get"); CheckFactories.registerCheck( "readability-redundant-string-cstr"); +CheckFactories.registerCheck( +"readability-redundant-string-init"); CheckFactories.registerCheck( "readability-simplify-boolean-expr"); CheckFactories.registerCheck( Added: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp?rev=261939&view=auto =
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
This revision was automatically updated to reflect the committed changes. Closed by commit rL261939: Add a new check, readability-redundant-string-init, that checks unnecessary… (authored by alexfh). Changed prior to commit: http://reviews.llvm.org/D17586?vs=49114&id=49118#toc Repository: rL LLVM http://reviews.llvm.org/D17586 Files: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-init.rst clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.h === --- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.h +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.h @@ -0,0 +1,32 @@ +//===- RedundantStringInitCheck.h - clang-tidy --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { +namespace readability { + +/// Finds unnecessary string initializations. +class RedundantStringInitCheck : public ClangTidyCheck { +public: + RedundantStringInitCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace readability +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H Index: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt === --- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt +++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt @@ -14,6 +14,7 @@ RedundantControlFlowCheck.cpp RedundantStringCStrCheck.cpp RedundantSmartptrGetCheck.cpp + RedundantStringInitCheck.cpp SimplifyBooleanExprCheck.cpp UniqueptrDeleteReleaseCheck.cpp Index: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp === --- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp +++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp @@ -21,6 +21,7 @@ #include "RedundantControlFlowCheck.h" #include "RedundantSmartptrGetCheck.h" #include "RedundantStringCStrCheck.h" +#include "RedundantStringInitCheck.h" #include "SimplifyBooleanExprCheck.h" #include "UniqueptrDeleteReleaseCheck.h" @@ -53,6 +54,8 @@ "readability-redundant-smartptr-get"); CheckFactories.registerCheck( "readability-redundant-string-cstr"); +CheckFactories.registerCheck( +"readability-redundant-string-init"); CheckFactories.registerCheck( "readability-simplify-boolean-expr"); CheckFactories.registerCheck( Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp @@ -0,0 +1,62 @@ +//===- RedundantStringInitCheck.cpp - clang-tidy *- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "RedundantStringInitCheck.h" +#include "clang/ASTMatchers/ASTMatchers.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace readability { + +namespace { + +AST_MATCHER(StringLiteral, lengthIsZero) { return Node.getLength() == 0; } + +} // namespace + +void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus) +return; + + const auto StringCtorExpr = cxxConstructE
Re: [PATCH] D17528: [analyzer] Warn on use of 'self' after call to to [super dealloc].
This revision was automatically updated to reflect the committed changes. dcoughlin marked an inline comment as done. Closed by commit rL261935: [analyzer] Warn on use of 'self' after call to to [super dealloc]. (authored by dcoughlin). Changed prior to commit: http://reviews.llvm.org/D17528?vs=48747&id=49116#toc Repository: rL LLVM http://reviews.llvm.org/D17528 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Index: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m === --- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m +++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m @@ -35,8 +35,9 @@ return self; } - (void)dealloc { - [super dealloc]; - [_ivar release]; + [super dealloc]; // expected-note {{[super dealloc] called here}} + [_ivar release]; // expected-warning {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} } @end @@ -54,8 +55,46 @@ return self; } - (void)dealloc { - [super dealloc]; - _delegate = nil; + [super dealloc]; // expected-note {{[super dealloc] called here}} + _delegate = nil; // expected-warning {{use of instance variable '_delegate' after the instance has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of instance variable '_delegate' after the instance has been freed with call to [super dealloc]}} +} +@end + + +struct SomeStruct { + int f; +}; + +@interface SuperDeallocThenAssignIvarField : NSObject { + struct SomeStruct _s; +} +@end + +@implementation SuperDeallocThenAssignIvarField +- (void)dealloc { + [super dealloc]; // expected-note {{[super dealloc] called here}} + _s.f = 7; // expected-warning {{use of instance variable '_s' after the instance has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of instance variable '_s' after the instance has been freed with call to [super dealloc]}} +} +@end + +@interface OtherClassWithIvar { +@public + int _otherIvar; +} +@end; + +@interface SuperDeallocThenAssignIvarIvar : NSObject { + OtherClassWithIvar *_ivar; +} +@end + +@implementation SuperDeallocThenAssignIvarIvar +- (void)dealloc { + [super dealloc]; // expected-note {{[super dealloc] called here}} + _ivar->_otherIvar = 7; // expected-warning {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]}} } @end @@ -72,8 +111,9 @@ return self; } - (void)dealloc { - [super dealloc]; - self.ivar = nil; + [super dealloc]; // expected-note {{[super dealloc] called here}} + self.ivar = nil; // expected-warning {{use of 'self' after it has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it has been freed with call to [super dealloc]}} } @end @@ -90,8 +130,9 @@ return self; } - (void)dealloc { - [super dealloc]; - self.delegate = nil; + [super dealloc]; // expected-note {{[super dealloc] called here}} + self.delegate = nil; // expected-warning {{use of 'self' after it has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it has been freed with call to [super dealloc]}} } @end @@ -103,8 +144,9 @@ - (void)_invalidate { } - (void)dealloc { - [super dealloc]; - [self _invalidate]; + [super dealloc]; // expected-note {{[super dealloc] called here}} + [self _invalidate]; // expected-warning {{use of 'self' after it has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it has been freed with call to [super dealloc]}} } @end @@ -117,8 +159,23 @@ @implementation SuperDeallocThenCallNonObjectiveCMethodClass - (void)dealloc { - [super dealloc]; - _invalidate(self); + [super dealloc]; // expected-note {{[super dealloc] called here}} + _invalidate(self); // expected-warning {{use of 'self' after it has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it has been freed with call to [super dealloc]}} +} +@end + +@interface SuperDeallocThenCallObjectiveClassMethodClass : NSObject { } +@end + +@implementation SuperDeallocThenCallObjectiveClassMethodClass ++ (void) invalidate:(id)arg; { +} + +- (void)dealloc { + [super dealloc]; // expected-note {{[super dealloc] called here}} + [SuperDeallocThenCallObjectiveClassMethodClass invalidate:self]; // expected-warning {{use of 'self' after it has been freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it has been freed with call to [super dealloc]}} } @end @@ -132,13 +189,14 @@ - (void)_invalidate { } - (void)dealloc { - if (_ivar) { +
r261935 - [analyzer] Warn on use of 'self' after call to to [super dealloc].
Author: dcoughlin Date: Thu Feb 25 17:36:52 2016 New Revision: 261935 URL: http://llvm.org/viewvc/llvm-project?rev=261935&view=rev Log: [analyzer] Warn on use of 'self' after call to to [super dealloc]. Referring to 'self' after a call to [super dealloc] is a use-after-free in Objective-C because NSObject's -dealloc frees the memory pointed to by self. This patch extends the ObjCSuperDeallocChecker to catch this error. rdar://problem/6953275 Differential Revision: http://reviews.llvm.org/D17528 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=261935&r1=261934&r2=261935&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Thu Feb 25 17:36:52 2016 @@ -8,7 +8,7 @@ //===--===// // // This defines ObjCSuperDeallocChecker, a builtin check that warns when -// [super dealloc] is called twice on the same instance in MRR mode. +// self is used after a call to [super dealloc] in MRR mode. // //===--===// @@ -25,7 +25,8 @@ using namespace ento; namespace { class ObjCSuperDeallocChecker -: public Checker { +: public Checker { mutable IdentifierInfo *IIdealloc, *IINSObject; mutable Selector SELdealloc; @@ -40,12 +41,24 @@ public: ObjCSuperDeallocChecker(); void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; + + void checkPreCall(const CallEvent &Call, CheckerContext &C) const; + + void checkLocation(SVal l, bool isLoad, const Stmt *S, + CheckerContext &C) const; + +private: + + void diagnoseCallArguments(const CallEvent &CE, CheckerContext &C) const; + + void reportUseAfterDealloc(SymbolRef Sym, StringRef Desc, const Stmt *S, + CheckerContext &C) const; }; } // End anonymous namespace. // Remember whether [super dealloc] has previously been called on the -// a SymbolRef for the receiver. +// SymbolRef for the receiver. REGISTER_SET_WITH_PROGRAMSTATE(CalledSuperDealloc, SymbolRef) class SuperDeallocBRVisitor final @@ -71,40 +84,36 @@ public: void ObjCSuperDeallocChecker::checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const { - if (!isSuperDeallocMessage(M)) -return; ProgramStateRef State = C.getState(); SymbolRef ReceiverSymbol = M.getReceiverSVal().getAsSymbol(); - assert(ReceiverSymbol && "No receiver symbol at call to [super dealloc]?"); + if (!ReceiverSymbol) { +diagnoseCallArguments(M, C); +return; + } bool AlreadyCalled = State->contains(ReceiverSymbol); - - // If [super dealloc] has not been called, there is nothing to do. We'll - // note the fact that [super dealloc] was called in checkPostObjCMessage. if (!AlreadyCalled) return; - // We have a duplicate [super dealloc] method call. - // This likely causes a crash, so stop exploring the - // path by generating a sink. - ExplodedNode *ErrNode = C.generateErrorNode(); - // If we've already reached this node on another path, return. - if (!ErrNode) -return; + StringRef Desc; - // Generate the report. - std::unique_ptr BR( - new BugReport(*DoubleSuperDeallocBugType, -"[super dealloc] should not be called multiple times", -ErrNode)); - BR->addRange(M.getOriginExpr()->getSourceRange()); - BR->addVisitor(llvm::make_unique(ReceiverSymbol)); - C.emitReport(std::move(BR)); + if (isSuperDeallocMessage(M)) { +Desc = "[super dealloc] should not be called multiple times"; + } else { +Desc = StringRef(); + } + + reportUseAfterDealloc(ReceiverSymbol, Desc, M.getOriginExpr(), C); return; } +void ObjCSuperDeallocChecker::checkPreCall(const CallEvent &Call, + CheckerContext &C) const { + diagnoseCallArguments(Call, C); +} + void ObjCSuperDeallocChecker::checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const { // Check for [super dealloc] method call. @@ -122,6 +131,92 @@ void ObjCSuperDeallocChecker::checkPostO C.addTransition(State); } +void ObjCSuperDeallocChecker::checkLocation(SVal L, bool IsLoad, const Stmt *S, + CheckerContext &C) const { + SymbolRef BaseSym = L.getLocSymbolInBase(); + if (!BaseSym) +return; + + ProgramStateRef State =
Re: [PATCH] D17528: [analyzer] Warn on use of 'self' after call to to [super dealloc].
dcoughlin added inline comments. Comment at: lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp:165 @@ +164,3 @@ + if (Desc.empty()) +Desc = "use of 'self' after it is freed with call to [super dealloc]"; + zaks.anna wrote: > Does "has been freed" sound better? Yes, changed it. Comment at: test/Analysis/DeallocUseAfterFreeErrors.m:59 @@ +58,3 @@ + [super dealloc]; // expected-note {{[super dealloc] called here}} + _delegate = nil; // expected-warning {{use of 'self' after it is freed with call to [super dealloc]}} + // expected-note@-1 {{use of 'self' after it is freed with call to [super dealloc]}} zaks.anna wrote: > Would it be possible to provide a more presice error message here? > Specifically, we refer to 'self' here but the reference is implicit. I guess > we could say something like "accessing an instance variable after the object > has been freed". Would that require extra checking to ensure that we are > indeed accessing a member in checkLocation? I've updated this to be "use of instance variable '_ivar' after the instance has been freed with call to [super dealloc]". Repository: rL LLVM http://reviews.llvm.org/D17528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
alexfh accepted this revision. alexfh added a comment. Looks good! I'll commit the patch for you. http://reviews.llvm.org/D17586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17360: [cfi] Fix handling of sanitize trap/recover flags in the cross-DSO CFI mode.
eugenis updated the summary for this revision. eugenis updated this revision to Diff 49115. eugenis added a comment. OK, done. Please take another look. This is inferior to the original patch in terms of functionality, but the implementation is a lot simpler. Repository: rL LLVM http://reviews.llvm.org/D17360 Files: lib/CodeGen/CGExpr.cpp test/CodeGen/cfi-check-fail.c test/CodeGen/cfi-check-fail2.c Index: test/CodeGen/cfi-check-fail2.c === --- /dev/null +++ test/CodeGen/cfi-check-fail2.c @@ -0,0 +1,70 @@ +// __cfi_check_fail codegen when not all CFI checkers are enabled. +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall \ +// RUN: -emit-llvm -o - %s | FileCheck %s + +void caller(void (*f)()) { + f(); +} + +// CHECK: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) { +// CHECK: store i8* %0, i8** %[[ALLOCA0:.*]], align 8 +// CHECK: store i8* %1, i8** %[[ALLOCA1:.*]], align 8 +// CHECK: %[[DATA:.*]] = load i8*, i8** %[[ALLOCA0]], align 8 +// CHECK: %[[ADDR:.*]] = load i8*, i8** %[[ALLOCA1]], align 8 +// CHECK: %[[ICMP_NOT_NULL:.*]] = icmp ne i8* %[[DATA]], null +// CHECK: br i1 %[[ICMP_NOT_NULL]], label %[[CONT0:.*]], label %[[TRAP:.*]], + +// CHECK: [[TRAP]]: +// CHECK-NEXT: call void @llvm.trap() +// CHECK-NEXT: unreachable + +// CHECK: [[CONT0]]: +// CHECK: %[[A:.*]] = bitcast i8* %[[DATA]] to { i8, { i8*, i32, i32 }, i8* }* +// CHECK: %[[KINDPTR:.*]] = getelementptr {{.*}} %[[A]], i32 0, i32 0 +// CHECK: %[[KIND:.*]] = load i8, i8* %[[KINDPTR]], align 4 +// CHECK: %[[VTVALID0:.*]] = call i1 @llvm.bitset.test(i8* %[[ADDR]], metadata !"all-vtables") +// CHECK: %[[VTVALID:.*]] = zext i1 %[[VTVALID0]] to i64 +// CHECK: %[[NOT_0:.*]] = icmp ne i8 %[[KIND]], 0 +// CHECK: br i1 %[[NOT_0]], label %[[CONT1:.*]], label %[[HANDLE0:.*]], !prof + +// CHECK: [[HANDLE0]]: +// CHECK: %[[DATA0:.*]] = ptrtoint i8* %[[DATA]] to i64, +// CHECK: %[[ADDR0:.*]] = ptrtoint i8* %[[ADDR]] to i64, +// CHECK: call void @__ubsan_handle_cfi_check_fail_abort(i64 %[[DATA0]], i64 %[[ADDR0]], i64 %[[VTVALID]]) +// CHECK: unreachable + +// CHECK: [[CONT1]]: +// CHECK: %[[NOT_1:.*]] = icmp ne i8 %[[KIND]], 1 +// CHECK: br i1 %[[NOT_1]], label %[[CONT2:.*]], label %[[HANDLE1:.*]], !nosanitize + +// CHECK: [[HANDLE1]]: +// CHECK-NEXT: call void @llvm.trap() +// CHECK-NEXT: unreachable + +// CHECK: [[CONT2]]: +// CHECK: %[[NOT_2:.*]] = icmp ne i8 %[[KIND]], 2 +// CHECK: br i1 %[[NOT_2]], label %[[CONT3:.*]], label %[[HANDLE2:.*]], !nosanitize + +// CHECK: [[HANDLE2]]: +// CHECK-NEXT: call void @llvm.trap() +// CHECK-NEXT: unreachable + +// CHECK: [[CONT3]]: +// CHECK: %[[NOT_3:.*]] = icmp ne i8 %[[KIND]], 3 +// CHECK: br i1 %[[NOT_3]], label %[[CONT4:.*]], label %[[HANDLE3:.*]], !nosanitize + +// CHECK: [[HANDLE3]]: +// CHECK-NEXT: call void @llvm.trap() +// CHECK-NEXT: unreachable + +// CHECK: [[CONT4]]: +// CHECK: %[[NOT_4:.*]] = icmp ne i8 %[[KIND]], 4 +// CHECK: br i1 %[[NOT_4]], label %[[CONT5:.*]], label %[[HANDLE4:.*]], !nosanitize + +// CHECK: [[HANDLE4]]: +// CHECK-NEXT: call void @llvm.trap() +// CHECK-NEXT: unreachable + +// CHECK: [[CONT5]]: +// CHECK: ret void Index: test/CodeGen/cfi-check-fail.c === --- test/CodeGen/cfi-check-fail.c +++ test/CodeGen/cfi-check-fail.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \ +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-icall,cfi-nvcall,cfi-vcall,cfi-unrelated-cast,cfi-derived-cast \ // RUN: -fsanitize-trap=cfi-icall,cfi-nvcall -fsanitize-recover=cfi-vcall,cfi-unrelated-cast \ // RUN: -emit-llvm -o - %s | FileCheck %s Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -2483,14 +2483,12 @@ CheckRecoverableKind RecoverKind = getRecoverableKind(Checked[0].second); // In cross-DSO CFI mode this code is used to generate __cfi_check_fail, which // includes all checks, even those that are not in SanOpts. - assert(CGM.getCodeGenOpts().SanitizeCfiCrossDso || - SanOpts.has(Checked[0].second)); + assert(SanOpts.has(Checked[0].second)); #ifndef NDEBUG for (int i = 1, n = Checked.size(); i < n; ++i) { assert(RecoverKind == getRecoverableKind(Checked[i].second) && "All recoverable kinds in a single check must be same!"); -assert(CGM.getCodeGenOpts().SanitizeCfiCrossDso || - SanOpts.has(Checked[i].second)); +assert(SanOpts.has(Checked[i].second)); } #endif @@ -2672,8 +2670,11 @@ SanitizerMask Mask = CheckKindMaskPair.second; llvm::Value *Cond = Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, K
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
shuaiwang marked an inline comment as done. shuaiwang added a comment. http://reviews.llvm.org/D17586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
shuaiwang updated this revision to Diff 49114. shuaiwang added a comment. CHECK-FIXES for macro tests http://reviews.llvm.org/D17586 Files: clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/RedundantStringInitCheck.cpp clang-tidy/readability/RedundantStringInitCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-redundant-string-init.rst test/clang-tidy/readability-redundant-string-init.cpp Index: test/clang-tidy/readability-redundant-string-init.cpp === --- /dev/null +++ test/clang-tidy/readability-redundant-string-init.cpp @@ -0,0 +1,86 @@ +// RUN: %check_clang_tidy %s readability-redundant-string-init %t + +namespace std { +template +class allocator {}; +template +class char_traits {}; +template , typename A = std::allocator> +struct basic_string { + basic_string(); + basic_string(const basic_string&); + basic_string(const C *, const A &a = A()); + ~basic_string(); +}; +typedef basic_string string; +typedef basic_string wstring; +} + +void f() { + std::string a = ""; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init] + // CHECK-FIXES: std::string a; + std::string b(""); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string b; + std::string c = R"()"; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string c; + std::string d(R"()"); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string d; + + std::string u = "u"; + std::string w("w"); + std::string x = R"(x)"; + std::string y(R"(y)"); + std::string z; +} + +void g() { + std::wstring a = L""; + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring a; + std::wstring b(L""); + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring b; + std::wstring c = LR"()"; + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring c; + std::wstring d(LR"()"); + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring d; + + std::wstring u = L"u"; + std::wstring w(L"w"); + std::wstring x = LR"(x)"; + std::wstring y(LR"(y)"); + std::wstring z; +} + +template +void templ() { + std::string s = ""; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string s; +} + +#define M(x) x +#define N { std::string s = ""; } +// CHECK-FIXES: #define N { std::string s = ""; } + +void h() { + templ(); + templ(); + + M({ std::string s = ""; }) + // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization + // CHECK-FIXES: M({ std::string s; }) + + N + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization + // CHECK-FIXES: N + N + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization + // CHECK-FIXES: N +} Index: docs/clang-tidy/checks/readability-redundant-string-init.rst === --- /dev/null +++ docs/clang-tidy/checks/readability-redundant-string-init.rst @@ -0,0 +1,16 @@ +.. title:: clang-tidy - readability-redundant-string-init + +readability-redundant-string-init += + + +Finds unnecessary string initializations. + +Examples: + +.. code:: c++ + + // Initializing string with empty string literal is unnecessary. + std::string a = ""; + std::string b(""); + Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -99,5 +99,6 @@ readability-redundant-control-flow readability-redundant-smartptr-get readability-redundant-string-cstr + readability-redundant-string-init readability-simplify-boolean-expr readability-uniqueptr-delete-release Index: clang-tidy/readability/RedundantStringInitCheck.h === --- /dev/null +++ clang-tidy/readability/RedundantStringInitCheck.h @@ -0,0 +1,32 @@ +//===- RedundantStringInitCheck.h - clang-tidy --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDA
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
alexfh added inline comments. Comment at: test/clang-tidy/readability-redundant-string-init.cpp:69 @@ +68,3 @@ +#define M(x) x +#define N { std::string s = ""; } + Please add a CHECK-FIXES to ensure the macro definition hasn't changed and that the macro invocations below are intact. http://reviews.llvm.org/D17586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation
Create a new review here: http://reviews.llvm.org/D17622 Thanks, -Rong On Wed, Feb 24, 2016 at 9:22 PM, Sean Silva wrote: > silvas added a comment. > > In http://reviews.llvm.org/D15829#360006, @xur wrote: > >> Here is the new patch that removes the auto detection of profile kind. >> >> In this patch, I replace the CC1 option of -fprofile-instr-use=<> with >> -fprofile-instrument={llvm-use|clang-use}. For the use compilation, the >> profile reuses the -fprofile-instrument-path= option. >> >> Again, all changes are of CC1 options. Driver options are intact. >> >> Some test are modified due to the -fprofile-instr-use= option change. >> >> A new test is added to test IR profile compilation. >> test/CodeGen/pgo-instrumentation.c > > > I meant in a new phabricator review. This one is has gone on for too long and > is convoluted and hard to follow. (lots of stray inline comments etc.) > > > http://reviews.llvm.org/D15829 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation
xur added a comment. Create a new review here: http://reviews.llvm.org/D17622 Thanks, -Rong http://reviews.llvm.org/D15829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17622: [PGO] clang cc1 option change to enable IR level instrumenation
xur created this revision. xur added reviewers: davidxl, silvas, justinruggles. xur added subscribers: cfe-commits, xur, mcrosier, davidxl, slingn. This patch expands cc1 option -fprofile-instrument= with three new values: (1) -fprofile-instrument=llvm This enables IR PGO instrumentation. (2) -fprofile-instrument=llvm-use This enables PGO use compilation using IR level profiles. The profile is specified by -fprofile-instrument-path= (cc1) option. (3) -fprofile-instrument=clang-use This enables PGO use compilation using clang profiles. This replaces current cc1 option -fprofile-instr-use=. The profile is specified by -fprofile-instrument-path= (cc1) option. Some tests are modified due to the -fprofile-instr-use= option change. A new test is added to test IR profile compilation. test/CodeGen/pgo-instrumentation.c Original discussion is in http://reviews.llvm.org/D15829. http://reviews.llvm.org/D17622 Files: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def include/clang/Frontend/CodeGenOptions.h lib/CodeGen/BackendUtil.cpp lib/CodeGen/CodeGenModule.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/Inputs/pgotestclang.profraw test/CodeGen/Inputs/pgotestir.profraw test/CodeGen/pgo-instrumentation.c test/Driver/clang_f_opts.c test/Profile/c-captured.c test/Profile/c-counter-overflows.c test/Profile/c-general.c test/Profile/c-outdated-data.c test/Profile/c-unprofiled-blocks.c test/Profile/c-unprofiled.c test/Profile/cxx-lambda.cpp test/Profile/cxx-rangefor.cpp test/Profile/cxx-templates.cpp test/Profile/objc-general.m test/Profile/profile-does-not-exist.c Index: test/Profile/profile-does-not-exist.c === --- test/Profile/profile-does-not-exist.c +++ test/Profile/profile-does-not-exist.c @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instrument-path=%t.nonexistent.profdata -fprofile-instrument=clang-use 2>&1 | FileCheck %s // CHECK: error: Could not read profile {{.*}}.nonexistent.profdata: // CHECK-NOT: Assertion failed Index: test/Profile/objc-general.m === --- test/Profile/objc-general.m +++ test/Profile/objc-general.m @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument=clang | FileCheck -check-prefix=PGOGEN %s // RUN: llvm-profdata merge %S/Inputs/objc-general.proftext -o %t.profdata -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instr-use=%t.profdata | FileCheck -check-prefix=PGOUSE %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name objc-general.m %s -o - -emit-llvm -fblocks -fprofile-instrument-path=%t.profdata -fprofile-instrument=clang-use | FileCheck -check-prefix=PGOUSE %s #ifdef HAVE_FOUNDATION Index: test/Profile/cxx-templates.cpp === --- test/Profile/cxx-templates.cpp +++ test/Profile/cxx-templates.cpp @@ -6,7 +6,7 @@ // RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s // RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-path=%t.profdata -fprofile-instrument=clang-use > %tuse // RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s // RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s Index: test/Profile/cxx-rangefor.cpp === --- test/Profile/cxx-rangefor.cpp +++ test/Profile/cxx-rangefor.cpp @@ -4,7 +4,7 @@ // RUN: FileCheck --input-file=%tgen -check-prefix=CHECK -check-prefix=PGOGEN %s // RUN: llvm-profdata merge %S/Inputs/cxx-rangefor.proftext -o %t.profdata -// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instr-use=%t.profdata > %tuse +// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-rangefor.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-path=%t.profdata -fprofile-instrument=clang-use > %tuse // RUN: FileCheck --input-file=%tuse -check-prefix=CHECK -check-prefix=PGOUSE %s // PGOGEN: @[[RFC:__profc__Z9range_forv]] = private global [5 x i64] zeroinitializer Index: test/Profile/cxx-lambda.cpp === --- test/Profil
r261929 - [analyzer] Reapply r261917 with a fix.
Author: dcoughlin Date: Thu Feb 25 15:15:16 2016 New Revision: 261929 URL: http://llvm.org/viewvc/llvm-project?rev=261929&view=rev Log: [analyzer] Reapply r261917 with a fix. This reapplies "[analyzer] Make ObjCDeallocChecker path sensitive." (r261917) with a fix for an error on some bots about specializing a template from another namespace. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp cfe/trunk/test/Analysis/DeallocMissingRelease.m cfe/trunk/test/Analysis/MissingDealloc.m cfe/trunk/test/Analysis/PR2978.m cfe/trunk/test/Analysis/properties.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=261929&r1=261928&r2=261929&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Feb 25 15:15:16 2016 @@ -7,9 +7,24 @@ // //===--===// // -// This file defines a CheckObjCDealloc, a checker that -// analyzes an Objective-C class's implementation to determine if it -// correctly implements -dealloc. +// This checker analyzes Objective-C -dealloc methods and their callees +// to warn about improper releasing of instance variables that back synthesized +// properties. It warns about missing releases in the following cases: +// - When a class has a synthesized instance variable for a 'retain' or 'copy' +//property and lacks a -dealloc method in its implementation. +// - When a class has a synthesized instance variable for a 'retain'/'copy' +// property but the ivar is not released in -dealloc by either -release +// or by nilling out the property. +// +// It warns about extra releases in -dealloc (but not in callees) when a +// synthesized instance variable is released in the following cases: +// - When the property is 'assign' and is not 'readonly'. +// - When the property is 'weak'. +// +// This checker only warns for instance variables synthesized to back +// properties. Handling the more general case would require inferring whether +// an instance variable is stored retained or not. For synthesized properties, +// this is specified in the property declaration itself. // //===--===// @@ -20,71 +35,36 @@ #include "clang/AST/ExprObjC.h" #include "clang/Basic/LangOptions.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "llvm/Support/raw_ostream.h" using namespace clang; using namespace ento; -// FIXME: This was taken from IvarInvalidationChecker.cpp -static const Expr *peel(const Expr *E) { - E = E->IgnoreParenCasts(); - if (const PseudoObjectExpr *POE = dyn_cast(E)) -E = POE->getSyntacticForm()->IgnoreParenCasts(); - if (const OpaqueValueExpr *OVE = dyn_cast(E)) -E = OVE->getSourceExpr()->IgnoreParenCasts(); - return E; -} - -static bool scan_ivar_release(Stmt *S, const ObjCIvarDecl *ID, - const ObjCPropertyDecl *PD, - Selector Release, - IdentifierInfo* SelfII, - ASTContext &Ctx) { - - // [mMyIvar release] - if (ObjCMessageExpr *ME = dyn_cast(S)) -if (ME->getSelector() == Release) - if (ME->getInstanceReceiver()) -if (const Expr *Receiver = peel(ME->getInstanceReceiver())) - if (auto *E = dyn_cast(Receiver)) -if (E->getDecl() == ID) - return true; - - // [self setMyIvar:nil]; - if (ObjCMessageExpr *ME = dyn_cast(S)) -if (ME->getInstanceReceiver()) - if (const Expr *Receiver = peel(ME->getInstanceReceiver())) -if (auto *E = dyn_cast(Receiver)) - if (E->getDecl()->getIdentifier() == SelfII) -if (ME->getMethodDecl() == PD->getSetterMethodDecl() && -ME->getNumArgs() == 1 && -peel(ME->getArg(0))->isNullPointerConstant(Ctx, - Expr::NPC_ValueDependentIsNull)) - return true; - - // self.myIvar = nil; - if (BinaryOperator* BO = dyn_cast(S)) -if (BO->isAssignmentOp()) - if (auto *PRE = dyn_cast(peel(
Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects
majnemer updated this revision to Diff 49109. majnemer added a comment. - Refactor this change. http://reviews.llvm.org/D17619 Files: lib/AST/ExprConstant.cpp test/SemaCXX/ms-const-member-expr.cpp Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4427,6 +4427,15 @@ void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); } + + /// Potentially visit a MemberExpr's base expression. + void VisitIgnoredBaseExpression(const Expr *E) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx)) + return; +VisitIgnoredValue(E); + } }; } @@ -4750,14 +4759,14 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { // Handle static data members. if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); +VisitIgnoredBaseExpression(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { if (MD->isStatic()) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return Success(MD); } } @@ -6078,7 +6087,7 @@ } bool VisitMemberExpr(const MemberExpr *E) { if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return true; } Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4427,6 +4427,15 @@ void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); } + + /// Potentially visit a MemberExpr's base expression. + void VisitIgnoredBaseExpression(const Expr *E) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (Info.getLangOpts().MSVCCompat && !E->HasSideEffects(Info.Ctx)) + return; +VisitIgnoredValue(E); + } }; } @@ -4750,14 +4759,14 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { // Handle static data members. if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); +VisitIgnoredBaseExpression(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { if (MD->isStatic()) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return Success(MD); } } @@ -6078,7 +6087,7 @@ } bool VisitMemberExpr(const MemberExpr *E) { if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); + VisitIgnoredBaseExpression(E->getBase()); return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
shuaiwang updated this revision to Diff 49108. shuaiwang added a comment. more test cases http://reviews.llvm.org/D17586 Files: clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/RedundantStringInitCheck.cpp clang-tidy/readability/RedundantStringInitCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-redundant-string-init.rst test/clang-tidy/readability-redundant-string-init.cpp Index: test/clang-tidy/readability-redundant-string-init.cpp === --- /dev/null +++ test/clang-tidy/readability-redundant-string-init.cpp @@ -0,0 +1,83 @@ +// RUN: %check_clang_tidy %s readability-redundant-string-init %t + +namespace std { +template +class allocator {}; +template +class char_traits {}; +template , typename A = std::allocator> +struct basic_string { + basic_string(); + basic_string(const basic_string&); + basic_string(const C *, const A &a = A()); + ~basic_string(); +}; +typedef basic_string string; +typedef basic_string wstring; +} + +void f() { + std::string a = ""; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization [readability-redundant-string-init] + // CHECK-FIXES: std::string a; + std::string b(""); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string b; + std::string c = R"()"; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string c; + std::string d(R"()"); + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string d; + + std::string u = "u"; + std::string w("w"); + std::string x = R"(x)"; + std::string y(R"(y)"); + std::string z; +} + +void g() { + std::wstring a = L""; + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring a; + std::wstring b(L""); + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring b; + std::wstring c = LR"()"; + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring c; + std::wstring d(LR"()"); + // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization + // CHECK-FIXES: std::wstring d; + + std::wstring u = L"u"; + std::wstring w(L"w"); + std::wstring x = LR"(x)"; + std::wstring y(LR"(y)"); + std::wstring z; +} + +template +void templ() { + std::string s = ""; + // CHECK-MESSAGES: [[@LINE-1]]:15: warning: redundant string initialization + // CHECK-FIXES: std::string s; +} + +#define M(x) x +#define N { std::string s = ""; } + +void h() { + templ(); + templ(); + + M({ std::string s = ""; }) + // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization + // CHECK-FIXES: M({ std::string s; }) + + N + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization + N + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: redundant string initialization +} Index: docs/clang-tidy/checks/readability-redundant-string-init.rst === --- /dev/null +++ docs/clang-tidy/checks/readability-redundant-string-init.rst @@ -0,0 +1,16 @@ +.. title:: clang-tidy - readability-redundant-string-init + +readability-redundant-string-init += + + +Finds unnecessary string initializations. + +Examples: + +.. code:: c++ + + // Initializing string with empty string literal is unnecessary. + std::string a = ""; + std::string b(""); + Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -99,5 +99,6 @@ readability-redundant-control-flow readability-redundant-smartptr-get readability-redundant-string-cstr + readability-redundant-string-init readability-simplify-boolean-expr readability-uniqueptr-delete-release Index: clang-tidy/readability/RedundantStringInitCheck.h === --- /dev/null +++ clang-tidy/readability/RedundantStringInitCheck.h @@ -0,0 +1,32 @@ +//===- RedundantStringInitCheck.h - clang-tidy --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { +namespace readabili
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
shuaiwang marked 3 inline comments as done. shuaiwang added a comment. http://reviews.llvm.org/D17586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261926 - more status updates
Author: marshall Date: Thu Feb 25 14:17:03 2016 New Revision: 261926 URL: http://llvm.org/viewvc/llvm-project?rev=261926&view=rev Log: more status updates Modified: libcxx/trunk/www/upcoming_meeting.html Modified: libcxx/trunk/www/upcoming_meeting.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=261926&r1=261925&r2=261926&view=diff == --- libcxx/trunk/www/upcoming_meeting.html (original) +++ libcxx/trunk/www/upcoming_meeting.html Thu Feb 25 14:17:03 2016 @@ -70,7 +70,7 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2545";>2545Simplify wording for bind without explicitly specified return typeJacksonville http://cplusplus.github.io/LWG/lwg-defects.html#2557";>2557Logical operator traits are broken in the zero-argument caseJacksonvilleComplete http://cplusplus.github.io/LWG/lwg-defects.html#2558";>2558[fund.ts.v2] Logical operator traits are broken in the zero-argument caseJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2559";>2559Error in LWG 2234's resolutionJacksonville + http://cplusplus.github.io/LWG/lwg-defects.html#2559";>2559Error in LWG 2234's resolutionJacksonvilleComplete http://cplusplus.github.io/LWG/lwg-defects.html#2560";>2560is_constructible underspecified when applied to a function typeJacksonvilleBroken in 3.6; See r261653. http://cplusplus.github.io/LWG/lwg-defects.html#2565";>2565std::function's move constructor should guarantee nothrow for reference_wrappers and function pointersJacksonville http://cplusplus.github.io/LWG/lwg-defects.html#2566";>2566Requirements on the first template parameter of container adaptorsJacksonville @@ -81,8 +81,8 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator and ostream_iterator should use std::addressofJacksonvillePatch done; needs tests http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock should use std::addressofJacksonville http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency wrt Allocators in basic_string assignment vs. basic_string::assignJacksonvillePatch Ready - http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization ofvariable templates should be prohibitedJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2582";>2582§[res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traitsJacksonville + http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization of variable templates should be prohibitedJacksonvilleComplete + http://cplusplus.github.io/LWG/lwg-defects.html#2582";>2582§[res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traitsJacksonvilleIn Progress http://cplusplus.github.io/LWG/lwg-defects.html#2583";>2583There is no way to supply an allocator for basic_string(str, pos)JacksonvillePatch Ready http://cplusplus.github.io/LWG/lwg-defects.html#2585";>2585forward_list::resize(size_type, const value_type&) effects incorrectJacksonvilleDisputed http://cplusplus.github.io/LWG/lwg-defects.html#2586";>2586Wrong value category used in scoped_allocator_adaptor::construct()Jacksonville @@ -104,7 +104,7 @@ 2545 - 2557 - Cleaning up wording; no code change required. 2558 - Cleaning up wording; no code change required. -2559 - +2559 - Cleaning up wording; no code change required. 2560 - We already do this; added tests in r261653. More: the new tests fail on green-dragon-09, so I reverted it. Will recommit after green-dragon bots are updated. Probably need to XFAIL for clang3-6 as well (arm bots) 2565 - 2566 - @@ -115,11 +115,11 @@ 2576 - This one is simple, but testing it will be hard. I tried making a sublass of istringstream, but it got sliced. 2577 - This one is simple 2579 - Done -2581 - -2582 - +2581 - Nothing to do here. +2582 - I've added tests to meta.unary.cat; no code changes needed yet. 2583 - Done 2585 - This looks easy; but Alisdair wants to NAD this issue. -2586 - +2586 - We need to fix PR24075 when we do this. 2590 - We already do this; added tests in r261648. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261925 - Added tests to make sure that the categorization traits work on incomplete types
Author: marshall Date: Thu Feb 25 14:15:47 2016 New Revision: 261925 URL: http://llvm.org/viewvc/llvm-project?rev=261925&view=rev Log: Added tests to make sure that the categorization traits work on incomplete types Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer_no_variadics.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp?rev=261925&r1=261924&r2=261925&view=diff == --- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp Thu Feb 25 14:15:47 2016 @@ -12,12 +12,13 @@ // array #include +#include "test_macros.h" template void test_array_imp() { static_assert(!std::is_void::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer::value, ""); #endif static_assert(!std::is_integral::value, ""); @@ -46,10 +47,14 @@ void test_array() typedef char array[3]; typedef const char const_array[3]; typedef char incomplete_array[]; +struct incomplete_type; int main() { test_array(); test_array(); test_array(); + +// LWG#2581 +static_assert(!std::is_array::value, ""); } Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp?rev=261925&r1=261924&r2=261925&view=diff == --- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp Thu Feb 25 14:15:47 2016 @@ -12,12 +12,13 @@ // class #include +#include "test_macros.h" template void test_class_imp() { static_assert(!std::is_void::value, ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(!std::is_null_pointer::value, ""); #endif static_assert(!std::is_integral::value, ""); @@ -47,7 +48,12 @@ class Class { }; +struct incomplete_type; + int main() { test_class(); + +// LWG#2581 +static_assert( std::is_class::value, ""); }
[PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.
erik65536 created this revision. erik65536 added reviewers: djasper, klimek. erik65536 added a subscriber: cfe-commits. Herald added a subscriber: klimek. http://reviews.llvm.org/D17621 Files: lib/Format/TokenAnnotator.cpp Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -504,7 +504,7 @@ Tok->Type = TT_BitFieldColon; } else if (Contexts.size() == 1 && !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) { -if (Tok->Previous->is(tok::r_paren)) +if (Tok->Previous->is(tok::r_paren) || Tok->Previous->is(tok::kw_noexcept)) Tok->Type = TT_CtorInitializerColon; else Tok->Type = TT_InheritanceColon; Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -504,7 +504,7 @@ Tok->Type = TT_BitFieldColon; } else if (Contexts.size() == 1 && !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) { -if (Tok->Previous->is(tok::r_paren)) +if (Tok->Previous->is(tok::r_paren) || Tok->Previous->is(tok::kw_noexcept)) Tok->Type = TT_CtorInitializerColon; else Tok->Type = TT_InheritanceColon; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects
majnemer updated this revision to Diff 49103. majnemer added a comment. - Add support for static data members too. http://reviews.llvm.org/D17619 Files: lib/AST/ExprConstant.cpp test/SemaCXX/ms-const-member-expr.cpp Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4748,14 +4748,20 @@ } bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { + ValueDecl *MemberDecl = E->getMemberDecl(); + ASTContext &Ctx = MemberDecl->getASTContext(); + // Handle static data members. - if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); + if (const auto *VD = dyn_cast(MemberDecl)) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) + VisitIgnoredValue(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. - if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { + if (const auto *MD = dyn_cast(MemberDecl)) { if (MD->isStatic()) { VisitIgnoredValue(E->getBase()); return Success(MD); @@ -6077,8 +6083,14 @@ return ExprEvaluatorBaseTy::VisitDeclRefExpr(E); } bool VisitMemberExpr(const MemberExpr *E) { -if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); +ValueDecl *MemberDecl = E->getMemberDecl(); +ASTContext &Ctx = MemberDecl->getASTContext(); +if (CheckReferencedDecl(E, MemberDecl)) { + // While MSVC doesn't evaluate the base expression, it does diagnose the + // presence of side-effecting behavior. + if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) { +VisitIgnoredValue(E->getBase()); + } return true; } Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; + static const int sdm = 1; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} + +constexpr int e4 = s->sdm; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4748,14 +4748,20 @@ } bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) { + ValueDecl *MemberDecl = E->getMemberDecl(); + ASTContext &Ctx = MemberDecl->getASTContext(); + // Handle static data members. - if (const VarDecl *VD = dyn_cast(E->getMemberDecl())) { -VisitIgnoredValue(E->getBase()); + if (const auto *VD = dyn_cast(MemberDecl)) { +// While MSVC doesn't evaluate the base expression, it does diagnose the +// presence of side-effecting behavior. +if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) + VisitIgnoredValue(E->getBase()); return VisitVarDecl(E, VD); } // Handle static member functions. - if (const CXXMethodDecl *MD = dyn_cast(E->getMemberDecl())) { + if (const auto *MD = dyn_cast(MemberDecl)) { if (MD->isStatic()) { VisitIgnoredValue(E->getBase()); return Success(MD); @@ -6077,8 +6083,14 @@ return ExprEvaluatorBaseTy::VisitDeclRefExpr(E); } bool VisitMemberExpr(const MemberExpr *E) { -if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); +ValueDecl *MemberDecl = E->getMemberDecl(); +ASTContext &Ctx = MemberDecl->getASTContext(); +if (CheckReferencedDecl(E, MemberDecl)) { + // While MSVC doesn't evaluate the base expression, it does diagnose the + // presence of side-effecting behavior. + if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) { +VisitIgnoredValue(E->getBase()); + } return
[PATCH] D17619: [MSVC Compat] Don't evaluate member base expressions w/o side effects
majnemer created this revision. majnemer added reviewers: rsmith, andreybokhanko. majnemer added a subscriber: cfe-commits. A member expression's base doesn't always have an impact on what the member decl would evaluate to. In such a case, the base is used as a poor man's scope qualifier. This fixes PR26738. http://reviews.llvm.org/D17619 Files: lib/AST/ExprConstant.cpp test/SemaCXX/ms-const-member-expr.cpp Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -6077,8 +6077,14 @@ return ExprEvaluatorBaseTy::VisitDeclRefExpr(E); } bool VisitMemberExpr(const MemberExpr *E) { -if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); +ValueDecl *MemberDecl = E->getMemberDecl(); +ASTContext &Ctx = MemberDecl->getASTContext(); +if (CheckReferencedDecl(E, MemberDecl)) { + // While MSVC doesn't evaluate the base expression, it does diagnose the + // presence of side-effecting behavior. + if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) { +VisitIgnoredValue(E->getBase()); + } return true; } Index: test/SemaCXX/ms-const-member-expr.cpp === --- /dev/null +++ test/SemaCXX/ms-const-member-expr.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -fsyntax-only -verify + +struct S { + enum { E = 1 }; +}; + +void f(S *s) { + char array[s->E] = { 0 }; +} + +extern S *s; +constexpr int e1 = s->E; + +S *side_effect(); // expected-note{{declared here}} +constexpr int e2 = // expected-error{{must be initialized by a constant expression}} +side_effect()->E; // expected-note{{cannot be used in a constant expression}} Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -6077,8 +6077,14 @@ return ExprEvaluatorBaseTy::VisitDeclRefExpr(E); } bool VisitMemberExpr(const MemberExpr *E) { -if (CheckReferencedDecl(E, E->getMemberDecl())) { - VisitIgnoredValue(E->getBase()); +ValueDecl *MemberDecl = E->getMemberDecl(); +ASTContext &Ctx = MemberDecl->getASTContext(); +if (CheckReferencedDecl(E, MemberDecl)) { + // While MSVC doesn't evaluate the base expression, it does diagnose the + // presence of side-effecting behavior. + if (!Info.getLangOpts().MSVCCompat || E->getBase()->HasSideEffects(Ctx)) { +VisitIgnoredValue(E->getBase()); + } return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261921 - Revert "[analyzer] Make ObjCDeallocChecker path sensitive."
Author: dcoughlin Date: Thu Feb 25 13:13:43 2016 New Revision: 261921 URL: http://llvm.org/viewvc/llvm-project?rev=261921&view=rev Log: Revert "[analyzer] Make ObjCDeallocChecker path sensitive." This reverts commit r261917. It broke the bots. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp cfe/trunk/test/Analysis/DeallocMissingRelease.m cfe/trunk/test/Analysis/MissingDealloc.m cfe/trunk/test/Analysis/PR2978.m cfe/trunk/test/Analysis/properties.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=261921&r1=261920&r2=261921&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Feb 25 13:13:43 2016 @@ -7,24 +7,9 @@ // //===--===// // -// This checker analyzes Objective-C -dealloc methods and their callees -// to warn about improper releasing of instance variables that back synthesized -// properties. It warns about missing releases in the following cases: -// - When a class has a synthesized instance variable for a 'retain' or 'copy' -//property and lacks a -dealloc method in its implementation. -// - When a class has a synthesized instance variable for a 'retain'/'copy' -// property but the ivar is not released in -dealloc by either -release -// or by nilling out the property. -// -// It warns about extra releases in -dealloc (but not in callees) when a -// synthesized instance variable is released in the following cases: -// - When the property is 'assign' and is not 'readonly'. -// - When the property is 'weak'. -// -// This checker only warns for instance variables synthesized to back -// properties. Handling the more general case would require inferring whether -// an instance variable is stored retained or not. For synthesized properties, -// this is specified in the property declaration itself. +// This file defines a CheckObjCDealloc, a checker that +// analyzes an Objective-C class's implementation to determine if it +// correctly implements -dealloc. // //===--===// @@ -35,36 +20,71 @@ #include "clang/AST/ExprObjC.h" #include "clang/Basic/LangOptions.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" -#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "llvm/Support/raw_ostream.h" using namespace clang; using namespace ento; -/// Indicates whether an instance variable is required to be released in -/// -dealloc. -enum class ReleaseRequirement { - /// The instance variable must be released, either by calling - /// -release on it directly or by nilling it out with a property setter. - MustRelease, - - /// The instance variable must not be directly released with -release. - MustNotReleaseDirectly, +// FIXME: This was taken from IvarInvalidationChecker.cpp +static const Expr *peel(const Expr *E) { + E = E->IgnoreParenCasts(); + if (const PseudoObjectExpr *POE = dyn_cast(E)) +E = POE->getSyntacticForm()->IgnoreParenCasts(); + if (const OpaqueValueExpr *OVE = dyn_cast(E)) +E = OVE->getSourceExpr()->IgnoreParenCasts(); + return E; +} + +static bool scan_ivar_release(Stmt *S, const ObjCIvarDecl *ID, + const ObjCPropertyDecl *PD, + Selector Release, + IdentifierInfo* SelfII, + ASTContext &Ctx) { + + // [mMyIvar release] + if (ObjCMessageExpr *ME = dyn_cast(S)) +if (ME->getSelector() == Release) + if (ME->getInstanceReceiver()) +if (const Expr *Receiver = peel(ME->getInstanceReceiver())) + if (auto *E = dyn_cast(Receiver)) +if (E->getDecl() == ID) + return true; + + // [self setMyIvar:nil]; + if (ObjCMessageExpr *ME = dyn_cast(S)) +if (ME->getInstanceReceiver()) + if (const Expr *Receiver = peel(ME->getInstanceReceiver())) +if (auto *E = dyn_cast(Receiver)) + if (E->getDecl()->getIdentifier() == SelfII) +if (ME->getMethodDecl() == PD->getSetterMethodDecl() && +ME->getNumArgs() == 1 && +peel(ME->g
Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.
This revision was automatically updated to reflect the committed changes. Closed by commit rL261917: [analyzer] Make ObjCDeallocChecker path sensitive. (authored by dcoughlin). Changed prior to commit: http://reviews.llvm.org/D17511?vs=48995&id=49097#toc Repository: rL LLVM http://reviews.llvm.org/D17511 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp cfe/trunk/test/Analysis/DeallocMissingRelease.m cfe/trunk/test/Analysis/MissingDealloc.m cfe/trunk/test/Analysis/PR2978.m cfe/trunk/test/Analysis/properties.m Index: cfe/trunk/test/Analysis/DeallocMissingRelease.m === --- cfe/trunk/test/Analysis/DeallocMissingRelease.m +++ cfe/trunk/test/Analysis/DeallocMissingRelease.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks %s 2>&1 | FileCheck -check-prefix=CHECK %s -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak %s 2>&1 | FileCheck -check-prefix=CHECK-ARC -allow-empty '--implicit-check-not=error:' '--implicit-check-not=warning:' %s +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s #define nil ((id)0) @@ -11,22 +11,27 @@ #define WEAK_ON_ARC __weak #endif +// No diagnostics expected under ARC. +#if !NON_ARC + // expected-no-diagnostics +#endif + typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; - (Class)class; @end @interface NSObject {} ++ (instancetype)alloc; - (void)dealloc; - (id)init; - (id)retain; - (oneway void)release; @end typedef struct objc_selector *SEL; -//====== // Do not warn about missing release in -dealloc for ivars. @interface MyIvarClass1 : NSObject { @@ -87,33 +92,30 @@ } @end -//====== // Warn about missing release in -dealloc for properties. @interface MyPropertyClass1 : NSObject -// CHECK: DeallocMissingRelease.m:[[@LINE+1]]:1: warning: The '_ivar' instance variable in 'MyPropertyClass1' was retained by a synthesized property but was not released in 'dealloc' @property (copy) NSObject *ivar; @end @implementation MyPropertyClass1 - (void)dealloc { #if NON_ARC - [super dealloc]; + [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass1' was copied by a synthesized property but not released before '[super dealloc]'}} #endif } @end @interface MyPropertyClass2 : NSObject -// CHECK: DeallocMissingRelease.m:[[@LINE+1]]:1: warning: The '_ivar' instance variable in 'MyPropertyClass2' was retained by a synthesized property but was not released in 'dealloc' @property (retain) NSObject *ivar; @end @implementation MyPropertyClass2 - (void)dealloc { #if NON_ARC - [super dealloc]; + [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass2' was retained by a synthesized property but not released before '[super dealloc]'}} #endif } @end @@ -125,14 +127,14 @@ @end @implementation MyPropertyClass3 -// CHECK: DeallocMissingRelease.m:[[@LINE+1]]:1: warning: The '_ivar' instance variable in 'MyPropertyClass3' was retained by a synthesized property but was not released in 'dealloc' @synthesize ivar = _ivar; - (void)dealloc { #if NON_ARC - [super dealloc]; + [super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass3' was retained by a synthesized property but not released before '[super dealloc]'}} #endif } + @end @interface MyPropertyClass4 : NSObject { @@ -142,12 +144,11 @@ @end @implementation MyPropertyClass4 -// CHECK: DeallocMissingRelease.m:[[@LINE+1]]:1: warning: The '_blockPropertyIvar' instance variable in 'MyPropertyClass4' was retained by a synthesized property but was not released in 'dealloc' @synthesize blockProperty = _blockPropertyIvar; - (void)dealloc { #if NON_ARC - [super dealloc]; + [super dealloc]; // expected-warning {{The '_blockPropertyIvar' ivar in 'MyPropertyClass4' was copied by a synthesized property but not released before '[super dealloc]'}} #endif } @end @@ -159,16 +160,77 @@ @end @implementation MyPropertyClass5 -@synthesize ivar = _ivar; // no-warning +@synthesize ivar = _ivar; - (void)dealloc { #if NON_ARC + [super dealloc]; // no-warning because it is a weak property +#endif +} +@end + +@interface MyPropertyClassWithReturnInDealloc : NSObject { + NSObject *_ivar; +} +@property (retain) NSObject *ivar; +@end + +@implementation MyPropertyClassWithReturnInDealloc +@synthesize ivar = _ivar; +- (void)dealloc +{ + return; +#if NON_ARC + // expected-warning@-2{{The '_ivar' ivar in 'MyPropertyClassWithReturnInDealloc' was re
r261917 - [analyzer] Make ObjCDeallocChecker path sensitive.
Author: dcoughlin Date: Thu Feb 25 12:55:24 2016 New Revision: 261917 URL: http://llvm.org/viewvc/llvm-project?rev=261917&view=rev Log: [analyzer] Make ObjCDeallocChecker path sensitive. Convert the ObjCDeallocChecker to be path sensitive. The primary motivation for this change is to prevent false positives when -dealloc calls helper invalidation methods to release instance variables, but it additionally improves precision when -dealloc contains control flow. It also reduces the need for pattern matching. The check for missing -dealloc methods remains AST-based. Part of rdar://problem/6927496 Differential Revision: http://reviews.llvm.org/D17511 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp cfe/trunk/test/Analysis/DeallocMissingRelease.m cfe/trunk/test/Analysis/MissingDealloc.m cfe/trunk/test/Analysis/PR2978.m cfe/trunk/test/Analysis/properties.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=261917&r1=261916&r2=261917&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Thu Feb 25 12:55:24 2016 @@ -7,9 +7,24 @@ // //===--===// // -// This file defines a CheckObjCDealloc, a checker that -// analyzes an Objective-C class's implementation to determine if it -// correctly implements -dealloc. +// This checker analyzes Objective-C -dealloc methods and their callees +// to warn about improper releasing of instance variables that back synthesized +// properties. It warns about missing releases in the following cases: +// - When a class has a synthesized instance variable for a 'retain' or 'copy' +//property and lacks a -dealloc method in its implementation. +// - When a class has a synthesized instance variable for a 'retain'/'copy' +// property but the ivar is not released in -dealloc by either -release +// or by nilling out the property. +// +// It warns about extra releases in -dealloc (but not in callees) when a +// synthesized instance variable is released in the following cases: +// - When the property is 'assign' and is not 'readonly'. +// - When the property is 'weak'. +// +// This checker only warns for instance variables synthesized to back +// properties. Handling the more general case would require inferring whether +// an instance variable is stored retained or not. For synthesized properties, +// this is specified in the property declaration itself. // //===--===// @@ -20,71 +35,36 @@ #include "clang/AST/ExprObjC.h" #include "clang/Basic/LangOptions.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h" #include "llvm/Support/raw_ostream.h" using namespace clang; using namespace ento; -// FIXME: This was taken from IvarInvalidationChecker.cpp -static const Expr *peel(const Expr *E) { - E = E->IgnoreParenCasts(); - if (const PseudoObjectExpr *POE = dyn_cast(E)) -E = POE->getSyntacticForm()->IgnoreParenCasts(); - if (const OpaqueValueExpr *OVE = dyn_cast(E)) -E = OVE->getSourceExpr()->IgnoreParenCasts(); - return E; -} - -static bool scan_ivar_release(Stmt *S, const ObjCIvarDecl *ID, - const ObjCPropertyDecl *PD, - Selector Release, - IdentifierInfo* SelfII, - ASTContext &Ctx) { - - // [mMyIvar release] - if (ObjCMessageExpr *ME = dyn_cast(S)) -if (ME->getSelector() == Release) - if (ME->getInstanceReceiver()) -if (const Expr *Receiver = peel(ME->getInstanceReceiver())) - if (auto *E = dyn_cast(Receiver)) -if (E->getDecl() == ID) - return true; - - // [self setMyIvar:nil]; - if (ObjCMessageExpr *ME = dyn_cast(S)) -if (ME->getInstanceReceiver()) - if (const Expr *Receiver = peel(ME->getInstanceReceiver())) -if (auto *E = dyn_cast(Receiver)) - if (E->getDecl()->getIdentifier() == SelfII) -if (ME->getMethodDecl() == PD->getSetterMethodDecl() && -ME->getNumArgs() == 1
r261911 - [CMake] Fixing install-clang-headers dependencies to depend on generating the headers.
Author: cbieneman Date: Thu Feb 25 12:39:19 2016 New Revision: 261911 URL: http://llvm.org/viewvc/llvm-project?rev=261911&view=rev Log: [CMake] Fixing install-clang-headers dependencies to depend on generating the headers. Modified: cfe/trunk/lib/Headers/CMakeLists.txt Modified: cfe/trunk/lib/Headers/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=261911&r1=261910&r2=261911&view=diff == --- cfe/trunk/lib/Headers/CMakeLists.txt (original) +++ cfe/trunk/lib/Headers/CMakeLists.txt Thu Feb 25 12:39:19 2016 @@ -110,7 +110,7 @@ install( if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's. add_custom_target(install-clang-headers -DEPENDS +DEPENDS clang-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=clang-headers -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.
dcoughlin added inline comments. Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:804 @@ +803,3 @@ +/// Returns true if there is a call to -dealloc anywhere on the stack and false +/// otherwise. If true, it also sets \param SelfValOut to the value of +/// 'self' in the frame for -dealloc. ddkilzer wrote: > ddkilzer wrote: > > I think you meant "/param InstanceValOut" here. > And I meant "\param InstanceValOut". 😐 Thanks! Will fix. http://reviews.llvm.org/D17511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Looks good. Thank you for fixing this! http://reviews.llvm.org/D17335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r261814 - check-clang-tools: Introduce the feature "target-headers".
Thanks! r261897. On Fri, Feb 26, 2016 at 1:55 AM Alexander Kornienko wrote: > I've committed r261893 that adds stub headers and points the tool to the > right search directory. If the solution works, this commit can be reverted. > > On Thu, Feb 25, 2016 at 2:12 AM, NAKAMURA Takumi via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: chapuni >> Date: Wed Feb 24 19:12:57 2016 >> New Revision: 261814 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=261814&view=rev >> Log: >> check-clang-tools: Introduce the feature "target-headers". >> >> For now, it just detects that host is non-Windows and target is msvc. >> >> FIXME: It should be probable for cross compilations. Detect whether >> target's headers would be available. >> >> Modified: >> >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp >> >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp >> clang-tools-extra/trunk/test/lit.cfg >> >> Modified: >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261814&r1=261813&r2=261814&view=diff >> >> == >> --- >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp >> (original) >> +++ >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp >> Wed Feb 24 19:12:57 2016 >> @@ -1,4 +1,5 @@ >> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- >> -std=c++03 -isystem %S/Inputs/Headers >> +// REQUIRES: target-headers >> >> #include >> #include >> >> Modified: >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261814&r1=261813&r2=261814&view=diff >> >> == >> --- >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp >> (original) >> +++ >> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp >> Wed Feb 24 19:12:57 2016 >> @@ -1,4 +1,5 @@ >> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- >> -std=c++11 -isystem %S/Inputs/Headers >> +// REQUIRES: target-headers >> >> #include >> #include >> >> Modified: clang-tools-extra/trunk/test/lit.cfg >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=261814&r1=261813&r2=261814&view=diff >> >> == >> --- clang-tools-extra/trunk/test/lit.cfg (original) >> +++ clang-tools-extra/trunk/test/lit.cfg Wed Feb 24 19:12:57 2016 >> @@ -189,6 +189,12 @@ if not platform.system() in ['Windows'] >> if platform.system() not in ['Windows']: >> config.available_features.add('ansi-escape-sequences') >> >> +# Set if default-target's system headers available. >> +# For example in general, MS headers are supposed unavailable on >> non-Windows hosts. >> +# FIXME: It should be probable for cross compilations. >> +if not (platform.system() not in ['Windows'] and re.match(r'.*-win32$', >> config.target_triple)): >> +config.available_features.add('target-headers') >> + >> check_clang_tidy = os.path.join( >> config.test_source_root, "clang-tidy", "check_clang_tidy.py") >> config.substitutions.append( >> >> >> ___ >> 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] D16876: [OpenCL] Refine pipe builtin support
yaxunl accepted this revision. yaxunl added a comment. LGTM. Thanks. http://reviews.llvm.org/D16876 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r261897 - Revert r261814, "check-clang-tools: Introduce the feature target-headers", corresponding to r261893.
Author: chapuni Date: Thu Feb 25 10:59:59 2016 New Revision: 261897 URL: http://llvm.org/viewvc/llvm-project?rev=261897&view=rev Log: Revert r261814, "check-clang-tools: Introduce the feature target-headers", corresponding to r261893. Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp clang-tools-extra/trunk/test/lit.cfg Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261897&r1=261896&r2=261897&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp Thu Feb 25 10:59:59 2016 @@ -1,5 +1,4 @@ // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- -std=c++03 -v -// REQUIRES: target-headers #include #include Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261897&r1=261896&r2=261897&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp Thu Feb 25 10:59:59 2016 @@ -1,5 +1,4 @@ // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- -std=c++11 -v -// REQUIRES: target-headers #include #include Modified: clang-tools-extra/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=261897&r1=261896&r2=261897&view=diff == --- clang-tools-extra/trunk/test/lit.cfg (original) +++ clang-tools-extra/trunk/test/lit.cfg Thu Feb 25 10:59:59 2016 @@ -189,12 +189,6 @@ if not platform.system() in ['Windows'] if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') -# Set if default-target's system headers available. -# For example in general, MS headers are supposed unavailable on non-Windows hosts. -# FIXME: It should be probable for cross compilations. -if not (platform.system() not in ['Windows'] and re.match(r'.*-win32$', config.target_triple)): -config.available_features.add('target-headers') - check_clang_tidy = os.path.join( config.test_source_root, "clang-tidy", "check_clang_tidy.py") config.substitutions.append( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261896 - Update the status of a N4089 and a couple issues
Author: marshall Date: Thu Feb 25 10:55:58 2016 New Revision: 261896 URL: http://llvm.org/viewvc/llvm-project?rev=261896&view=rev Log: Update the status of a N4089 and a couple issues Modified: libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=261896&r1=261895&r2=261896&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Thu Feb 25 10:55:58 2016 @@ -53,7 +53,7 @@ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3346.pdf";>3346LWGTerminology for Container Element Requirements - Rev 1KonaComplete3.4 --> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911";>N3911LWGTransformationTrait Alias void_t.UrbanaComplete3.6 - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089";>N4089LWGSafe conversions in unique_ptr.Urbana + http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089";>N4089LWGSafe conversions in unique_ptr .UrbanaIn progress3.9 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169";>N4169LWGA proposal to add invoke function templateUrbanaComplete3.7 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190";>N4190LWGRemoving auto_ptr, random_shuffle(), And Old Stuff.Urbana http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258";>N4258LWGCleaning-up noexcept in the Library.UrbanaIn progress3.7 @@ -85,7 +85,7 @@ Issue #Issue NameMeetingStatus http://cplusplus.github.io/LWG/lwg-defects.html#2016";>2016Allocators must be no-throw swappableUrbana - http://cplusplus.github.io/LWG/lwg-defects.html#2376";>2118unique_ptr for array does not support cv qualification conversion of actual argumentUrbanaWill be resolved by N4089 + http://cplusplus.github.io/LWG/lwg-defects.html#2376";>2118unique_ptr for array does not support cv qualification conversion of actual argumentUrbanaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2170";>2170Aggregates cannot be DefaultConstructibleUrbanaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2308";>2308Clarify container destructor requirements w.r.t. std::arrayUrbanaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2340";>2340Replacement allocation functions declared as inlineUrbanaComplete @@ -192,7 +192,7 @@ - Last Updated: 25-Jan-2016 + Last Updated: 25-Feb-2016 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261894 - Another chunk of N4089
Author: marshall Date: Thu Feb 25 10:50:51 2016 New Revision: 261894 URL: http://llvm.org/viewvc/llvm-project?rev=261894&view=rev Log: Another chunk of N4089 Modified: libcxx/trunk/include/memory Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=261894&r1=261893&r2=261894&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Thu Feb 25 10:50:51 2016 @@ -2548,7 +2548,7 @@ public: typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT { static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type"); -static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type"); +static_assert(!is_void<_Tp>::value, "default_delete can not delete void type"); delete [] __ptr; } }; @@ -2918,7 +2918,6 @@ public: return __t; } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template _LIBCPP_INLINE_VISIBILITY typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, void>::type @@ -2929,29 +2928,13 @@ public: if (__tmp) __ptr_.second()(__tmp); } -_LIBCPP_INLINE_VISIBILITY void reset(nullptr_t) _NOEXCEPT -{ -pointer __tmp = __ptr_.first(); -__ptr_.first() = nullptr; -if (__tmp) -__ptr_.second()(__tmp); -} -_LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT +_LIBCPP_INLINE_VISIBILITY void reset(nullptr_t = nullptr) _NOEXCEPT { pointer __tmp = __ptr_.first(); __ptr_.first() = nullptr; if (__tmp) __ptr_.second()(__tmp); } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES -_LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) -{ -pointer __tmp = __ptr_.first(); -__ptr_.first() = __p; -if (__tmp) -__ptr_.second()(__tmp); -} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) {__ptr_.swap(__u.__ptr_);} private: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r261814 - check-clang-tools: Introduce the feature "target-headers".
I've committed r261893 that adds stub headers and points the tool to the right search directory. If the solution works, this commit can be reverted. On Thu, Feb 25, 2016 at 2:12 AM, NAKAMURA Takumi via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: chapuni > Date: Wed Feb 24 19:12:57 2016 > New Revision: 261814 > > URL: http://llvm.org/viewvc/llvm-project?rev=261814&view=rev > Log: > check-clang-tools: Introduce the feature "target-headers". > > For now, it just detects that host is non-Windows and target is msvc. > > FIXME: It should be probable for cross compilations. Detect whether > target's headers would be available. > > Modified: > > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp > > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp > clang-tools-extra/trunk/test/lit.cfg > > Modified: > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261814&r1=261813&r2=261814&view=diff > > == > --- > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp > (original) > +++ > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp > Wed Feb 24 19:12:57 2016 > @@ -1,4 +1,5 @@ > // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- > -std=c++03 -isystem %S/Inputs/Headers > +// REQUIRES: target-headers > > #include > #include > > Modified: > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261814&r1=261813&r2=261814&view=diff > > == > --- > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp > (original) > +++ > clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp > Wed Feb 24 19:12:57 2016 > @@ -1,4 +1,5 @@ > // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- > -std=c++11 -isystem %S/Inputs/Headers > +// REQUIRES: target-headers > > #include > #include > > Modified: clang-tools-extra/trunk/test/lit.cfg > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=261814&r1=261813&r2=261814&view=diff > > == > --- clang-tools-extra/trunk/test/lit.cfg (original) > +++ clang-tools-extra/trunk/test/lit.cfg Wed Feb 24 19:12:57 2016 > @@ -189,6 +189,12 @@ if not platform.system() in ['Windows'] > if platform.system() not in ['Windows']: > config.available_features.add('ansi-escape-sequences') > > +# Set if default-target's system headers available. > +# For example in general, MS headers are supposed unavailable on > non-Windows hosts. > +# FIXME: It should be probable for cross compilations. > +if not (platform.system() not in ['Windows'] and re.match(r'.*-win32$', > config.target_triple)): > +config.available_features.add('target-headers') > + > check_clang_tidy = os.path.join( > config.test_source_root, "clang-tidy", "check_clang_tidy.py") > config.substitutions.append( > > > ___ > 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: [clang-tools-extra] r261737 - [clang-tidy] Added a check for forward declaration in the potentially wrong namespace
Let's see if r261893 fixes this. On Thu, Feb 25, 2016 at 4:31 PM, Alexander Kornienko wrote: > Yes, I know. Trying to come up with a good solution. > > On Thu, Feb 25, 2016 at 4:59 AM, Sean Silva wrote: > >> This or r261737 seem to be causing a bot failure: >> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/636 >> >> -- Sean Silva >> >> On Wed, Feb 24, 2016 at 5:35 AM, Alexander Kornienko via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Author: alexfh >>> Date: Wed Feb 24 07:35:32 2016 >>> New Revision: 261737 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=261737&view=rev >>> Log: >>> [clang-tidy] Added a check for forward declaration in the potentially >>> wrong namespace >>> >>> Adds a new check "misc-forward-declaration-namespace". >>> In check, A forward declaration is considerred in a potentially wrong >>> namespace >>> if there is any definition/declaration with the same name exists in a >>> different >>> namespace. >>> >>> Reviewers: akuegel, hokein, alexfh >>> >>> Patch by Eric Liu! >>> >>> Differential Revision: http://reviews.llvm.org/D17195 >>> >>> Added: >>> >>> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >>> >>> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.h >>> >>> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forward-declaration-namespace.rst >>> >>> clang-tools-extra/trunk/test/clang-tidy/misc-forward-declaration-namespace.cpp >>> Modified: >>> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt >>> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp >>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst >>> >>> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt >>> URL: >>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=261737&r1=261736&r2=261737&view=diff >>> >>> == >>> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original) >>> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Feb 24 >>> 07:35:32 2016 >>> @@ -6,6 +6,7 @@ add_clang_library(clangTidyMiscModule >>>AssignOperatorSignatureCheck.cpp >>>BoolPointerImplicitConversionCheck.cpp >>>DefinitionsInHeadersCheck.cpp >>> + ForwardDeclarationNamespaceCheck.cpp >>>InaccurateEraseCheck.cpp >>>IncorrectRoundings.cpp >>>InefficientAlgorithmCheck.cpp >>> >>> Added: >>> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=261737&view=auto >>> >>> == >>> --- >>> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >>> (added) >>> +++ >>> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >>> Wed Feb 24 07:35:32 2016 >>> @@ -0,0 +1,174 @@ >>> +//===--- ForwardDeclarationNamespaceCheck.cpp - clang-tidy --*- C++ >>> -*-===// >>> +// >>> +// The LLVM Compiler Infrastructure >>> +// >>> +// This file is distributed under the University of Illinois Open Source >>> +// License. See LICENSE.TXT for details. >>> +// >>> >>> +//===--===// >>> + >>> +#include "ForwardDeclarationNamespaceCheck.h" >>> +#include >>> +#include >>> +#include "clang/AST/ASTContext.h" >>> +#include "clang/AST/Decl.h" >>> +#include "clang/ASTMatchers/ASTMatchFinder.h" >>> +#include "clang/ASTMatchers/ASTMatchers.h" >>> + >>> +using namespace clang::ast_matchers; >>> + >>> +namespace clang { >>> +namespace tidy { >>> +namespace misc { >>> + >>> +void ForwardDeclarationNamespaceCheck::registerMatchers(MatchFinder >>> *Finder) { >>> + // Match all class declarations/definitions *EXCEPT* >>> + // 1. implicit classes, e.g. `class A {};` has implicit `class A` >>> inside `A`. >>> + // 2. nested classes declared/defined inside another class. >>> + // 3. template class declaration, template instantiation or >>> + //specialization (NOTE: extern specialization is filtered out by >>> + //`unless(hasAncestor(cxxRecordDecl()))`). >>> + auto IsInSpecialization = hasAncestor( >>> + decl(anyOf(cxxRecordDecl(isExplicitTemplateSpecialization()), >>> + functionDecl(isExplicitTemplateSpecialization(); >>> + Finder->addMatcher( >>> + cxxRecordDecl( >>> + hasParent(decl(anyOf(namespaceDecl(), >>> translationUnitDecl(, >>> + unless(isImplicit()), unless(hasAncestor(cxxRecordDecl())), >>> + unless(isInstantiated()), unless(IsInSpecialization), >>> + unless(classTemplateSpecializationDecl())) >>> + .bind("record_decl"), >>> + this); >>> + >>> + // Match all friend declarations. Classes used in fr
[clang-tools-extra] r261893 - [clang-tidy] Adding headers needed in modernize-deprecated-headers tests
Author: alexfh Date: Thu Feb 25 10:46:54 2016 New Revision: 261893 URL: http://llvm.org/viewvc/llvm-project?rev=261893&view=rev Log: [clang-tidy] Adding headers needed in modernize-deprecated-headers tests Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/ clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/assert.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/complex.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/ctype.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/errno.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/fenv.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/float.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/inttypes.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/iso646.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/limits.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/locale.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/math.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/setjmp.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/signal.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdalign.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdarg.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdbool.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stddef.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdint.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdio.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/stdlib.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/string.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/tgmath.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/time.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/uchar.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/wchar.h clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/wctype.h Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/assert.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/assert.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/complex.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/complex.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/ctype.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/ctype.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/errno.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/errno.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/fenv.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/fenv.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/float.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/float.h?rev=261893&view=auto == (empty) Added: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprecated-headers/inttypes.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-deprec
r261887 - Add FieldNames to __NSConstantString_tag
Author: benlangmuir Date: Thu Feb 25 10:36:26 2016 New Revision: 261887 URL: http://llvm.org/viewvc/llvm-project?rev=261887&view=rev Log: Add FieldNames to __NSConstantString_tag Since consumers of the AST may expect fields to be named. Patch by Brad King! Modified: cfe/trunk/lib/AST/ASTContext.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=261887&r1=261886&r2=261887&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Feb 25 10:36:26 2016 @@ -4877,21 +4877,27 @@ TypedefDecl *ASTContext::getCFConstantSt CFConstantStringTagDecl->startDefinition(); QualType FieldTypes[4]; +const char *FieldNames[4]; // const int *isa; FieldTypes[0] = getPointerType(IntTy.withConst()); +FieldNames[0] = "isa"; // int flags; FieldTypes[1] = IntTy; +FieldNames[1] = "flags"; // const char *str; FieldTypes[2] = getPointerType(CharTy.withConst()); +FieldNames[2] = "str"; // long length; FieldTypes[3] = LongTy; +FieldNames[3] = "length"; // Create fields for (unsigned i = 0; i < 4; ++i) { FieldDecl *Field = FieldDecl::Create(*this, CFConstantStringTagDecl, SourceLocation(), - SourceLocation(), nullptr, + SourceLocation(), + &Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr, /*BitWidth=*/nullptr, /*Mutable=*/false, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r244989 - Avoid iteration invalidation issues around MaterializedTemporaryExpr
Seems like this test got flagged as 'slow' by Google's internal infrastructure - and that makes me wonder about whether it's appropriate to have in the lit test suite - we really want to keep these tests as fast as possible. I think we're generally OK committing iterator invalidation fixes without tests in the past, and I'd be inclined to suggest removing this test. It's nice to have the demonstration to justify the commit, but I'm not sure it'll pull its weight as part of the regression suite. (unicorn: what I'd love to see is a checked mode for our containers, so that we could reduce invalidation test cases down to something entirely reasonable and that would fail fast without having to concoct a rehashing event to occur at a particular point) On Thu, Aug 13, 2015 at 4:50 PM, David Majnemer via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: majnemer > Date: Thu Aug 13 18:50:15 2015 > New Revision: 244989 > > URL: http://llvm.org/viewvc/llvm-project?rev=244989&view=rev > Log: > Avoid iteration invalidation issues around MaterializedTemporaryExpr > > We risk iterator invalidation issues if we use a DenseMap to hold the > backing storage for an APValue. Instead, BumpPtrAllocate them and > use APValue * as our DenseMap value. > > Also, don't assume that MaterializedGlobalTemporaryMap won't regrow > between when we initially perform a lookup and later on when we actually > try to insert into it. > > This fixes PR24289. > > Differential Revision: http://reviews.llvm.org/D11629 > > Added: > cfe/trunk/test/CodeGenCXX/PR24289.cpp > Modified: > cfe/trunk/include/clang/AST/ASTContext.h > cfe/trunk/lib/AST/ASTContext.cpp > cfe/trunk/lib/CodeGen/CodeGenModule.cpp > > Modified: cfe/trunk/include/clang/AST/ASTContext.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=244989&r1=244988&r2=244989&view=diff > > == > --- cfe/trunk/include/clang/AST/ASTContext.h (original) > +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Aug 13 18:50:15 2015 > @@ -176,8 +176,9 @@ class ASTContext : public RefCountedBase > ClassScopeSpecializationPattern; > >/// \brief Mapping from materialized temporaries with static storage > duration > - /// that appear in constant initializers to their evaluated values. > - llvm::DenseMap > + /// that appear in constant initializers to their evaluated values. > These are > + /// allocated in a std::map because their address must be stable. > + llvm::DenseMap > MaterializedTemporaryValues; > >/// \brief Representation of a "canonical" template template parameter > that > > Modified: cfe/trunk/lib/AST/ASTContext.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=244989&r1=244988&r2=244989&view=diff > > == > --- cfe/trunk/lib/AST/ASTContext.cpp (original) > +++ cfe/trunk/lib/AST/ASTContext.cpp Thu Aug 13 18:50:15 2015 > @@ -8553,12 +8553,14 @@ ASTContext::getMaterializedTemporaryValu >bool MayCreate) { >assert(E && E->getStorageDuration() == SD_Static && > "don't need to cache the computed value for this temporary"); > - if (MayCreate) > -return &MaterializedTemporaryValues[E]; > + if (MayCreate) { > +APValue *&MTVI = MaterializedTemporaryValues[E]; > +if (!MTVI) > + MTVI = new (*this) APValue; > +return MTVI; > + } > > - llvm::DenseMap::iterator I = > - MaterializedTemporaryValues.find(E); > - return I == MaterializedTemporaryValues.end() ? nullptr : &I->second; > + return MaterializedTemporaryValues.lookup(E); > } > > bool ASTContext::AtomicUsesUnsupportedLibcall(const AtomicExpr *E) const { > > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=244989&r1=244988&r2=244989&view=diff > > == > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Aug 13 18:50:15 2015 > @@ -3029,8 +3029,7 @@ llvm::Constant *CodeGenModule::GetAddrOf >if (Init == E->GetTemporaryExpr()) > MaterializedType = E->getType(); > > - llvm::Constant *&Slot = MaterializedGlobalTemporaryMap[E]; > - if (Slot) > + if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E]) > return Slot; > >// FIXME: If an externally-visible declaration extends multiple > temporaries, > @@ -3101,7 +3100,7 @@ llvm::Constant *CodeGenModule::GetAddrOf > GV->setComdat(TheModule.getOrInsertComdat(GV->getName())); >if (VD->getTLSKind()) > setTLSMode(GV, *VD); > - Slot = GV; > + MaterializedGlobalTemporaryMap[E] = GV; >return GV; > } > > > Added: cfe/trunk/test/CodeGenCXX/PR24289.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/te
Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target
yaxunl accepted this revision. yaxunl added a comment. This revision is now accepted and ready to land. Pls revise by Anastasia's comments. Otherwise LGTM. We have two options about SPIR-V support: 1. drop SPIR support and move on to SPIR-V 2. keep supporting both SPIR and SPIR-V Option 1 is cleaner and easier to maintain, however it will require changes in backends which expect SPIR format for OCL programs. http://reviews.llvm.org/D17596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.
ddkilzer added inline comments. Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:804 @@ +803,3 @@ +/// Returns true if there is a call to -dealloc anywhere on the stack and false +/// otherwise. If true, it also sets \param SelfValOut to the value of +/// 'self' in the frame for -dealloc. ddkilzer wrote: > I think you meant "/param InstanceValOut" here. And I meant "\param InstanceValOut". 😐 http://reviews.llvm.org/D17511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.
ddkilzer added inline comments. Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:804 @@ +803,3 @@ +/// Returns true if there is a call to -dealloc anywhere on the stack and false +/// otherwise. If true, it also sets \param SelfValOut to the value of +/// 'self' in the frame for -dealloc. I think you meant "/param InstanceValOut" here. http://reviews.llvm.org/D17511 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer
Alexander_Droste added inline comments. Comment at: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp:46 @@ +45,3 @@ +ExplodedNode *ErrorNode = Ctx.generateNonFatalErrorNode(State, &Tag); +BReporter->reportDoubleNonblocking(PreCallEvent, *Req, MR, ExplNode); +Ctx.addTransition(ErrorNode->getState(), ErrorNode); This should actually be `reportDoubleNonblocking(..., ErrorNode);` instead of `ExplNode`, right? http://reviews.llvm.org/D12761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target
Anastasia added a comment. I was just wondering with SPIRV coming these days, how long should we be supporting and maintaining previous SPIR versions. Might be worth clarifying that... Comment at: lib/CodeGen/TargetInfo.cpp:7022 @@ -7021,1 +7021,3 @@ +class SPIRTargetCodeGenInfo : public TargetCodeGenInfo { +public: Could we please separate this from XCore code? Add separate anonymous namespace for it and proper heading comment. See XCore above as an example. http://reviews.llvm.org/D17596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
hokein marked 3 inline comments as done. Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:16 @@ +15,3 @@ +// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4 Yeah, exactly. http://reviews.llvm.org/D17335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
hokein updated this revision to Diff 49060. hokein added a comment. Address review comments. http://reviews.llvm.org/D17335 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h test/clang-tidy/Inputs/compilation-database/template.json test/clang-tidy/clang-tidy-run-with-database.cpp Index: test/clang-tidy/clang-tidy-run-with-database.cpp === --- /dev/null +++ test/clang-tidy/clang-tidy-run-with-database.cpp @@ -0,0 +1,24 @@ +// REQUIRES: shell +// RUN: mkdir -p %T/compilation-database-test/include +// RUN: mkdir -p %T/compilation-database-test/a +// RUN: mkdir -p %T/compilation-database-test/b +// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp +// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp +// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp +// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp +// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h +// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp +// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix +// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1 +// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4 +// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5 + +// CHECK-FIX1: int *AA = nullptr; +// CHECK-FIX2: int *AB = nullptr; +// CHECK-FIX3: int *BB = nullptr; +// CHECK-FIX4: int *BC = nullptr; +// CHECK-FIX5: int *HP = nullptr; Index: test/clang-tidy/Inputs/compilation-database/template.json === --- /dev/null +++ test/clang-tidy/Inputs/compilation-database/template.json @@ -0,0 +1,32 @@ +[ +{ + "directory": "test_dir/a", + "command": "clang++ -o test.o test_dir/a/a.cpp", + "file": "test_dir/a/a.cpp" +}, +{ + "directory": "test_dir/a", + "command": "clang++ -o test.o test_dir/a/b.cpp", + "file": "test_dir/a/b.cpp" +}, +{ + "directory": "test_dir/", + "command": "clang++ -o test.o test_dir/b/b.cpp", + "file": "test_dir/b/b.cpp" +}, +{ + "directory": "test_dir/b", + "command": "clang++ -o test.o ../b/c.cpp", + "file": "test_dir/b/c.cpp" +}, +{ + "directory": "test_dir/b", + "command": "clang++ -I../include -o test.o ../b/d.cpp", + "file": "test_dir/b/d.cpp" +}, +{ + "directory": "test_dir/", + "command": "clang++ -o test.o test_dir/b/not-exist.cpp", + "file": "test_dir/b/not-exist.cpp" +} +] Index: clang-tidy/ClangTidyDiagnosticConsumer.h === --- clang-tidy/ClangTidyDiagnosticConsumer.h +++ clang-tidy/ClangTidyDiagnosticConsumer.h @@ -57,13 +57,23 @@ Error = DiagnosticsEngine::Error }; - ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError); + ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, + StringRef BuildDirectory); std::string CheckName; ClangTidyMessage Message; tooling::Replacements Fix; SmallVector Notes; + // A build directory of the diagnostic source file. + // + // It's an absolute path which is `directory` field of the source file in + // compilation database. If users don't specify the compilation database + // directory, it is the current directory where clang-tidy runs. + // + // Note: it is empty in unittest. + std::string BuildDirectory; + Level DiagLevel; bool IsWarningAsError; }; @@ -198,6 +208,16 @@ void setCheckProfileData(ProfileData *Profile); ProfileData *getCheckProfileData() const { return Profile; } + /// \brief Should be called when starting to process new translation unit. + void setCurrentBuildDirectory(StringRef BuildDirectory) { +CurrentBuildDirectory = BuildDirectory; + } + + /// \brief Returns all build directories. + const std::string &getCurrentBuildDirectory() { +return CurrentBuildDirectory; + } + private: // Calls setDiagnosticsEngine() and storeError(). friend class ClangTidyDiagnosticConsumer; @@ -222,6 +242,8 @@ ClangTidyStats Stats; + std::string CurrentBuildDirectory; + llvm::DenseMap CheckNamesByD
[libcxx] r261875 - No, really - test the constructor
Author: marshall Date: Thu Feb 25 09:27:13 2016 New Revision: 261875 URL: http://llvm.org/viewvc/llvm-project?rev=261875&view=rev Log: No, really - test the constructor Modified: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp Modified: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp?rev=261875&r1=261874&r2=261875&view=diff == --- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp Thu Feb 25 09:27:13 2016 @@ -23,5 +23,5 @@ int main() { std::default_delete d1; -std::default_delete d2; +std::default_delete d2 = d1; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r261737 - [clang-tidy] Added a check for forward declaration in the potentially wrong namespace
Yes, I know. Trying to come up with a good solution. On Thu, Feb 25, 2016 at 4:59 AM, Sean Silva wrote: > This or r261737 seem to be causing a bot failure: > http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/636 > > -- Sean Silva > > On Wed, Feb 24, 2016 at 5:35 AM, Alexander Kornienko via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: alexfh >> Date: Wed Feb 24 07:35:32 2016 >> New Revision: 261737 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=261737&view=rev >> Log: >> [clang-tidy] Added a check for forward declaration in the potentially >> wrong namespace >> >> Adds a new check "misc-forward-declaration-namespace". >> In check, A forward declaration is considerred in a potentially wrong >> namespace >> if there is any definition/declaration with the same name exists in a >> different >> namespace. >> >> Reviewers: akuegel, hokein, alexfh >> >> Patch by Eric Liu! >> >> Differential Revision: http://reviews.llvm.org/D17195 >> >> Added: >> >> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >> >> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.h >> >> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forward-declaration-namespace.rst >> >> clang-tools-extra/trunk/test/clang-tidy/misc-forward-declaration-namespace.cpp >> Modified: >> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt >> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp >> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst >> >> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=261737&r1=261736&r2=261737&view=diff >> >> == >> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original) >> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Feb 24 >> 07:35:32 2016 >> @@ -6,6 +6,7 @@ add_clang_library(clangTidyMiscModule >>AssignOperatorSignatureCheck.cpp >>BoolPointerImplicitConversionCheck.cpp >>DefinitionsInHeadersCheck.cpp >> + ForwardDeclarationNamespaceCheck.cpp >>InaccurateEraseCheck.cpp >>IncorrectRoundings.cpp >>InefficientAlgorithmCheck.cpp >> >> Added: >> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=261737&view=auto >> >> == >> --- >> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >> (added) >> +++ >> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp >> Wed Feb 24 07:35:32 2016 >> @@ -0,0 +1,174 @@ >> +//===--- ForwardDeclarationNamespaceCheck.cpp - clang-tidy --*- C++ >> -*-===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> >> +//===--===// >> + >> +#include "ForwardDeclarationNamespaceCheck.h" >> +#include >> +#include >> +#include "clang/AST/ASTContext.h" >> +#include "clang/AST/Decl.h" >> +#include "clang/ASTMatchers/ASTMatchFinder.h" >> +#include "clang/ASTMatchers/ASTMatchers.h" >> + >> +using namespace clang::ast_matchers; >> + >> +namespace clang { >> +namespace tidy { >> +namespace misc { >> + >> +void ForwardDeclarationNamespaceCheck::registerMatchers(MatchFinder >> *Finder) { >> + // Match all class declarations/definitions *EXCEPT* >> + // 1. implicit classes, e.g. `class A {};` has implicit `class A` >> inside `A`. >> + // 2. nested classes declared/defined inside another class. >> + // 3. template class declaration, template instantiation or >> + //specialization (NOTE: extern specialization is filtered out by >> + //`unless(hasAncestor(cxxRecordDecl()))`). >> + auto IsInSpecialization = hasAncestor( >> + decl(anyOf(cxxRecordDecl(isExplicitTemplateSpecialization()), >> + functionDecl(isExplicitTemplateSpecialization(); >> + Finder->addMatcher( >> + cxxRecordDecl( >> + hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(, >> + unless(isImplicit()), unless(hasAncestor(cxxRecordDecl())), >> + unless(isInstantiated()), unless(IsInSpecialization), >> + unless(classTemplateSpecializationDecl())) >> + .bind("record_decl"), >> + this); >> + >> + // Match all friend declarations. Classes used in friend declarations >> are not >> + // marked as referenced in AST. We need to record all record classes >> used in >> + // friend declarations. >> + Finder->addMatcher(friendDecl().bind("friend_decl"), this); >> +} >> + >> +v
Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker
AndyG added inline comments. Comment at: lib/Sema/SemaChecking.cpp:3923-3924 @@ +3922,4 @@ + PartialDiagnostic PDiag = S.PDiag(diag::warn_printf_data_arg_not_used); + for (unsigned i = 1; i < DiagnosticExprs.size(); ++i) +PDiag << DiagnosticExprs[i]->getSourceRange(); + rtrieu wrote: > That raises the question why the first element is different from the rest. I've put this as a range-based for-loop as requested. The reason it wasn't before is that one expression is passed through the call to EmitFormatDiagnostic. Ultimately, I think EmitFormatDiagnostic needs to be reworked to support multiple format strings - and this will probably resolve the FIXME relating to the missing diagnostic note in the tests. http://reviews.llvm.org/D15636 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r261874 - Add test to ensure that the converting constructor in N4089 is present and working
Author: marshall Date: Thu Feb 25 09:25:29 2016 New Revision: 261874 URL: http://llvm.org/viewvc/llvm-project?rev=261874&view=rev Log: Add test to ensure that the converting constructor in N4089 is present and working Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp Added: libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp?rev=261874&view=auto == --- libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp Thu Feb 25 09:25:29 2016 @@ -0,0 +1,27 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// default_delete[] + +// template +// default_delete(const default_delete&); +// +// This constructor shall not participate in overload resolution unless +// U(*)[] is convertible to T(*)[]. + +#include +#include + +int main() +{ +std::default_delete d1; +std::default_delete d2; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
alexfh added inline comments. Comment at: clang-tidy/readability/RedundantStringInitCheck.cpp:26 @@ +25,3 @@ +void RedundantStringInitCheck::registerMatchers( +ast_matchers::MatchFinder *Finder) { + if (!getLangOpts().CPlusPlus) nit: `ast_matchers::` can be omitted. Comment at: clang-tidy/readability/RedundantStringInitCheck.cpp:54 @@ +53,3 @@ +void RedundantStringInitCheck::check( +const ast_matchers::MatchFinder::MatchResult &Result) { + const auto *CtorExpr = Result.Nodes.getNodeAs("expr"); ditto Comment at: test/clang-tidy/readability-redundant-string-init.cpp:1 @@ +1,2 @@ +// RUN: %check_clang_tidy %s readability-redundant-string-init %t + Please add test cases with: * a template with multiple instantiations * macros, something along the lines of: ``` #define M(x) x M({ std::string a = ""; }) #define M2 { std::string b = ""; } M2; M2; ``` http://reviews.llvm.org/D17586 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker
AndyG updated this revision to Diff 49058. AndyG marked 5 inline comments as done. AndyG added a comment. Updated patch according to the comments made. Also spotted a corner-case where a double-diagnostic was produced, for example in the following where one string has too few arguments and the other string too many: printf(minimal ? "%i\n" : "%i %s %s\n", code, msg); Hitherto, this produced two diagnostics: the first (correct) diagnostic that more '%' conversions exist than data arguments, but then a second diagnostic regarding uncovered arguments. The second diagnostic is now suppressed since the format string that has too many does also cover all arguments. http://reviews.llvm.org/D15636 Files: lib/Sema/SemaChecking.cpp test/Sema/format-strings-scanf.c test/Sema/format-strings.c Index: test/Sema/format-strings.c === --- test/Sema/format-strings.c +++ test/Sema/format-strings.c @@ -46,6 +46,9 @@ vscanf(s, ap); // expected-warning {{format string is not a string literal}} + const char *const fmt = "%d"; // FIXME -- defined here + printf(fmt, 1, 2); // expected-warning{{data argument not used}} + // rdar://6079877 printf("abc" "%*d", 1, 1); // no-warning @@ -86,6 +89,20 @@ printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}} printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}} + printf(0 ? "yes %s" : "no %d", 1); // no-warning + printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}} + + printf(0 ? "yes" : "no %d", 1); // no-warning + printf(0 ? "yes %d" : "no", 1); // expected-warning{{data argument not used by format string}} + printf(1 ? "yes" : "no %d", 1); // expected-warning{{data argument not used by format string}} + printf(1 ? "yes %d" : "no", 1); // no-warning + printf(i ? "yes" : "no %d", 1); // no-warning + printf(i ? "yes %s" : "no %d", 1); // expected-warning{{format specifies type 'char *'}} + printf(i ? "yes" : "no %d", 1, 2); // expected-warning{{data argument not used by format string}} + + printf(i ? "%*s" : "-", i, s); // no-warning + printf(i ? "yes" : 0 ? "no %*d" : "dont know %d", 1, 2); // expected-warning{{data argument not used by format string}} + printf(i ? "%i\n" : "%i %s %s\n", i, s); // expected-warning{{more '%' conversions than data arguments}} } void check_writeback_specifier() @@ -519,7 +536,7 @@ // Make sure that the "format string is defined here" note is not emitted // when the original string is within the argument expression. - printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}} + printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}} const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}} printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}} Index: test/Sema/format-strings-scanf.c === --- test/Sema/format-strings-scanf.c +++ test/Sema/format-strings-scanf.c @@ -18,7 +18,7 @@ int vsscanf(const char * restrict, const char * restrict, va_list); void test(const char *s, int *i) { - scanf(s, i); // expected-warning{{ormat string is not a string literal}} + scanf(s, i); // expected-warning{{format string is not a string literal}} scanf("%0d", i); // expected-warning{{zero field width in scanf format string is unused}} scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}} scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}} @@ -171,3 +171,15 @@ scanf("%d", (ip_t)0); // No warning. scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}} } + +void check_conditional_literal(char *s, int *i) { + scanf(0 ? "%s" : "%d", i); // no warning + scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char *'}} + scanf(0 ? "%d %d" : "%d", i); // no warning + scanf(1 ? "%d %d" : "%d", i); // expected-warning{{more '%' conversions than data arguments}} + scanf(0 ? "%d %d" : "%d", i, s); // expected-warning{{data argument not used}} + scanf(1 ? "%d %s" : "%d", i, s); // no warning + scanf(i ? "%d %s" : "%d", i, s); // no warning + scanf(i ? "%d" : "%d", i, s); // expected-warning{{data argument not used}} + scanf(i ? "%s" : "%d", s); // expected-warning{{format specifies type 'int *'}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -3258,6 +3258,51 @@ } namespace { +class UncoveredArgHandl
Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
alexfh added inline comments. Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:2 @@ +1,3 @@ +// REQUIRES: shell +// RUN: mkdir -p %T/compilation-database-test +// RUN: mkdir -p %T/compilation-database-test/include You don't need to create the root directory, since the `mkdir -p` calls below will take care of this. Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:15 @@ +14,3 @@ +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %t.cpp -check-prefix=CHECK-FIX1 I'm not sure how the rest of the test works. This `grep -v` call leaves everything __except__ for the CHECK-lines in the %t.cpp, doesn't it? Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:16 @@ +15,3 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %t.cpp -check-prefix=CHECK-FIX1 +// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %t.cpp -check-prefix=CHECK-FIX2 Why don't you use `%s` here? http://reviews.llvm.org/D17335 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17575: Determine if there's a getDecl member function using less hacks
aaron.ballman closed this revision. aaron.ballman added a comment. Thanks! I've commit in r261872. http://reviews.llvm.org/D17575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r261872 - Replace a compiler-specific approach to determining the presence of a getDecl() member function with one that does not require compiler-specific workarounds; NFC.
Author: aaronballman Date: Thu Feb 25 09:14:09 2016 New Revision: 261872 URL: http://llvm.org/viewvc/llvm-project?rev=261872&view=rev Log: Replace a compiler-specific approach to determining the presence of a getDecl() member function with one that does not require compiler-specific workarounds; NFC. Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=261872&r1=261871&r2=261872&view=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Thu Feb 25 09:14:09 2016 @@ -569,32 +569,21 @@ bool matchesFirstInPointerRange(const Ma return false; } -// Metafunction to determine if type T has a member called -// getDecl. -#if defined(_MSC_VER) && !defined(__clang__) -// For MSVC, we use a weird nonstandard __if_exists statement, as it -// is not standards-conformant enough to properly compile the standard -// code below. (At least up through MSVC 2015 require this workaround) -template struct has_getDecl { - __if_exists(T::getDecl) { -enum { value = 1 }; - } - __if_not_exists(T::getDecl) { -enum { value = 0 }; - } +// Metafunction to determine if type T has a member called getDecl. +template +class has_getDecl { + typedef char yes[1]; + typedef char no[2]; + + template + static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr); + + template + static no& test(...); + +public: + static const bool value = sizeof(test(nullptr)) == sizeof(yes); }; -#else -// There is a default template inheriting from "false_type". Then, a -// partial specialization inherits from "true_type". However, this -// specialization will only exist when the call to getDecl() isn't an -// error -- it vanishes by SFINAE when the member doesn't exist. -template struct type_sink_to_void { typedef void type; }; -template struct has_getDecl : std::false_type {}; -template -struct has_getDecl< -T, typename type_sink_to_void().getDecl())>::type> -: std::true_type {}; -#endif /// \brief Matches overloaded operators with a specific name. /// ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.
logan added inline comments. Comment at: lib/Headers/unwind.h:61 @@ +60,3 @@ +#define _UNWIND_ARM_EHABI 0 +#endif + compnerd wrote: > logan wrote: > > logan wrote: > > > compnerd wrote: > > > > logan wrote: > > > > > compnerd wrote: > > > > > > logan wrote: > > > > > > > Since this is `unwind.h`, I feel that we can get a step further > > > > > > > and use `__ARM_EABI_UNWINDER__` to get more compatibility to > > > > > > > GCC's unwind.h. > > > > > > > > > > > > > > Here's the change: > > > > > > > > > > > > > > ``` > > > > > > > #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ > > > > > > > !defined(__ARM_DWARF_EH__) > > > > > > > #define __ARM_EABI_UNWINDER__ 1 > > > > > > > #endif > > > > > > > ``` > > > > > > I dont know if we really need to imitate GCC's macros here. Am I > > > > > > mistaken in that they assume that `__ARM_EABI_UNWINDER__` has been > > > > > > set to 1 externally if targeting such an environment? I think that > > > > > > it is better to use the reserved namespace and intrude into > > > > > > libunwind's namespace as already done here. > > > > > > Am I mistaken in that they assume that `__ARM_EABI_UNWINDER__` has > > > > > > been set to 1 externally if targeting such an environment? > > > > > > > > > > Although this is an implementation detail, it was defined by > > > > > `unwind.h` in the implementation of GCC. > > > > > > > > > > Remark: `__ARM_EABI_UNWINDER__` is not a pre-defined macro in GCC and > > > > > Clang (can be checked with ` gcc -dM -E - < /dev/null`.) > > > > > > > > > > BTW, some applications or libraries need this macro to be defined > > > > > after including `` (such as uclibc, boost, or libc++abi > > > > > 3.0.) I remembered that someone suggested to use > > > > > `__ARM_EABI_UNWINDER__` instead of `LIBCXXABI_ARM_EHABI` when I was > > > > > fixing libc++abi several years ago. I chose `LIBCXXABI_ARM_EHABI` > > > > > simply because `__ARM_EABI_UNWINDER__` wasn't provided by clang at > > > > > that time. > > > > > > > > > > I am less concerned to namespace pollution, because this is already > > > > > the de facto implementation in GCC world and the macro names start > > > > > with underscores are reserved for compiler or standard libraries by > > > > > convention. > > > > > > > > > > Since this is file a public header and will be used for a long time, > > > > > I personally believe that it will be better to use an existing name > > > > > with the same meaning instead of introducing a new name. In > > > > > addition, this will make it easier to port the application between > > > > > gcc and clang. > > > > I just checked, libc++abi has no use of this macro, nor does boost > > > > 1.60. uclibc only defines `__ARM_EABI_UNWINDER__`, but does not use > > > > it. I also checked glibc and musl, and glibc like uclibc defines it > > > > while musl has no references to it. This is injecting itself into the > > > > compiler namespace and is misleading, so I think I would really rather > > > > prefer the current patch as is. > > > > I just checked, libc++abi has no use of this macro, nor does boost > > > > 1.60. uclibc only defines __ARM_EABI_UNWINDER__, but does not use it. I > > > > also checked glibc and musl, and glibc like uclibc defines it while > > > > musl has no references to it. > > > > > > For uClibc++ and Boost I only did a simple Google search while writing > > > the previous reply. Sorry for the brevity. > > > > > > Although uClibc++ itself does not use `__ARM_EABI_UNWINDER__`, some > > > third-party ARM ports are using this macro. For example, > > > [toyroot](https://github.com/luckboy/toyroot), a small build system for > > > small linux distribution, is maintaining a [local > > > patch](https://github.com/luckboy/toyroot/blob/master/patch/uClibc%2B%2B-0.2.4-arm-eabi-unwinder.patch). > > > Yet another example, [Aboriginal Linux](http://landley.net/aboriginal/) > > > has [another > > > patch](http://www.landley.net/hg/aboriginal/file/tip/sources/patches/uClibc%2B%2B-unwind-cxx.patch) > > > that requires this macro. Someone even sent a > > > [patch](http://lists.uclibc.org/pipermail/uclibc/2012-June/046915.html) > > > to uClibc++ mailing list. > > > > > > For Boost, I am referring to [this > > > thread](http://lists.boost.org/Archives/boost/2008/04/136332.php), > > > although it seems not being committed. > > > > > > For libc++abi, I am referring to the [earlier > > > version](http://llvm.org/klaus/libcxxabi/blob/8b547a338373b6e149d8ceed34bbf6a979a1e10d/src/cxa_exception.hpp) > > > (roughly 3.4.) You won't find `__ARM_EABI_UNWINDER__` in libc++abi > > > master branch because I removed it in > > > [05d51bcf07](http://llvm.org/klaus/libcxxabi/commit/05d51bcf07d0ec1c40785b4a860fd917410b4be1/) > > > when I was implementing the ARM EHABI support. I remembered in the > > > [review > > > comments](http://lists.llvm.org/pipermail/cfe-commits/Week-of-
Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
hokein updated this revision to Diff 49054. hokein added a comment. Simplify test code. http://reviews.llvm.org/D17335 Files: clang-tidy/ClangTidy.cpp clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tidy/ClangTidyDiagnosticConsumer.h test/clang-tidy/Inputs/compilation-database/template.json test/clang-tidy/clang-tidy-run-with-database.cpp Index: test/clang-tidy/clang-tidy-run-with-database.cpp === --- /dev/null +++ test/clang-tidy/clang-tidy-run-with-database.cpp @@ -0,0 +1,26 @@ +// REQUIRES: shell +// RUN: mkdir -p %T/compilation-database-test +// RUN: mkdir -p %T/compilation-database-test/include +// RUN: mkdir -p %T/compilation-database-test/a +// RUN: mkdir -p %T/compilation-database-test/b +// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp +// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp +// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp +// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp +// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h +// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp +// RUN: sed 's|test_dir|%T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* +// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix +// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp +// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %t.cpp -check-prefix=CHECK-FIX1 +// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %t.cpp -check-prefix=CHECK-FIX2 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %t.cpp -check-prefix=CHECK-FIX3 +// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %t.cpp -check-prefix=CHECK-FIX4 +// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %t.cpp -check-prefix=CHECK-FIX5 + +// CHECK-FIX1: int *AA = nullptr; +// CHECK-FIX2: int *AB = nullptr; +// CHECK-FIX3: int *BB = nullptr; +// CHECK-FIX4: int *BC = nullptr; +// CHECK-FIX5: int *HP = nullptr; Index: test/clang-tidy/Inputs/compilation-database/template.json === --- /dev/null +++ test/clang-tidy/Inputs/compilation-database/template.json @@ -0,0 +1,32 @@ +[ +{ + "directory": "test_dir/a", + "command": "clang++ -o test.o test_dir/a/a.cpp", + "file": "test_dir/a/a.cpp" +}, +{ + "directory": "test_dir/a", + "command": "clang++ -o test.o test_dir/a/b.cpp", + "file": "test_dir/a/b.cpp" +}, +{ + "directory": "test_dir/", + "command": "clang++ -o test.o test_dir/b/b.cpp", + "file": "test_dir/b/b.cpp" +}, +{ + "directory": "test_dir/b", + "command": "clang++ -o test.o ../b/c.cpp", + "file": "test_dir/b/c.cpp" +}, +{ + "directory": "test_dir/b", + "command": "clang++ -I../include -o test.o ../b/d.cpp", + "file": "test_dir/b/d.cpp" +}, +{ + "directory": "test_dir/", + "command": "clang++ -o test.o test_dir/b/not-exist.cpp", + "file": "test_dir/b/not-exist.cpp" +} +] Index: clang-tidy/ClangTidyDiagnosticConsumer.h === --- clang-tidy/ClangTidyDiagnosticConsumer.h +++ clang-tidy/ClangTidyDiagnosticConsumer.h @@ -57,13 +57,23 @@ Error = DiagnosticsEngine::Error }; - ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError); + ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError, + StringRef BuildDirectory); std::string CheckName; ClangTidyMessage Message; tooling::Replacements Fix; SmallVector Notes; + // A build directory of the diagnostic source file. + // + // It's an absolute path which is `directory` field of the source file in + // compilation database. If users don't specify the compilation database + // directory, it is the current directory where clang-tidy runs. + // + // Note: it is empty in unittest. + std::string BuildDirectory; + Level DiagLevel; bool IsWarningAsError; }; @@ -198,6 +208,16 @@ void setCheckProfileData(ProfileData *Profile); ProfileData *getCheckProfileData() const { return Profile; } + /// \brief Should be called when starting to process new translation unit. + void setCurrentBuildDirectory(StringRef BuildDirectory) { +CurrentBuildDirectory = BuildDirectory; + } + + /// \brief Returns all build directories. + const std::string &getCurrentBuildDirectory() { +return CurrentBuildDirectory; + } + private: // Calls setDiagnosticsEngine() and storeError(). friend class ClangTidyDiagnosticConsumer; @@ -222,6 +24
Re: [PATCH] D17149: Consolidate and improve the handling of built-in feature-like macros
AndyG added a comment. Second bump :o) http://reviews.llvm.org/D17149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r261868 - [clang-tidy] update links to Google Code Style in docs
Author: hokein Date: Thu Feb 25 08:31:10 2016 New Revision: 261868 URL: http://llvm.org/viewvc/llvm-project?rev=261868&view=rev Log: [clang-tidy] update links to Google Code Style in docs Summary: Because of the recent Google Code shutdown links to the Google Code Style up there are no longer relevant. Reviewers: alexfh, hokein Subscribers: cfe-commits Patch by Kirill Bobyrev! Differential Revision: http://reviews.llvm.org/D17602 Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h?rev=261868&r1=261867&r2=261868&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h (original) +++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h Thu Feb 25 08:31:10 2016 @@ -19,7 +19,7 @@ namespace readability { /// Finds usages of C-style casts. /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting +/// https://google.github.io/styleguide/cppguide.html#Casting /// /// Corresponding cpplint.py check name: 'readability/casting'. /// Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h?rev=261868&r1=261867&r2=261868&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h (original) +++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h Thu Feb 25 08:31:10 2016 @@ -18,7 +18,7 @@ namespace google { /// Checks that all single-argument constructors are explicit. /// -/// See http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors +/// See https://google.github.io/styleguide/cppguide.html#Explicit_Constructors class ExplicitConstructorCheck : public ClangTidyCheck { public: ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context) Modified: clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h?rev=261868&r1=261867&r2=261868&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h (original) +++ clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h Thu Feb 25 08:31:10 2016 @@ -19,7 +19,7 @@ namespace runtime { /// Finds overloads of unary `operator &`. /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Operator_Overloading#Operator_Overloading +/// https://google.github.io/styleguide/cppguide.html#Operator_Overloading /// /// Corresponding cpplint.py check name: 'runtime/operator'. class OverloadedUnaryAndCheck : public ClangTidyCheck { Modified: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h?rev=261868&r1=261867&r2=261868&view=diff == --- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h (original) +++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h Thu Feb 25 08:31:10 2016 @@ -27,7 +27,7 @@ namespace build { /// For extension-less header files, using an empty string or leaving an /// empty string between "," if there are other filename extensions. /// -/// http://google-styleguide.googlecod
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
This revision was automatically updated to reflect the committed changes. Closed by commit rL261868: [clang-tidy] update links to Google Code Style in docs (authored by hokein). Changed prior to commit: http://reviews.llvm.org/D17602?vs=49048&id=49052#toc Repository: rL LLVM http://reviews.llvm.org/D17602 Files: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.h clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h clang-tools-extra/trunk/clang-tidy/google/OverloadedUnaryAndCheck.h clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-namespaces.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-using-namespace.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-explicit-constructor.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-casting.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-readability-namespace-comments.rst clang-tools-extra/trunk/docs/clang-tidy/checks/google-runtime-operator.rst clang-tools-extra/trunk/docs/clang-tidy/checks/llvm-namespace-comment.rst clang-tools-extra/trunk/docs/clang-tidy/checks/readability-named-parameter.rst Index: clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h === --- clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h +++ clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.h @@ -21,7 +21,7 @@ /// /// http://llvm.org/docs/CodingStandards.html#namespace-indentation /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces +/// https://google.github.io/styleguide/cppguide.html#Namespaces class NamespaceCommentCheck : public ClangTidyCheck { public: NamespaceCommentCheck(StringRef Name, ClangTidyContext *Context); Index: clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h === --- clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h +++ clang-tools-extra/trunk/clang-tidy/readability/NamedParameterCheck.h @@ -21,7 +21,7 @@ /// The check implements the following rule originating in the Google C++ Style /// Guide: /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Function_Declarations_and_Definitions#Function_Declarations_and_Definitions +/// https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions /// /// All parameters should be named, with identical names in the declaration and /// implementation. Index: clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h === --- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h +++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h @@ -27,7 +27,7 @@ /// For extension-less header files, using an empty string or leaving an /// empty string between "," if there are other filename extensions. /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namespaces#Namespaces +/// https://google.github.io/styleguide/cppguide.html#Namespaces /// /// Corresponding cpplint.py check name: 'build/namespaces'. class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck { Index: clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h === --- clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h +++ clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.h @@ -19,7 +19,7 @@ /// Finds using namespace directives. /// -/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Namespaces#Namespaces +/// https://google.github.io/styleguide/cppguide.html#Namespaces /// /// The check implements the following rule of the Google C++ Style Guide: /// Index: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h === --- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h +++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.h @@ -18,7 +18,7 @@ /// Checks that all single-argument constructors are explicit. /// -/// See http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Explicit_Constructors +/// See https://google.github.io/styleguide/cppguide.html#Explicit_Constructors class ExplicitConstructorCheck : public ClangTidyCheck { public: ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context) Index: clang
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
omtcyf0 added inline comments. Comment at: docs/clang-tidy/checks/readability-named-parameter.rst:13 @@ -13,2 +12,3 @@ +https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions All parameters should be named, with identical names in the declaration and hokein wrote: > omtcyf0 wrote: > > alexfh wrote: > > > omtcyf0 wrote: > > > > It is rst. I meant generated HTML docs there. > > > > > > > > IIRC rst is similar to markdown there -- the generated output won't > > > > have newline there unless there are 2 spaces at the end of line or a > > > > blank line. > > > One of the good properties of markdown and rst (though rst is worse in > > > this regard) is that these formats are readable and usable as a plain > > > text (unlike HTML, for example). Breaking the link makes the link > > > unusable in the text mode (at least, not with vim in a terminal). > > Okay, won't do that again :) > > IIRC rst is similar to markdown there -- the generated output won't have > > newline there unless there are 2 spaces at the end of line or a blank line. > > Indeed, the generated html will not have a new line, but the link will be > broken. Uh, you're right! Sorry for arguing before, I thought it won't be; thanks for pointing out! http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
hokein added inline comments. Comment at: docs/clang-tidy/checks/readability-named-parameter.rst:13 @@ -13,2 +12,3 @@ +https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions All parameters should be named, with identical names in the declaration and omtcyf0 wrote: > alexfh wrote: > > omtcyf0 wrote: > > > It is rst. I meant generated HTML docs there. > > > > > > IIRC rst is similar to markdown there -- the generated output won't have > > > newline there unless there are 2 spaces at the end of line or a blank > > > line. > > One of the good properties of markdown and rst (though rst is worse in this > > regard) is that these formats are readable and usable as a plain text > > (unlike HTML, for example). Breaking the link makes the link unusable in > > the text mode (at least, not with vim in a terminal). > Okay, won't do that again :) > IIRC rst is similar to markdown there -- the generated output won't have > newline there unless there are 2 spaces at the end of line or a blank line. Indeed, the generated html will not have a new line, but the link will be broken. http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
omtcyf0 added a comment. Thank you very much, @hokein! http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
hokein accepted this revision. hokein added a comment. LGTM. I will commit the patch for you @omtcyf0. http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
omtcyf0 added inline comments. Comment at: docs/clang-tidy/checks/readability-named-parameter.rst:13 @@ -13,2 +12,3 @@ +https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions All parameters should be named, with identical names in the declaration and alexfh wrote: > omtcyf0 wrote: > > It is rst. I meant generated HTML docs there. > > > > IIRC rst is similar to markdown there -- the generated output won't have > > newline there unless there are 2 spaces at the end of line or a blank line. > One of the good properties of markdown and rst (though rst is worse in this > regard) is that these formats are readable and usable as a plain text (unlike > HTML, for example). Breaking the link makes the link unusable in the text > mode (at least, not with vim in a terminal). Okay, won't do that again :) http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17602: [clang-tidy] update links to Google Code Style in docs
alexfh added a comment. Hajian, if you have no concerns, could you commit the patch? Thanks! http://reviews.llvm.org/D17602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits