[libcxx] r282352 - Update -verify test to use new static assert message
Author: ericwf Date: Sun Sep 25 03:30:05 2016 New Revision: 282352 URL: http://llvm.org/viewvc/llvm-project?rev=282352&view=rev Log: Update -verify test to use new static assert message Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp Modified: libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp?rev=282352&r1=282351&r2=282352&view=diff == --- libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp (original) +++ libcxx/trunk/test/std/containers/sequences/array/array.tuple/get.fail.cpp Sun Sep 25 03:30:05 2016 @@ -19,7 +19,6 @@ #include #include -#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. @@ -32,10 +31,6 @@ int main() typedef std::array C; C c = {1, 2, 3.5}; std::get<3>(c) = 5.5; // expected-note {{requested here}} -#if TEST_STD_VER >= 11 // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} -#else -// expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test'}} -#endif } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24893: [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions
omtcyfz updated this revision to Diff 72422. omtcyfz marked an inline comment as done. omtcyfz added a comment. Replace `anyOf(hasName("..."), hasName("..."))` with `hasAnyName("...", "...")`. https://reviews.llvm.org/D24893 Files: clang-tidy/readability/RedundantSmartptrGetCheck.cpp test/clang-tidy/readability-redundant-smartptr-get.cpp Index: test/clang-tidy/readability-redundant-smartptr-get.cpp === --- test/clang-tidy/readability-redundant-smartptr-get.cpp +++ test/clang-tidy/readability-redundant-smartptr-get.cpp @@ -113,6 +113,37 @@ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get(); // CHECK-FIXES: i = *PointerWithOverloadedGet(); + + bb = std::unique_ptr().get() == NULL; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call + // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL; + // CHECK-FIXES: bb = std::unique_ptr() == NULL; + bb = ss->get() == NULL; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call + // CHECK-MESSAGES: bb = ss->get() == NULL; + // CHECK-FIXES: bb = *ss == NULL; + + std::unique_ptr x, y; + if (x.get() == nullptr); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call + // CHECK-MESSAGES: if (x.get() == nullptr); + // CHECK-FIXES: if (x == nullptr); + if (nullptr == y.get()); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call + // CHECK-MESSAGES: if (nullptr == y.get()); + // CHECK-FIXES: if (nullptr == y); + if (x.get() == NULL); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call + // CHECK-MESSAGES: if (x.get() == NULL); + // CHECK-FIXES: if (x == NULL); + if (NULL == x.get()); + // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call + // CHECK-MESSAGES: if (NULL == x.get()); + // CHECK-FIXES: if (NULL == x); + if (x.get()); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call + // CHECK-MESSAGES: if (x.get()); + // CHECK-FIXES: if (x); } void Negative() { @@ -137,7 +168,5 @@ (*Fail2().get()).Do(); int_ptr ip; - bool bb = std::unique_ptr().get() == NULL; - bb = ip.get() == nullptr; - bb = u->get() == NULL; + bool bb = ip.get() == nullptr; } Index: clang-tidy/readability/RedundantSmartptrGetCheck.cpp === --- clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -60,21 +60,27 @@ // might be on global namespace or found by ADL, might be a template, etc. // For now, lets keep a list of known standard types. - const auto IsAKnownSmartptr = recordDecl( - anyOf(hasName("::std::unique_ptr"), hasName("::std::shared_ptr"))); + const auto IsAKnownSmartptr = + recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")); // Matches against nullptr. Finder->addMatcher( - binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!=")), - hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())), - hasEitherOperand(callToGet(IsAKnownSmartptr))), + binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(ignoringImpCasts( + anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(), + integerLiteral(equals(0), + hasEitherOperand(callToGet(IsAKnownSmartptr))), + Callback); + + // Matches against if(ptr.get()) + Finder->addMatcher( + ifStmt(hasCondition(ignoringImpCasts(callToGet(IsAKnownSmartptr, Callback); - // TODO: Catch ptr.get() == other_ptr.get() -} + // FIXME: Match and fix if (l.get() == r.get()). +} -} // namespace +} // namespace void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not @@ -102,10 +108,11 @@ Result.Nodes.getNodeAs("getType")->getUnqualifiedDesugaredType(); return OpArrowType == OpStarType && OpArrowType == GetType; } -} // namespace +} // namespace void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { - if (!allReturnTypesMatch(Result)) return; + if (!allReturnTypesMatch(Result)) +return; bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr; bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22968: [analyzer] A checker for macOS-specific bool- and number-like objects.
NoQ marked an inline comment as done. NoQ added a comment. Ouch, seems inline answers don't automatically post themselves when you update the diff :o Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:62 @@ +61,3 @@ + << "' to a plain boolean value: probably a forgotten " + << (IsObjC ? "'[boolValue]'" : "'->isTrue()'"); +BR.EmitBasicReport( dcoughlin wrote: > - The '[boolValue]' thing here is weird. Maybe use '-boolValue' instead? > - How about "Comparison between 'NSNumber *' and 'BOOL'; use -boolValue > instead." > - You probably want to remove lifetime qualifiers from the type with > `.getUnqualifiedType()`. before printing (i.e., don't mention '__strong') in > the diagnostic. > Yeah, noticed the lifetime qualifiers. Changed messages significantly. Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:117 @@ +116,3 @@ +auto ConversionThroughComparisonM = +binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(NSNumberExprM), zaks.anna wrote: > Can we use any binary operator here without any restrictions? Comparisons are handled here. Assignments are handled in a different matcher. Arithmetic operators are either a valid pointer arithmetic (such as `+` or `-`) or cause compile errors (such as `*` or `/`). Bitwise ops (`&`, `>>`, etc.) - perhaps somebody is computing shadow memory. Logical ops - also too commonly intentional (typically: `if (p && [p boolValue])`). Comma operator - ouch, we should probably warn about the very fact that somebody uses comma operators. Comment at: test/Analysis/bool-conversion.cpp:18 @@ +17,3 @@ +#ifdef PEDANTIC + if (p) {} // expected-warning{{}} + if (!p) {} // expected-warning{{}} zaks.anna wrote: > dcoughlin wrote: > > It is generally good to include the diagnostic text in the test for the > > warning. This way we make sure we get the warning we expected. > +1 > > Are these pedantic because we assume these are comparing the pointer and not > the value? Have you checked that this is a common idiom? > > Same comment applies to NSNumber. If it is common practice to compare against > nil.. > > Are these pedantic because we assume these are comparing the pointer and not > the value? Have you checked that this is a common idiom? I haven't checked if this is more popular or less popular than `if (p == nil)`, but it's clearly too popular and too often correct for a warning enabled by default. Comment at: test/Analysis/bool-conversion.cpp:21 @@ +20,3 @@ + p ? 1 : 2; // expected-warning{{}} + (bool)p; // expected-warning{{}} +#endif zaks.anna wrote: > Why is this OK? Will test more closely; i think this gives a lot of intentionals, but a cast to a non-boolean integer is clearly an error that must be reported. Comment at: test/Analysis/bool-conversion.m:10 @@ +9,3 @@ + if (!p) {} // expected-warning{{}} + if (p == YES) {} // expected-warning{{}} + if (p == NO) {} // expected-warning{{}} zaks.anna wrote: > dcoughlin wrote: > > There is a Sema warning for `p == YES` already, right? ("comparison between > > pointer and integer ('NSNumber *' and 'int')") > These tests seem to be even more relevant to OSBoolean. > There is a Sema warning Yep, but it is disabled with `-w`. I think it's a good idea to add `-w` to the run line in all analyzer tests - it often makes tests easier to read, and in particular we're sure that all warnings in the test are coming from the enabled checkers, not from other sources. Comment at: test/Analysis/bool-conversion.m:11 @@ +10,3 @@ + if (p == YES) {} // expected-warning{{}} + if (p == NO) {} // expected-warning{{}} + (!p) ? 1 : 2; // expected-warning{{}} dcoughlin wrote: > Should `p == NO` be on in non-pedantic mode, as well? It also seems to me > that you could warn on comparison of *any* ObjCObjectPointerType type to > `NO`. At a minimum it would probably be good to check for comparisons of `id` > to NO. Whoops, accidental. https://reviews.llvm.org/D22968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15075: No error for conflict between inputs\outputs and clobber list
zizhar added a comment. Hello :) I will prepare another patch as you suggested, is this patch good? Can it be submitted? Ziv https://reviews.llvm.org/D15075 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24791: Use checktime when reloading vim buffer after applying clang-rename
NewProggie added a comment. In https://reviews.llvm.org/D24791#551662, @omtcyfz wrote: > @NewProggie do you have commit access or do you want me to land this patch > for you? I don't have commit access. Please, land it for me. Glad, you've accepted my patch. https://reviews.llvm.org/D24791 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc
mgorny created this revision. mgorny added a reviewer: EricWF. mgorny added a subscriber: cfe-commits. Declare __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS before including real inttypes.h/stdint.h when the wrapper-header is included in C++11, in order to enable the necessary macros in C99-compliant libc. The C99 standard defined that the format macros in inttypes.h should be defined by the C++ implementations only when __STDC_FORMAT_MACROS is defined, and the limit and constant macros in stdint.h should be defined only when __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined appropriately. Following this specification, multiple old versions of glibc up to 2.17 do not define those macros by default for C++, rendering the libc++ headers non-compliant to the C++11 standard. In order to achieve the necessary compliance, __STDC_FORMAT_MACROS is defined in wrapped inttypes.h just before including the system inttypes.h, when C++11 or newer is used. Both __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined in newly-wrapped stdint.h. This fixes the C++11 compliance while preserving the current behavior for C++03. https://reviews.llvm.org/D24903 Files: include/inttypes.h include/stdint.h Index: include/stdint.h === --- /dev/null +++ include/stdint.h @@ -0,0 +1,33 @@ +// -*- C++ -*- +//=== stdint.h ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_STDINT_H +#define _LIBCPP_STDINT_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed + for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS + are defined +*/ +#if __cplusplus >= 201103L && !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +#endif +#if __cplusplus >= 201103L && !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +#endif + +#include_next + +#endif // _LIBCPP_STDINT_H Index: include/inttypes.h === --- include/inttypes.h +++ include/inttypes.h @@ -237,6 +237,13 @@ #pragma GCC system_header #endif +/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed + for C++11 unless __STDC_FORMAT_MACROS is defined +*/ +#if __cplusplus >= 201103L && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +#endif + #include_next #ifdef __cplusplus Index: include/stdint.h === --- /dev/null +++ include/stdint.h @@ -0,0 +1,33 @@ +// -*- C++ -*- +//=== stdint.h ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCPP_STDINT_H +#define _LIBCPP_STDINT_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed + for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS + are defined +*/ +#if __cplusplus >= 201103L && !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS +#endif +#if __cplusplus >= 201103L && !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS +#endif + +#include_next + +#endif // _LIBCPP_STDINT_H Index: include/inttypes.h === --- include/inttypes.h +++ include/inttypes.h @@ -237,6 +237,13 @@ #pragma GCC system_header #endif +/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed + for C++11 unless __STDC_FORMAT_MACROS is defined +*/ +#if __cplusplus >= 201103L && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +#endif + #include_next #ifdef __cplusplus ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc
EricWF added reviewers: mclow.lists, rsmith. EricWF added subscribers: mclow.lists, rsmith. EricWF added a comment. Adding reviewers @mclow.lists and @rsmith since he originally wrote the C wrappers. https://reviews.llvm.org/D24903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc
rmaprath added a subscriber: rmaprath. rmaprath added a comment. When the `` headers where split into `` and `` headers in https://reviews.llvm.org/D12747, we have left out `` and ``. I was going to put up a patch to fix this but couldn't get to it. It's good that you are adding ``, perhaps you can follow what was done in https://reviews.llvm.org/D12747 and repeat the same for ``? You will also need a test for the new header, https://reviews.llvm.org/D12747 has examples. Hope this helps! / Asiri https://reviews.llvm.org/D24903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc
EricWF added inline comments. Comment at: include/stdint.h:24 @@ +23,3 @@ +*/ +#if __cplusplus >= 201103L && !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS Please take a look at how `clang/lib/Headers/stdint.h` handles forwarding this header, and use a solution similar to that. Comment at: include/stdint.h:27 @@ +26,3 @@ +#endif +#if __cplusplus >= 201103L && !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS I think we should define `__STDC_LIMIT_MACROS` and `__STDC_CONSTANT_MACROS` even if we are in C++03, since we don't provide strict C++03 conformance. However we should still check if `__cplusplus` is defined. https://reviews.llvm.org/D24903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282371 - [AMDGPU] Expose flat work group size, register and wave control attributes
Author: kzhuravl Date: Sun Sep 25 20:02:57 2016 New Revision: 282371 URL: http://llvm.org/viewvc/llvm-project?rev=282371&view=rev Log: [AMDGPU] Expose flat work group size, register and wave control attributes __attribute__((amdgpu_flat_work_group_size(, ))) - request minimum and maximum flat work group size __attribute__((amdgpu_waves_per_eu([, ]))) - request minimum and/or maximum waves per execution unit Differential Revision: https://reviews.llvm.org/D24513 Added: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl cfe/trunk/test/SemaCUDA/amdgpu-attrs.cu cfe/trunk/test/SemaOpenCL/amdgpu-attrs.cl Removed: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl cfe/trunk/test/SemaCUDA/amdgpu-num-gpr-attr.cu cfe/trunk/test/SemaOpenCL/amdgpu-num-register-attrs.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/TargetInfo.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=282371&r1=282370&r2=282371&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Sun Sep 25 20:02:57 2016 @@ -1050,24 +1050,37 @@ def NoMips16 : InheritableAttr, TargetSp // // FIXME: This provides a sub-optimal error message if you attempt to // use this in CUDA, since CUDA does not use the same terminology. -def AMDGPUNumVGPR : InheritableAttr { - let Spellings = [GNU<"amdgpu_num_vgpr">]; - let Args = [UnsignedArgument<"NumVGPR">]; - let Documentation = [AMDGPUNumVGPRDocs]; - -// FIXME: This should be for OpenCLKernelFunction, but is not to +// +// FIXME: SubjectList should be for OpenCLKernelFunction, but is not to // workaround needing to see kernel attribute before others to know if // this should be rejected on non-kernels. - let Subjects = SubjectList<[Function], ErrorDiag, - "ExpectedKernelFunction">; + +def AMDGPUFlatWorkGroupSize : InheritableAttr { + let Spellings = [GNU<"amdgpu_flat_work_group_size">]; + let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">]; + let Documentation = [AMDGPUFlatWorkGroupSizeDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; +} + +def AMDGPUWavesPerEU : InheritableAttr { + let Spellings = [GNU<"amdgpu_waves_per_eu">]; + let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>]; + let Documentation = [AMDGPUWavesPerEUDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; } def AMDGPUNumSGPR : InheritableAttr { let Spellings = [GNU<"amdgpu_num_sgpr">]; let Args = [UnsignedArgument<"NumSGPR">]; - let Documentation = [AMDGPUNumSGPRDocs]; - let Subjects = SubjectList<[Function], ErrorDiag, - "ExpectedKernelFunction">; + let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; +} + +def AMDGPUNumVGPR : InheritableAttr { + let Spellings = [GNU<"amdgpu_num_vgpr">]; + let Args = [UnsignedArgument<"NumVGPR">]; + let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; } def NoSplitStack : InheritableAttr { Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=282371&r1=282370&r2=282371&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Sun Sep 25 20:02:57 2016 @@ -889,12 +889,12 @@ variable, a function or method, a functi enumerator, a non-static data member, or a label. .. code-block: c++ - #include - - [[maybe_unused]] void f([[maybe_unused]] bool thing1, - [[maybe_unused]] bool thing2) { -[[maybe_unused]] bool b = thing1 && thing2; -assert(b); + #include + + [[maybe_unused]] void f([[maybe_unused]] bool thing1, + [[maybe_unused]] bool thing2) { +[[maybe_unused]] bool b = thing1 && thing2; +assert(b); } }]; } @@ -911,15 +911,15 @@ potentially-evaluated discarded-value ex `void`. .. code-block: c++ - struct [[nodiscard]] error_info { /*...*/ }; - error_info enable_missile_safety_mode(); - - void launch_missiles(); - void test_missiles() { -enable_missile_safety_mode(); // diagnoses -launch_missiles(); - } - error_info &foo(); + struct [[nodiscard]] error_info { /*...*/ }; + error_info enable_missile_safety_mode(); + + void launch_missiles(); + void test_missiles() { +enable_missile_safety_mode(); // diagnoses +launch_missiles(); + } + error_info &foo();
Re: [PATCH] D24513: [AMDGPU] Expose flat work group size, register and wave control attributes
This revision was automatically updated to reflect the committed changes. Closed by commit rL282371: [AMDGPU] Expose flat work group size, register and wave control attributes (authored by kzhuravl). Changed prior to commit: https://reviews.llvm.org/D24513?vs=71970&id=72436#toc Repository: rL LLVM https://reviews.llvm.org/D24513 Files: 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/TargetInfo.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl cfe/trunk/test/SemaCUDA/amdgpu-attrs.cu cfe/trunk/test/SemaCUDA/amdgpu-num-gpr-attr.cu cfe/trunk/test/SemaOpenCL/amdgpu-attrs.cl cfe/trunk/test/SemaOpenCL/amdgpu-num-register-attrs.cl Index: cfe/trunk/include/clang/Basic/Attr.td === --- cfe/trunk/include/clang/Basic/Attr.td +++ cfe/trunk/include/clang/Basic/Attr.td @@ -1050,24 +1050,37 @@ // // FIXME: This provides a sub-optimal error message if you attempt to // use this in CUDA, since CUDA does not use the same terminology. -def AMDGPUNumVGPR : InheritableAttr { - let Spellings = [GNU<"amdgpu_num_vgpr">]; - let Args = [UnsignedArgument<"NumVGPR">]; - let Documentation = [AMDGPUNumVGPRDocs]; - -// FIXME: This should be for OpenCLKernelFunction, but is not to +// +// FIXME: SubjectList should be for OpenCLKernelFunction, but is not to // workaround needing to see kernel attribute before others to know if // this should be rejected on non-kernels. - let Subjects = SubjectList<[Function], ErrorDiag, - "ExpectedKernelFunction">; + +def AMDGPUFlatWorkGroupSize : InheritableAttr { + let Spellings = [GNU<"amdgpu_flat_work_group_size">]; + let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">]; + let Documentation = [AMDGPUFlatWorkGroupSizeDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; +} + +def AMDGPUWavesPerEU : InheritableAttr { + let Spellings = [GNU<"amdgpu_waves_per_eu">]; + let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>]; + let Documentation = [AMDGPUWavesPerEUDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; } def AMDGPUNumSGPR : InheritableAttr { let Spellings = [GNU<"amdgpu_num_sgpr">]; let Args = [UnsignedArgument<"NumSGPR">]; - let Documentation = [AMDGPUNumSGPRDocs]; - let Subjects = SubjectList<[Function], ErrorDiag, - "ExpectedKernelFunction">; + let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; +} + +def AMDGPUNumVGPR : InheritableAttr { + let Spellings = [GNU<"amdgpu_num_vgpr">]; + let Args = [UnsignedArgument<"NumVGPR">]; + let Documentation = [AMDGPUNumSGPRNumVGPRDocs]; + let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">; } def NoSplitStack : InheritableAttr { Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -2382,6 +2382,9 @@ "'%0' parameter must have pointer%select{| to unqualified pointer}1 type; " "type here is %2">; +def err_attribute_argument_invalid : Error< + "%0 attribute argument is invalid: %select{max must be 0 since min is 0|" + "min must not be greater than max}1">; def err_attribute_argument_is_zero : Error< "%0 attribute must be greater than 0">; def warn_attribute_argument_n_negative : Warning< Index: cfe/trunk/include/clang/Basic/AttrDocs.td === --- cfe/trunk/include/clang/Basic/AttrDocs.td +++ cfe/trunk/include/clang/Basic/AttrDocs.td @@ -889,12 +889,12 @@ enumerator, a non-static data member, or a label. .. code-block: c++ - #include - - [[maybe_unused]] void f([[maybe_unused]] bool thing1, - [[maybe_unused]] bool thing2) { -[[maybe_unused]] bool b = thing1 && thing2; -assert(b); + #include + + [[maybe_unused]] void f([[maybe_unused]] bool thing1, + [[maybe_unused]] bool thing2) { +[[maybe_unused]] bool b = thing1 && thing2; +assert(b); } }]; } @@ -911,15 +911,15 @@ `void`. .. code-block: c++ - struct [[nodiscard]] error_info { /*...*/ }; - error_info enable_missile_safety_mode(); - - void launch_missiles(); - void test_missiles() { -enable_missile_safety_mode(); // diagnoses -launch_missiles(); - } - error_info &foo(); + struct [[nodiscard]] error_info { /*...*/ }; + error_info enable_missile_safety_mode(); + + void launch_missiles(); + void test_missiles() { +enable_missile_safety_mode(); // diagnoses +launch_missiles(); +
Re: [PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType
klimek added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2119 @@ +2118,3 @@ + "template \n" + "void Function(Namespace::Template param) {\n" + " param.Method();\n" Given your use case: why do we need hasDeclaration here at all? I'd have expected this working with just matching on the nested name specifier of the type instead of saying hasDeclaration on the template type. Btw, if you add a type alias for a class not in the namespace into the namespace (typedef / using), do you wan that to rename or not? :) I'd personally probably have expected (2), but I'm never sure in these cases without playing around with more test cases... https://reviews.llvm.org/D24361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24893: [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions
alexfh added a comment. Still LG. https://reviews.llvm.org/D24893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282379 - Driver: avoid failing in the backend
Author: compnerd Date: Sun Sep 25 23:48:22 2016 New Revision: 282379 URL: http://llvm.org/viewvc/llvm-project?rev=282379&view=rev Log: Driver: avoid failing in the backend Avoid failing in the backend when the rewrite map does not exist. Rather check that the map exists in the frontend before handing it off to the backend. Add the missing rewrite maps that the tests were referencing. Added: cfe/trunk/test/Driver/Inputs/rewrite-1.map cfe/trunk/test/Driver/Inputs/rewrite-2.map cfe/trunk/test/Driver/Inputs/rewrite.map cfe/trunk/test/Driver/rewrite-map-files.c Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=282379&r1=282378&r2=282379&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Sun Sep 25 23:48:22 2016 @@ -4213,9 +4213,14 @@ void Clang::ConstructJob(Compilation &C, Args.hasArg(options::OPT_frewrite_map_file_EQ)) { for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file, options::OPT_frewrite_map_file_EQ)) { - CmdArgs.push_back("-frewrite-map-file"); - CmdArgs.push_back(A->getValue()); - A->claim(); + StringRef Map = A->getValue(); + if (!llvm::sys::fs::exists(Map)) { +D.Diag(diag::err_drv_no_such_file) << Map; + } else { +CmdArgs.push_back("-frewrite-map-file"); +CmdArgs.push_back(A->getValue()); +A->claim(); + } } } Added: cfe/trunk/test/Driver/Inputs/rewrite-1.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite-1.map?rev=282379&view=auto == (empty) Added: cfe/trunk/test/Driver/Inputs/rewrite-2.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite-2.map?rev=282379&view=auto == (empty) Added: cfe/trunk/test/Driver/Inputs/rewrite.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/rewrite.map?rev=282379&view=auto == (empty) Added: cfe/trunk/test/Driver/rewrite-map-files.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/rewrite-map-files.c?rev=282379&view=auto == --- cfe/trunk/test/Driver/rewrite-map-files.c (added) +++ cfe/trunk/test/Driver/rewrite-map-files.c Sun Sep 25 23:48:22 2016 @@ -0,0 +1,2 @@ +// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s +// CHECK: error: no such file or directory: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24893: [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions
omtcyfz added a comment. In https://reviews.llvm.org/D24893#551914, @alexfh wrote: > Still LG. Thank you! Landing the patch. https://reviews.llvm.org/D24893 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r282382 - [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions
Author: omtcyfz Date: Mon Sep 26 01:22:54 2016 New Revision: 282382 URL: http://llvm.org/viewvc/llvm-project?rev=282382&view=rev Log: [clang-tidy] make readability-redundant-smartptr-get report get() usage in conditions This patch extends clang-tidy's readability-redundant-smartptr-get to produce warnings for previously unsupported cases: ``` std::unique_ptr ptr; if (ptr.get()) if (ptr.get() == NULL) if (ptr.get() != NULL) ``` This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=25804, a bug report opened by @Eugene.Zelenko. However, there still are cases not detected by the check. They can be found in `void Negative()` function defined in test/clang-tidy/readability-redundant-smartptr-get.cpp. Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=282382&r1=282381&r2=282382&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp Mon Sep 26 01:22:54 2016 @@ -60,21 +60,27 @@ void registerMatchersForGetEquals(MatchF // might be on global namespace or found by ADL, might be a template, etc. // For now, lets keep a list of known standard types. - const auto IsAKnownSmartptr = recordDecl( - anyOf(hasName("::std::unique_ptr"), hasName("::std::shared_ptr"))); + const auto IsAKnownSmartptr = + recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")); // Matches against nullptr. Finder->addMatcher( - binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!=")), - hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())), - hasEitherOperand(callToGet(IsAKnownSmartptr))), + binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(ignoringImpCasts( + anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(), + integerLiteral(equals(0), + hasEitherOperand(callToGet(IsAKnownSmartptr))), + Callback); + + // Matches against if(ptr.get()) + Finder->addMatcher( + ifStmt(hasCondition(ignoringImpCasts(callToGet(IsAKnownSmartptr, Callback); - // TODO: Catch ptr.get() == other_ptr.get() -} + // FIXME: Match and fix if (l.get() == r.get()). +} -} // namespace +} // namespace void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not @@ -102,10 +108,11 @@ bool allReturnTypesMatch(const MatchFind Result.Nodes.getNodeAs("getType")->getUnqualifiedDesugaredType(); return OpArrowType == OpStarType && OpArrowType == GetType; } -} // namespace +} // namespace void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { - if (!allReturnTypesMatch(Result)) return; + if (!allReturnTypesMatch(Result)) +return; bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr; bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr; Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=282382&r1=282381&r2=282382&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Mon Sep 26 01:22:54 2016 @@ -113,6 +113,37 @@ void Positive() { // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get(); // CHECK-FIXES: i = *PointerWithOverloadedGet(); + + bb = std::unique_ptr().get() == NULL; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call + // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL; + // CHECK-FIXES: bb = std::unique_ptr() == NULL; + bb = ss->get() == NULL; + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call + // CHECK-MESSAGES: bb = ss->get() == NULL; + // CHECK-FIXES: bb = *ss == NULL; + + std::unique_ptr x, y; + if (x.get() == nullptr); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call + // CHECK-MESSAGES: if (x.get() == nullptr); + // CHECK-FIXES: if (x == nullptr); + if (nullptr == y.get()); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call + // CHECK-MESSAGES: if (nullptr == y.get()); + /
[clang-tools-extra] r282384 - Revert r282382; it had no reference to Revision.
Author: omtcyfz Date: Mon Sep 26 01:33:58 2016 New Revision: 282384 URL: http://llvm.org/viewvc/llvm-project?rev=282384&view=rev Log: Revert r282382; it had no reference to Revision. Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=282384&r1=282383&r2=282384&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp Mon Sep 26 01:33:58 2016 @@ -60,27 +60,21 @@ void registerMatchersForGetEquals(MatchF // might be on global namespace or found by ADL, might be a template, etc. // For now, lets keep a list of known standard types. - const auto IsAKnownSmartptr = - recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr")); + const auto IsAKnownSmartptr = recordDecl( + anyOf(hasName("::std::unique_ptr"), hasName("::std::shared_ptr"))); // Matches against nullptr. Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), - hasEitherOperand(ignoringImpCasts( - anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(), - integerLiteral(equals(0), - hasEitherOperand(callToGet(IsAKnownSmartptr))), + binaryOperator( + anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(ignoringImpCasts(cxxNullPtrLiteralExpr())), + hasEitherOperand(callToGet(IsAKnownSmartptr))), Callback); - - // Matches against if(ptr.get()) - Finder->addMatcher( - ifStmt(hasCondition(ignoringImpCasts(callToGet(IsAKnownSmartptr, - Callback); - - // FIXME: Match and fix if (l.get() == r.get()). + // TODO: Catch ptr.get() == other_ptr.get() } -} // namespace + +} // namespace void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++; the functionality currently does not @@ -108,11 +102,10 @@ bool allReturnTypesMatch(const MatchFind Result.Nodes.getNodeAs("getType")->getUnqualifiedDesugaredType(); return OpArrowType == OpStarType && OpArrowType == GetType; } -} // namespace +} // namespace void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) { - if (!allReturnTypesMatch(Result)) -return; + if (!allReturnTypesMatch(Result)) return; bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr; bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr; Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=282384&r1=282383&r2=282384&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Mon Sep 26 01:33:58 2016 @@ -113,37 +113,6 @@ void Positive() { // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call // CHECK-MESSAGES: i = *PointerWithOverloadedGet().get(); // CHECK-FIXES: i = *PointerWithOverloadedGet(); - - bb = std::unique_ptr().get() == NULL; - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call - // CHECK-MESSAGES: bb = std::unique_ptr().get() == NULL; - // CHECK-FIXES: bb = std::unique_ptr() == NULL; - bb = ss->get() == NULL; - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call - // CHECK-MESSAGES: bb = ss->get() == NULL; - // CHECK-FIXES: bb = *ss == NULL; - - std::unique_ptr x, y; - if (x.get() == nullptr); - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call - // CHECK-MESSAGES: if (x.get() == nullptr); - // CHECK-FIXES: if (x == nullptr); - if (nullptr == y.get()); - // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: redundant get() call - // CHECK-MESSAGES: if (nullptr == y.get()); - // CHECK-FIXES: if (nullptr == y); - if (x.get() == NULL); - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call - // CHECK-MESSAGES: if (x.get() == NULL); - // CHECK-FIXES: if (x == NULL); - if (NULL == x.get()); - // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: redundant get() call - // CHECK-MESSAGES: if (NULL == x.get()); - // CHECK-FIXES: if (NULL == x); - if (x.get()); - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant get() call - // CHECK-MESSAGES: if (x.get()); - // CHECK-FIXES: if (x); } voi
Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc
mgorny added a comment. In https://reviews.llvm.org/D24903#551890, @rmaprath wrote: > When the `` headers where split into `` and `` headers in > https://reviews.llvm.org/D12747, we have left out `` and ``. > I was going to put up a patch to fix this but couldn't get to it. It's good > that you are adding ``, perhaps you can follow what was done in > https://reviews.llvm.org/D12747 and repeat the same for ``? I'm sorry but could you be a little more specific, please? I've looked into that diff, and it seems that the cstdint resembles e.g. cinttypes already -- i.e. there's only the include, and 'using' lines there. Or do you mean that I should copy/update the synopsis over to stdint.h? https://reviews.llvm.org/D24903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits