r269556 - MSVCToolChain.cpp: Use explicit constructor for SmallString from std::string, to appease mingw-g++.
Author: chapuni Date: Sat May 14 03:09:12 2016 New Revision: 269556 URL: http://llvm.org/viewvc/llvm-project?rev=269556&view=rev Log: MSVCToolChain.cpp: Use explicit constructor for SmallString from std::string, to appease mingw-g++. Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=269556&r1=269555&r2=269556&view=diff == --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original) +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Sat May 14 03:09:12 2016 @@ -466,7 +466,7 @@ VersionTuple MSVCToolChain::getMSVCVersi std::string BinPath; if (!getVisualStudioBinariesFolder("", BinPath)) return Version; - SmallString<128> ClExe = BinPath; + SmallString<128> ClExe(BinPath); llvm::sys::path::append(ClExe, "cl.exe"); std::wstring ClExeWide; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269557 - MSVCToolChain.cpp: Make version.dll generic for win32.
Author: chapuni Date: Sat May 14 03:12:37 2016 New Revision: 269557 URL: http://llvm.org/viewvc/llvm-project?rev=269557&view=rev Log: MSVCToolChain.cpp: Make version.dll generic for win32. We may consider msvc features may be capable on mingw host, if it can. Consider --host=mingw --target=msvc. Modified: cfe/trunk/lib/Driver/CMakeLists.txt cfe/trunk/lib/Driver/MSVCToolChain.cpp Modified: cfe/trunk/lib/Driver/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=269557&r1=269556&r2=269557&view=diff == --- cfe/trunk/lib/Driver/CMakeLists.txt (original) +++ cfe/trunk/lib/Driver/CMakeLists.txt Sat May 14 03:12:37 2016 @@ -3,6 +3,11 @@ set(LLVM_LINK_COMPONENTS Support ) +if(WIN32) + # MSVCToolChain.cpp uses version.dll. + set(system_libs version) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp @@ -26,4 +31,5 @@ add_clang_library(clangDriver LINK_LIBS clangBasic + ${system_libs} ) Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=269557&r1=269556&r2=269557&view=diff == --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original) +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Sat May 14 03:12:37 2016 @@ -38,8 +38,6 @@ #define NOMINMAX #endif #include - - #pragma comment(lib, "version.lib") #endif using namespace clang::driver; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269559 - ModuleMap.h: Fix a \param. [-Wdocumentation]
Author: chapuni Date: Sat May 14 07:37:06 2016 New Revision: 269559 URL: http://llvm.org/viewvc/llvm-project?rev=269559&view=rev Log: ModuleMap.h: Fix a \param. [-Wdocumentation] Modified: cfe/trunk/include/clang/Lex/ModuleMap.h Modified: cfe/trunk/include/clang/Lex/ModuleMap.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=269559&r1=269558&r2=269559&view=diff == --- cfe/trunk/include/clang/Lex/ModuleMap.h (original) +++ cfe/trunk/include/clang/Lex/ModuleMap.h Sat May 14 07:37:06 2016 @@ -59,7 +59,7 @@ public: /// \brief Called when an umbrella header is added during module map parsing. /// /// \param FileMgr FileManager instance - /// \param Filename The umbreall header to collect. + /// \param Header The umbreall header to collect. virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr, const FileEntry *Header) {} }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269560 - [mips] Enable IAS by default for 32-bit MIPS targets (O32).
Author: dsanders Date: Sat May 14 07:43:08 2016 New Revision: 269560 URL: http://llvm.org/viewvc/llvm-project?rev=269560&view=rev Log: [mips] Enable IAS by default for 32-bit MIPS targets (O32). Summary: The MIPS IAS can now pass 'ninja check-all', recurse, build a bootable linux kernel, and pass a variety of LNT testing. Unfortunately we can't enable it by default for 64-bit targets yet since the N32 ABI is still very buggy and this also means we can't enable it for N64 either because we can't distinguish between N32 and N64 in the relevant code. Reviewers: vkalintiris Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18759 Differential Revision: http://reviews.llvm.org/D18761 Modified: cfe/trunk/lib/Driver/ToolChains.cpp Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=269560&r1=269559&r2=269560&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Sat May 14 07:43:08 2016 @@ -2444,6 +2444,8 @@ bool Generic_GCC::IsIntegratedAssemblerD case llvm::Triple::ppc64: case llvm::Triple::ppc64le: case llvm::Triple::systemz: + case llvm::Triple::mips: + case llvm::Triple::mipsel: return true; default: return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r269559 - ModuleMap.h: Fix a \param. [-Wdocumentation]
> On 14 May 2016, at 14:37, NAKAMURA Takumi via cfe-commits > wrote: > > - /// \param Filename The umbreall header to collect. > + /// \param Header The umbreall header to collect. s/Umbreall/Umbrella/ signature.asc Description: Message signed with OpenPGP using GPGMail ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269570 - [AVX512] Immediate for permd builtins should be an ICE.
Author: ctopper Date: Sat May 14 10:27:13 2016 New Revision: 269570 URL: http://llvm.org/viewvc/llvm-project?rev=269570&view=rev Log: [AVX512] Immediate for permd builtins should be an ICE. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269570&r1=269569&r2=269570&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat May 14 10:27:13 2016 @@ -2173,10 +2173,10 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddss3_ TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_maskz, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask3, "V2dV2dV2dV2dUcIi", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_permdf512_mask, "V8dV8dUcV8dUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_permdi512_mask, "V8LLiV8LLiUcV8LLiUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_permdf256_mask, "V4dV4dUcV4dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_permdi256_mask, "V4LLiV4LLiUcV4LLiUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_permdf512_mask, "V8dV8dIcV8dUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_permdi512_mask, "V8LLiV8LLiIcV8LLiUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_permdf256_mask, "V4dV4dIcV4dUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_permdi256_mask, "V4LLiV4LLiIcV4LLiUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_permvarhi512_mask, "V32sV32sV32sV32sUi","","avx512bw") TARGET_BUILTIN(__builtin_ia32_permvardf512_mask, "V8dV8dV8LLiV8dUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_permvardi512_mask, "V8LLiV8LLiV8LLiV8LLiUc","","avx512f") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269572 - Warn when a reference is bound to an empty l-value (dereferenced null pointer).
Author: nicholas Date: Sat May 14 12:44:14 2016 New Revision: 269572 URL: http://llvm.org/viewvc/llvm-project?rev=269572&view=rev Log: Warn when a reference is bound to an empty l-value (dereferenced null pointer). Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp cfe/trunk/test/Parser/cxx-casting.cpp cfe/trunk/test/SemaCXX/cstyle-cast.cpp cfe/trunk/test/SemaCXX/functional-cast.cpp cfe/trunk/test/SemaCXX/new-delete.cpp cfe/trunk/test/SemaCXX/static-cast.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=269572&r1=269571&r2=269572&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat May 14 12:44:14 2016 @@ -5371,7 +5371,11 @@ def ext_typecheck_indirection_through_vo "ISO C++ does not allow indirection on operand of type %0">, InGroup>; def warn_indirection_through_null : Warning< - "indirection of non-volatile null pointer will be deleted, not trap">, InGroup; + "indirection of non-volatile null pointer will be deleted, not trap">, + InGroup; +def warn_binding_null_to_reference : Warning< + "binding dereferenced null pointer to reference has undefined behavior">, + InGroup; def note_indirection_through_null : Note< "consider using __builtin_trap() or qualifying pointer with 'volatile'">; def warn_pointer_indirection_from_incompatible_type : Warning< Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=269572&r1=269571&r2=269572&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Sat May 14 12:44:14 2016 @@ -6168,6 +6168,20 @@ static void CheckMoveOnConstruction(Sema << FixItHint::CreateRemoval(SourceRange(RParen, RParen)); } +static void CheckForNullPointerDereference(Sema &S, const Expr *E) { + // Check to see if we are dereferencing a null pointer. If so, this is + // undefined behavior, so warn about it. This only handles the pattern + // "*null", which is a very syntactic check. + if (const UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts())) +if (UO->getOpcode() == UO_Deref && +UO->getSubExpr()->IgnoreParenCasts()-> +isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)) { +S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO, + S.PDiag(diag::warn_binding_null_to_reference) +<< UO->getSubExpr()->getSourceRange()); + } +} + ExprResult InitializationSequence::Perform(Sema &S, const InitializedEntity &Entity, @@ -6420,6 +6434,7 @@ InitializationSequence::Perform(Sema &S, /*IsInitializerList=*/false, ExtendingEntity->getDecl()); + CheckForNullPointerDereference(S, CurInit.get()); break; case SK_BindReferenceToTemporary: { Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp?rev=269572&r1=269571&r2=269572&view=diff == --- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp (original) +++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp Sat May 14 12:44:14 2016 @@ -11,7 +11,7 @@ void test_attributes() { template struct bogus_override_if_virtual : public T { - bogus_override_if_virtual() : T(*(T*)0) { } + bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding dereferenced null pointer to reference has undefined behavior}} int operator()() const; }; @@ -36,7 +36,7 @@ void test_quals() { lv(); // expected-error{{no matching function for call to object of type}} mlv(); // expected-error{{no matching function for call to object of type}} - bogus_override_if_virtual bogus; + bogus_override_if_virtual bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}} } // Core issue 974: default arguments (8.3.6) may be specified in the Modified: cfe/trunk/test/Parser/cxx-casting.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-casting.cpp?rev=269572&r1=269571&r2=269572&view=diff == --- cfe/trunk/test/Parser/cxx-casting.cpp (original) +++ cfe/trunk/test/Parser/cxx-casting.cpp Sat May 14 12:44:14 2016 @@ -37,7 +37,7 @@ char postfix_expr_test() // This was being incorrectly tentatively parsed. namesp
Re: [PATCH] D19851: Warn on binding reference to null in copy initialization
nicholas closed this revision. nicholas added a comment. Closed by r269572. http://reviews.llvm.org/D19851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20053: [clang-tidy] Add misc-unnecessary-mutable check.
aaron.ballman added inline comments. Comment at: test/clang-tidy/misc-unnecessary-mutable.cpp:237 @@ +236,3 @@ + +// Fails for now. +/* It would be good to put further information in about why this fails. http://reviews.llvm.org/D20053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r269575 - Revert r269546 "Added support to the ASTImporter for C++ constructor initializers." as it breaks TestDataFormatterSynthVal.DataFormatterSynthValueTestCase.test_with_run_command_dwarf test -
Author: ovyalov Date: Sat May 14 14:07:13 2016 New Revision: 269575 URL: http://llvm.org/viewvc/llvm-project?rev=269575&view=rev Log: Revert r269546 "Added support to the ASTImporter for C++ constructor initializers." as it breaks TestDataFormatterSynthVal.DataFormatterSynthValueTestCase.test_with_run_command_dwarf test - http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/14699 Removed: cfe/trunk/test/ASTMerge/Inputs/init-ctors-classes.cpp cfe/trunk/test/ASTMerge/init-ctors.cpp Modified: cfe/trunk/include/clang/AST/ASTImporter.h cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/include/clang/AST/ASTImporter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTImporter.h?rev=269575&r1=269574&r2=269575&view=diff == --- cfe/trunk/include/clang/AST/ASTImporter.h (original) +++ cfe/trunk/include/clang/AST/ASTImporter.h Sat May 14 14:07:13 2016 @@ -23,7 +23,6 @@ namespace clang { class ASTContext; - class CXXCtorInitializer; class Decl; class DeclContext; class DiagnosticsEngine; @@ -205,14 +204,6 @@ namespace clang { /// \returns the equivalent file ID in the source manager of the "to" /// context. FileID Import(FileID); - -/// \brief Import the given C++ constructor initializer from the "from" -/// context into the "to" context. -/// -/// \returns the equivalent initializer in the "to" context. -CXXCtorInitializer *Import(CXXCtorInitializer *FromInit); - - /// \brief Import the definition of the given declaration, including all of /// the declarations it contains. Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=269575&r1=269574&r2=269575&view=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Sat May 14 14:07:13 2016 @@ -3029,22 +3029,6 @@ Decl *ASTNodeImporter::VisitFunctionDecl D->isInlineSpecified(), D->isImplicit(), D->isConstexpr()); -if (unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) { - SmallVector CtorInitializers; - for (CXXCtorInitializer *I : FromConstructor->inits()) { -CXXCtorInitializer *ToI = -cast_or_null(Importer.Import(I)); -if (!ToI && I) - return nullptr; -CtorInitializers.push_back(ToI); - } - CXXCtorInitializer **Memory = - new (Importer.getToContext()) CXXCtorInitializer *[NumInitializers]; - std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory); - CXXConstructorDecl *ToCtor = llvm::cast(ToFunction); - ToCtor->setCtorInitializers(Memory); - ToCtor->setNumCtorInitializers(NumInitializers); -} } else if (isa(D)) { ToFunction = CXXDestructorDecl::Create(Importer.getToContext(), cast(DC), @@ -6376,72 +6360,6 @@ FileID ASTImporter::Import(FileID FromID return ToID; } -CXXCtorInitializer *ASTImporter::Import(CXXCtorInitializer *From) { - Expr *ToExpr = Import(From->getInit()); - if (!ToExpr && From->getInit()) -return nullptr; - - if (From->isBaseInitializer()) { -TypeSourceInfo *ToTInfo = Import(From->getTypeSourceInfo()); -if (!ToTInfo && From->getTypeSourceInfo()) - return nullptr; - -return new (ToContext) CXXCtorInitializer( -ToContext, ToTInfo, From->isBaseVirtual(), Import(From->getLParenLoc()), -ToExpr, Import(From->getRParenLoc()), -From->isPackExpansion() ? Import(From->getEllipsisLoc()) -: SourceLocation()); - } else if (From->isMemberInitializer()) { -FieldDecl *ToField = -llvm::cast_or_null(Import(From->getMember())); -if (!ToField && From->getMember()) - return nullptr; - -return new (ToContext) CXXCtorInitializer( -ToContext, ToField, Import(From->getMemberLocation()), -Import(From->getLParenLoc()), ToExpr, Import(From->getRParenLoc())); - } else if (From->isIndirectMemberInitializer()) { -IndirectFieldDecl *ToIField = llvm::cast_or_null( -Import(From->getIndirectMember())); -if (!ToIField && From->getIndirectMember()) - return nullptr; - -return new (ToContext) CXXCtorInitializer( -ToContext, ToIField, Import(From->getMemberLocation()), -Import(From->getLParenLoc()), ToExpr, Import(From->getRParenLoc())); - } else if (From->isDelegatingInitializer()) { -TypeSourceInfo *ToTInfo = Import(From->getTypeSourceInfo()); -if (!ToTInfo && From->getTypeSourceInfo()) - return nullptr; - -return new (ToContext) -CXXCtorInitializer(ToContext, ToTInfo, Import(From->getLParenL
r269580 - [AVX512] Make the permd builtins take a 32-bit immediate to match the software spec.
Author: ctopper Date: Sat May 14 16:13:31 2016 New Revision: 269580 URL: http://llvm.org/viewvc/llvm-project?rev=269580&view=rev Log: [AVX512] Make the permd builtins take a 32-bit immediate to match the software spec. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=269580&r1=269579&r2=269580&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat May 14 16:13:31 2016 @@ -2173,10 +2173,10 @@ TARGET_BUILTIN(__builtin_ia32_vfmaddss3_ TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_maskz, "V2dV2dV2dV2dUcIi", "", "avx512f") TARGET_BUILTIN(__builtin_ia32_vfmaddsd3_mask3, "V2dV2dV2dV2dUcIi", "", "avx512f") -TARGET_BUILTIN(__builtin_ia32_permdf512_mask, "V8dV8dIcV8dUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_permdi512_mask, "V8LLiV8LLiIcV8LLiUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_permdf256_mask, "V4dV4dIcV4dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_permdi256_mask, "V4LLiV4LLiIcV4LLiUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_permdf512_mask, "V8dV8dIiV8dUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_permdi512_mask, "V8LLiV8LLiIiV8LLiUc","","avx512f") +TARGET_BUILTIN(__builtin_ia32_permdf256_mask, "V4dV4dIiV4dUc","","avx512vl") +TARGET_BUILTIN(__builtin_ia32_permdi256_mask, "V4LLiV4LLiIiV4LLiUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_permvarhi512_mask, "V32sV32sV32sV32sUi","","avx512bw") TARGET_BUILTIN(__builtin_ia32_permvardf512_mask, "V8dV8dV8LLiV8dUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_permvardi512_mask, "V8LLiV8LLiV8LLiV8LLiUc","","avx512f") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20170: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
flx updated this revision to Diff 57286. flx marked 3 inline comments as done. http://reviews.llvm.org/D20170 Files: clang-tidy/utils/TypeTraits.cpp clang-tidy/utils/TypeTraits.h test/clang-tidy/performance-unnecessary-value-param.cpp Index: test/clang-tidy/performance-unnecessary-value-param.cpp === --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -23,6 +23,13 @@ SomewhatTrivial& operator=(const SomewhatTrivial&); }; +struct MoveOnlyType { + MoveOnlyType(const MoveOnlyType &) = delete; + MoveOnlyType(MoveOnlyType &&) = default; + ~MoveOnlyType(); + void constMethod() const; +}; + void positiveExpensiveConstValue(const ExpensiveToCopyType Obj); // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj); void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) { @@ -169,3 +176,7 @@ NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; // CHECK-FIXES: NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; }; + +void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) { + M.constMethod(); +} Index: clang-tidy/utils/TypeTraits.h === --- clang-tidy/utils/TypeTraits.h +++ clang-tidy/utils/TypeTraits.h @@ -19,7 +19,8 @@ namespace type_traits { // \brief Returns true If \c Type is expensive to copy. -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context); +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context); // \brief Returns true If \c Type is trivially default constructible. bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context); Index: clang-tidy/utils/TypeTraits.cpp === --- clang-tidy/utils/TypeTraits.cpp +++ clang-tidy/utils/TypeTraits.cpp @@ -10,26 +10,42 @@ #include "TypeTraits.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" namespace clang { namespace tidy { namespace utils { namespace type_traits { namespace { + bool classHasTrivialCopyAndDestroy(QualType Type) { auto *Record = Type->getAsCXXRecordDecl(); return Record && Record->hasDefinition() && !Record->hasNonTrivialCopyConstructor() && !Record->hasNonTrivialDestructor(); } + +bool hasDeletedCopyConstructor(QualType Type) { + auto *Record = Type->getAsCXXRecordDecl(); + if (!Record || !Record->hasDefinition()) +return false; + for (const auto *Constructor : Record->ctors()) { +if (Constructor->isCopyConstructor() && Constructor->isDeleted()) + return true; + } + return false; +} + } // namespace -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context) { +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context) { if (Type->isDependentType()) return llvm::None; return !Type.isTriviallyCopyableType(Context) && - !classHasTrivialCopyAndDestroy(Type); + !classHasTrivialCopyAndDestroy(Type) && + !hasDeletedCopyConstructor(Type); } bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, Index: test/clang-tidy/performance-unnecessary-value-param.cpp === --- test/clang-tidy/performance-unnecessary-value-param.cpp +++ test/clang-tidy/performance-unnecessary-value-param.cpp @@ -23,6 +23,13 @@ SomewhatTrivial& operator=(const SomewhatTrivial&); }; +struct MoveOnlyType { + MoveOnlyType(const MoveOnlyType &) = delete; + MoveOnlyType(MoveOnlyType &&) = default; + ~MoveOnlyType(); + void constMethod() const; +}; + void positiveExpensiveConstValue(const ExpensiveToCopyType Obj); // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj); void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) { @@ -169,3 +176,7 @@ NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; // CHECK-FIXES: NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; }; + +void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) { + M.constMethod(); +} Index: clang-tidy/utils/TypeTraits.h === --- clang-tidy/utils/TypeTraits.h +++ clang-tidy/utils/TypeTraits.h @@ -19,7 +19,8 @@ namespace type_traits { // \brief Returns true If \c Type is expensive to copy. -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context); +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context); // \brief Returns true If \c Type is trivially default constructible. bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context);
Re: [PATCH] D20170: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
flx added inline comments. Comment at: clang-tidy/utils/TypeTraits.cpp:42 @@ -27,3 +41,3 @@ llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context) { if (Type->isDependentType()) etienneb wrote: > You're right too. > But, it's possible to fix these prototypes: > http://reviews.llvm.org/D20226 Updated to const reference now that your patch is in. http://reviews.llvm.org/D20170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20170: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
This revision was automatically updated to reflect the committed changes. Closed by commit rL269581: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted… (authored by flx). Changed prior to commit: http://reviews.llvm.org/D20170?vs=57286&id=57287#toc Repository: rL LLVM http://reviews.llvm.org/D20170 Files: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Index: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp === --- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp +++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp @@ -10,26 +10,42 @@ #include "TypeTraits.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" namespace clang { namespace tidy { namespace utils { namespace type_traits { namespace { + bool classHasTrivialCopyAndDestroy(QualType Type) { auto *Record = Type->getAsCXXRecordDecl(); return Record && Record->hasDefinition() && !Record->hasNonTrivialCopyConstructor() && !Record->hasNonTrivialDestructor(); } + +bool hasDeletedCopyConstructor(QualType Type) { + auto *Record = Type->getAsCXXRecordDecl(); + if (!Record || !Record->hasDefinition()) +return false; + for (const auto *Constructor : Record->ctors()) { +if (Constructor->isCopyConstructor() && Constructor->isDeleted()) + return true; + } + return false; +} + } // namespace -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context) { +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context) { if (Type->isDependentType()) return llvm::None; return !Type.isTriviallyCopyableType(Context) && - !classHasTrivialCopyAndDestroy(Type); + !classHasTrivialCopyAndDestroy(Type) && + !hasDeletedCopyConstructor(Type); } bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, Index: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h === --- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h +++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h @@ -19,7 +19,8 @@ namespace type_traits { // \brief Returns true If \c Type is expensive to copy. -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context); +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context); // \brief Returns true If \c Type is trivially default constructible. bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context); Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp === --- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp +++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp @@ -23,6 +23,13 @@ SomewhatTrivial& operator=(const SomewhatTrivial&); }; +struct MoveOnlyType { + MoveOnlyType(const MoveOnlyType &) = delete; + MoveOnlyType(MoveOnlyType &&) = default; + ~MoveOnlyType(); + void constMethod() const; +}; + void positiveExpensiveConstValue(const ExpensiveToCopyType Obj); // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj); void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) { @@ -169,3 +176,7 @@ NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; // CHECK-FIXES: NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; }; + +void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) { + M.constMethod(); +} Index: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp === --- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp +++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp @@ -10,26 +10,42 @@ #include "TypeTraits.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" namespace clang { namespace tidy { namespace utils { namespace type_traits { namespace { + bool classHasTrivialCopyAndDestroy(QualType Type) { auto *Record = Type->getAsCXXRecordDecl(); return Record && Record->hasDefinition() && !Record->hasNonTrivialCopyConstructor() && !Record->hasNonTrivialDestructor(); } + +bool hasDeletedCopyConstructor(QualType Type) { + auto *Record = Type->getAsCXXRecordDecl(); + if (!Record || !Record->hasDefinition()) +return false; + for (const auto *Constructor : Record->ctors()) { +if (Constructor->isCopyConstructor() && Constructor->isDeleted()) + return true; + } + return fals
[clang-tools-extra] r269581 - [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
Author: flx Date: Sat May 14 17:43:50 2016 New Revision: 269581 URL: http://llvm.org/viewvc/llvm-project?rev=269581&view=rev Log: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor. Reviewers: alexfh, sbenza Subscribers: etienneb, aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D20170 Modified: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Modified: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp?rev=269581&r1=269580&r2=269581&view=diff == --- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp Sat May 14 17:43:50 2016 @@ -10,6 +10,7 @@ #include "TypeTraits.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" namespace clang { namespace tidy { @@ -17,19 +18,34 @@ namespace utils { namespace type_traits { namespace { + bool classHasTrivialCopyAndDestroy(QualType Type) { auto *Record = Type->getAsCXXRecordDecl(); return Record && Record->hasDefinition() && !Record->hasNonTrivialCopyConstructor() && !Record->hasNonTrivialDestructor(); } + +bool hasDeletedCopyConstructor(QualType Type) { + auto *Record = Type->getAsCXXRecordDecl(); + if (!Record || !Record->hasDefinition()) +return false; + for (const auto *Constructor : Record->ctors()) { +if (Constructor->isCopyConstructor() && Constructor->isDeleted()) + return true; + } + return false; +} + } // namespace -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context) { +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context) { if (Type->isDependentType()) return llvm::None; return !Type.isTriviallyCopyableType(Context) && - !classHasTrivialCopyAndDestroy(Type); + !classHasTrivialCopyAndDestroy(Type) && + !hasDeletedCopyConstructor(Type); } bool recordIsTriviallyDefaultConstructible(const RecordDecl &RecordDecl, Modified: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h?rev=269581&r1=269580&r2=269581&view=diff == --- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h (original) +++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h Sat May 14 17:43:50 2016 @@ -19,7 +19,8 @@ namespace utils { namespace type_traits { // \brief Returns true If \c Type is expensive to copy. -llvm::Optional isExpensiveToCopy(QualType Type, ASTContext &Context); +llvm::Optional isExpensiveToCopy(QualType Type, + const ASTContext &Context); // \brief Returns true If \c Type is trivially default constructible. bool isTriviallyDefaultConstructible(QualType Type, const ASTContext &Context); Modified: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=269581&r1=269580&r2=269581&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Sat May 14 17:43:50 2016 @@ -23,6 +23,13 @@ class SomewhatTrivial { SomewhatTrivial& operator=(const SomewhatTrivial&); }; +struct MoveOnlyType { + MoveOnlyType(const MoveOnlyType &) = delete; + MoveOnlyType(MoveOnlyType &&) = default; + ~MoveOnlyType(); + void constMethod() const; +}; + void positiveExpensiveConstValue(const ExpensiveToCopyType Obj); // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj); void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) { @@ -169,3 +176,7 @@ struct NegativeDeletedMethod { NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; // CHECK-FIXES: NegativeDeletedMethod& operator=(NegativeDeletedMethod N) = delete; }; + +void NegativeMoveOnlyTypePassedByValue(MoveOnlyType M) { + M.constMethod(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r269585 - Disable LIBCXX_ENABLE_ABI_LINKER_SCRIPT for static library builds.
Author: asiri Date: Sat May 14 18:58:11 2016 New Revision: 269585 URL: http://llvm.org/viewvc/llvm-project?rev=269585&view=rev Log: Disable LIBCXX_ENABLE_ABI_LINKER_SCRIPT for static library builds. This option is geared towards shared library builds and causes static library builds to fail if not explicitly disabled. This patch fixes PR27706: https://llvm.org/bugs/show_bug.cgi?id=27706 Thanks rgood...@isi.edu for the catch. Modified: libcxx/trunk/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=269585&r1=269584&r2=269585&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Sat May 14 18:58:11 2016 @@ -96,7 +96,8 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" - AND PYTHONINTERP_FOUND) + AND PYTHONINTERP_FOUND + AND LIBCXX_ENABLE_SHARED) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) endif() @@ -203,6 +204,9 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) if (NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.") endif() +if (NOT LIBCXX_ENABLE_SHARED) + message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") +endif() endif() if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:37 @@ +36,3 @@ +bool UseNoexceptCheck::checkHelper(const MatchFinder::MatchResult &Result, + const SourceRange &Range, + CharSourceRange &FileMoveRange, > Happy to rename it, but not sure making it more convenient serves much of a > purpose. Well, the initial problem was that the `check` method was too long and complicated. I suggested to make it easier to read by pulling a part of it in a separate method. I pointed to a part that seemed like something worth extracting to a method, and you mechanically created a method with unclear responsibilities, an awkward interface (two output parameters, a bool return value and a class data member) and a name that doesn't help understanding what the method does. That doesn't make the code any better. Let's try once again. We need to pull out an abstraction (at least one, but maybe you see more) that will make sense on its own and will have a reasonable interface. It could be `SourceRange findDynamicExceptionSpecification(ArrayRef Tokens)`, for example. Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:121 @@ +120,3 @@ +FileMoveRange.getEnd()), + Replacement); +} I think, the problem is in the way you assign MoveRange in the checkHelper method. It is created as a character range and then you just assign its begin and end location. Instead, try `MoveRange = CharSourceRange::getTokenRange(I->getLocation(), Loc)`. Comment at: clang-tidy/modernize/UseNoexceptCheck.h:44-45 @@ +43,4 @@ + unsigned &Len); + const std::string ReplacementStr; + StringRef Replacement; +}; hintonda wrote: > aaron.ballman wrote: > > What is the difference between these two fields? The names are kind of > > confusing to me given their similarity, so perhaps renaming one to be more > > descriptive would be useful. > The first is the option passed in, i.e., the replacement string we will use > (either noexcept or a user macro like libcxx's _NOEXCEPT) for throw() and the > second one is the string we'll actually use for a particular replacement, > which can be what the user supplied, or noexcept(false) when the function can > throw. > > This was originally done with an auto in check(), but Alex wanted me to add a > helper function to make check() easier to understand. So, I had to put it > somewhere. I actually prefer the simpler original version. > > I'll see if I can come up with better names, but suggestions are always > welcome. The `StringRef Replacement;` should not be a member, since it's just one of the results of the `checkHelper` method. http://reviews.llvm.org/D18575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20196: [clang-tidy] Inefficient string operation
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. The last diff has nothing but a 2-line change in the docs. http://reviews.llvm.org/D20196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications
hintonda added a comment. I agree -- things got messy. I'm in the process of completely refactoring the whole thing -- including the ast matchers that I'll checkin later today. Thanks for your patience. http://reviews.llvm.org/D18575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20052: Add new ASTMatcher that matches dynamic exception specifications.
hintonda updated this revision to Diff 57290. hintonda added a comment. - Added new isThrow matcher to complement isNoThrow, and changed hadDynamicExceptionSpec to take a parameter, e.g., isThrow() or isNoThrow(). http://reviews.llvm.org/D20052 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/Dynamic/Registry.cpp unittests/ASTMatchers/ASTMatchersTest.cpp Index: unittests/ASTMatchers/ASTMatchersTest.cpp === --- unittests/ASTMatchers/ASTMatchersTest.cpp +++ unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1891,6 +1891,15 @@ functionDecl(hasName("Func"), isDeleted(; } +TEST(IsThrow, MatchesThrowFunctionDeclarations) { + EXPECT_TRUE(matches("void f();", functionDecl(isThrow(; + EXPECT_TRUE(matches("void f() throw(int);", functionDecl(isThrow(; + EXPECT_TRUE( + matches("void f() noexcept(false);", functionDecl(isThrow(; + EXPECT_TRUE(notMatches("void f() throw();", functionDecl(isThrow(; + EXPECT_TRUE(notMatches("void f() noexcept;", functionDecl(isThrow(; +} + TEST(IsNoThrow, MatchesNoThrowFunctionDeclarations) { EXPECT_TRUE(notMatches("void f();", functionDecl(isNoThrow(; EXPECT_TRUE(notMatches("void f() throw(int);", functionDecl(isNoThrow(; @@ -3552,6 +3561,38 @@ pointsTo(TypeMatcher(anything())); } +TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) { + EXPECT_TRUE(notMatches("void f();", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void f();", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + EXPECT_TRUE(notMatches("void g() noexcept;", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void g() noexcept;", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + EXPECT_TRUE(notMatches("void h() noexcept(true);", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void h() noexcept(true);", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + EXPECT_TRUE(notMatches("void i() noexcept(false);", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void i() noexcept(false);", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + + EXPECT_TRUE(notMatches("void j() throw();", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(matches("void j() throw();", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + EXPECT_TRUE(matches("void k() throw(int);", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void k() throw(int);", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); + EXPECT_TRUE(matches("void l() throw(...);", + functionDecl(hasDynamicExceptionSpec(isThrow(); + EXPECT_TRUE(notMatches("void l() throw(...);", + functionDecl(hasDynamicExceptionSpec(isNoThrow(); +} + TEST(HasImplicitDestinationType, MatchesSimpleCase) { // This test creates an implicit const cast. EXPECT_TRUE(matches("int x; const int i = x;", Index: lib/ASTMatchers/Dynamic/Registry.cpp === --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -218,6 +218,7 @@ REGISTER_MATCHER(hasDeducedType); REGISTER_MATCHER(hasDescendant); REGISTER_MATCHER(hasDestinationType); + REGISTER_MATCHER(hasDynamicExceptionSpec); REGISTER_MATCHER(hasEitherOperand); REGISTER_MATCHER(hasElementType); REGISTER_MATCHER(hasElse); @@ -308,6 +309,7 @@ REGISTER_MATCHER(isMoveAssignmentOperator); REGISTER_MATCHER(isMoveConstructor); REGISTER_MATCHER(isNoThrow); + REGISTER_MATCHER(isThrow); REGISTER_MATCHER(isOverride); REGISTER_MATCHER(isPrivate); REGISTER_MATCHER(isProtected); Index: include/clang/ASTMatchers/ASTMatchers.h === --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -3212,6 +3212,48 @@ return Node.isDefaulted(); } +/// \brief Matches functions that have a dynamic exception specification. +/// +/// Given: +/// \code +/// void f(); +/// void g() noexcept; +/// void h() noexcept(true); +/// void i() noexcept(false); +/// void j() throw(); +/// void k() throw(int); +/// void l() throw(...); +/// \endcode +/// functionDecl(hasDynamicExceptionSpec(isThrow())) +/// matches the declarations of k and l, but not f, g, h, i, or j. +/// functionDecl(hasDynamicExceptionSpec(isNoThrow())) +/// only matches the declaration of j. +AST_M