This revision was automatically updated to reflect the committed changes. Closed by commit rL370200: [clang-tidy] Fix the potential infinite loop in… (authored by hokein, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D66874?vs=217628&id=217629#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66874/new/ https://reviews.llvm.org/D66874 Files: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp +++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp @@ -0,0 +1,7 @@ +// RUN: %check_clang_tidy -expect-clang-tidy-error %s cppcoreguidelines-pro-type-member-init %t + +struct X { + X x; + // CHECK-MESSAGES: :[[@LINE-1]]:5: error: field has incomplete type 'X' [clang-diagnostic-error] + int a = 10; +}; 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 @@ -54,6 +54,10 @@ // Non-C++ records are always trivially constructible. if (!ClassDecl) return true; + // It is impossible to detemine whether an ill-formed decl is trivially + // constructible. + if (RecordDecl.isInvalidDecl()) + return false; // A class with a user-provided default constructor is not trivially // constructible. if (ClassDecl->hasUserProvidedDefaultConstructor())
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp +++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-no-crash.cpp @@ -0,0 +1,7 @@ +// RUN: %check_clang_tidy -expect-clang-tidy-error %s cppcoreguidelines-pro-type-member-init %t + +struct X { + X x; + // CHECK-MESSAGES: :[[@LINE-1]]:5: error: field has incomplete type 'X' [clang-diagnostic-error] + int a = 10; +}; 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 @@ -54,6 +54,10 @@ // Non-C++ records are always trivially constructible. if (!ClassDecl) return true; + // It is impossible to detemine whether an ill-formed decl is trivially + // constructible. + if (RecordDecl.isInvalidDecl()) + return false; // A class with a user-provided default constructor is not trivially // constructible. if (ClassDecl->hasUserProvidedDefaultConstructor())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits