Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added a comment. Can someone commit this for me? https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r277918 - Move helpers into anonymous namespaces. NFC.
Author: d0k Date: Sat Aug 6 06:21:04 2016 New Revision: 277918 URL: http://llvm.org/viewvc/llvm-project?rev=277918&view=rev Log: Move helpers into anonymous namespaces. NFC. Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=277918&r1=277917&r2=277918&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Aug 6 06:21:04 2016 @@ -1467,7 +1467,7 @@ static void ParseHeaderSearchArgs(Header Opts.AddVFSOverlayFile(A->getValue()); } -bool isOpenCL(LangStandard::Kind LangStd) { +static bool isOpenCL(LangStandard::Kind LangStd) { return LangStd == LangStandard::lang_opencl || LangStd == LangStandard::lang_opencl11 || LangStd == LangStandard::lang_opencl12 || Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=277918&r1=277917&r2=277918&view=diff == --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat Aug 6 06:21:04 2016 @@ -8607,6 +8607,7 @@ bool Sema::IsInsideALocalClassWithinATem return false; } +namespace { /// \brief Walk the path from which a declaration was instantiated, and check /// that every explicit specialization along that path is visible. This enforces /// C++ [temp.expl.spec]/6: @@ -8734,6 +8735,7 @@ private: } } }; +} // end anonymous namespace void Sema::checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec) { if (!getLangOpts().Modules) Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=277918&r1=277917&r2=277918&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sat Aug 6 06:21:04 2016 @@ -436,8 +436,9 @@ public: }; } // end anonymous namespace -template -llvm::iterator_range> merged_redecls(DeclT *D) { +template +static llvm::iterator_range> +merged_redecls(DeclT *D) { return llvm::make_range(MergedRedeclIterator(D), MergedRedeclIterator()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r277917 - [StaticAnalyzer] Remove dead code.
Author: d0k Date: Sat Aug 6 06:20:59 2016 New Revision: 277917 URL: http://llvm.org/viewvc/llvm-project?rev=277917&view=rev Log: [StaticAnalyzer] Remove dead code. Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=277917&r1=277916&r2=277917&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Sat Aug 6 06:20:59 2016 @@ -1277,15 +1277,9 @@ public: private: template - RegionTy* getRegion(const A1 a1); - - template RegionTy* getSubRegion(const A1 a1, const MemRegion* superRegion); template - RegionTy* getRegion(const A1 a1, const A2 a2); - - template RegionTy* getSubRegion(const A1 a1, const A2 a2, const MemRegion* superRegion); Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=277917&r1=277916&r2=277917&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Sat Aug 6 06:20:59 2016 @@ -31,28 +31,6 @@ using namespace ento; // MemRegion Construction. //===--===// -template struct MemRegionManagerTrait; - -template -RegionTy* MemRegionManager::getRegion(const A1 a1) { - const typename MemRegionManagerTrait::SuperRegionTy *superRegion = - MemRegionManagerTrait::getSuperRegion(*this, a1); - - llvm::FoldingSetNodeID ID; - RegionTy::ProfileRegion(ID, a1, superRegion); - void *InsertPos; - RegionTy* R = cast_or_null(Regions.FindNodeOrInsertPos(ID, - InsertPos)); - - if (!R) { -R = A.Allocate(); -new (R) RegionTy(a1, superRegion); -Regions.InsertNode(R, InsertPos); - } - - return R; -} - template RegionTy* MemRegionManager::getSubRegion(const A1 a1, const MemRegion *superRegion) { @@ -68,26 +46,6 @@ RegionTy* MemRegionManager::getSubRegion Regions.InsertNode(R, InsertPos); } - return R; -} - -template -RegionTy* MemRegionManager::getRegion(const A1 a1, const A2 a2) { - const typename MemRegionManagerTrait::SuperRegionTy *superRegion = - MemRegionManagerTrait::getSuperRegion(*this, a1, a2); - - llvm::FoldingSetNodeID ID; - RegionTy::ProfileRegion(ID, a1, a2, superRegion); - void *InsertPos; - RegionTy* R = cast_or_null(Regions.FindNodeOrInsertPos(ID, - InsertPos)); - - if (!R) { -R = A.Allocate(); -new (R) RegionTy(a1, a2, superRegion); -Regions.InsertNode(R, InsertPos); - } - return R; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r277920 - [Sema] Make switch fully covered again.
Author: d0k Date: Sat Aug 6 06:28:20 2016 New Revision: 277920 URL: http://llvm.org/viewvc/llvm-project?rev=277920&view=rev Log: [Sema] Make switch fully covered again. Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=277920&r1=277919&r2=277920&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Aug 6 06:28:20 2016 @@ -136,7 +136,7 @@ AvailabilityResult Sema::ShouldDiagnoseA } switch (Result) { - default: + case AR_Available: return Result; case AR_Unavailable: @@ -167,6 +167,7 @@ AvailabilityResult Sema::ShouldDiagnoseA return Warn ? AR_NotYetIntroduced : AR_Available; } } + llvm_unreachable("Unknown availability result!"); } static void ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r277923 - [ASTReader] Use real move semantics instead of emulating them in the copy ctor.
Author: d0k Date: Sat Aug 6 07:45:16 2016 New Revision: 277923 URL: http://llvm.org/viewvc/llvm-project?rev=277923&view=rev Log: [ASTReader] Use real move semantics instead of emulating them in the copy ctor. No functionality change intended. Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=277923&r1=277922&r2=277923&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Sat Aug 6 07:45:16 2016 @@ -170,12 +170,12 @@ namespace clang { ASTReader &Reader; NamedDecl *New; NamedDecl *Existing; - mutable bool AddResult; + bool AddResult; unsigned AnonymousDeclNumber; IdentifierInfo *TypedefNameForLinkage; - void operator=(FindExistingResult&) = delete; + void operator=(FindExistingResult &&) = delete; public: FindExistingResult(ASTReader &Reader) @@ -189,7 +189,7 @@ namespace clang { AnonymousDeclNumber(AnonymousDeclNumber), TypedefNameForLinkage(TypedefNameForLinkage) {} - FindExistingResult(const FindExistingResult &Other) + FindExistingResult(FindExistingResult &&Other) : Reader(Other.Reader), New(Other.New), Existing(Other.Existing), AddResult(Other.AddResult), AnonymousDeclNumber(Other.AnonymousDeclNumber), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23228: Do not depend on unwind when building standalone
phosek created this revision. phosek added a subscriber: cfe-commits. When libcxxabi is being built standalone, unwind dependency is not available, so do not use it even when LLVM unwinder is being requested. https://reviews.llvm.org/D23228 Files: test/CMakeLists.txt Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -36,10 +36,9 @@ if (NOT LIBCXXABI_BUILT_STANDALONE) list(APPEND LIBCXXABI_TEST_DEPS cxx) -endif() - -if (LIBCXXABI_USE_LLVM_UNWINDER) - list(APPEND LIBCXXABI_TEST_DEPS unwind) + if (LIBCXXABI_USE_LLVM_UNWINDER) +list(APPEND LIBCXXABI_TEST_DEPS unwind) + endif() endif() add_lit_testsuite(check-libcxxabi "Running libcxxabi tests" Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -36,10 +36,9 @@ if (NOT LIBCXXABI_BUILT_STANDALONE) list(APPEND LIBCXXABI_TEST_DEPS cxx) -endif() - -if (LIBCXXABI_USE_LLVM_UNWINDER) - list(APPEND LIBCXXABI_TEST_DEPS unwind) + if (LIBCXXABI_USE_LLVM_UNWINDER) +list(APPEND LIBCXXABI_TEST_DEPS unwind) + endif() endif() add_lit_testsuite(check-libcxxabi "Running libcxxabi tests" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r277928 - Headers: Add ARM support to intrin.h for MSVC compatibility
Author: compnerd Date: Sat Aug 6 12:58:24 2016 New Revision: 277928 URL: http://llvm.org/viewvc/llvm-project?rev=277928&view=rev Log: Headers: Add ARM support to intrin.h for MSVC compatibility This fixes compiling with headers from the Windows SDK for ARM, where the YieldProcessor function (in winnt.h) refers to _ARM_BARRIER_ISHST. The actual MSVC armintr.h contains a lot more definitions, but this is enough to build code that uses the Windows SDK but doesn't use ARM intrinsics directly. An alternative would to just keep the addition to intrin.h (to include armintr.h), but not actually ship armintr.h, instead having clang's intrin.h include armintr.h from MSVC's include directory. (That one works fine with clang, at least for building code that uses the Windows SDK.) Patch by Martin Storsjö! Added: cfe/trunk/lib/Headers/armintr.h Modified: cfe/trunk/lib/Headers/CMakeLists.txt cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/Headers/ms-intrin.cpp Modified: cfe/trunk/lib/Headers/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=277928&r1=277927&r2=277928&view=diff == --- cfe/trunk/lib/Headers/CMakeLists.txt (original) +++ cfe/trunk/lib/Headers/CMakeLists.txt Sat Aug 6 12:58:24 2016 @@ -3,6 +3,7 @@ set(files altivec.h ammintrin.h arm_acle.h + armintr.h avx2intrin.h avx512bwintrin.h avx512cdintrin.h Added: cfe/trunk/lib/Headers/armintr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/armintr.h?rev=277928&view=auto == --- cfe/trunk/lib/Headers/armintr.h (added) +++ cfe/trunk/lib/Headers/armintr.h Sat Aug 6 12:58:24 2016 @@ -0,0 +1,45 @@ +/*=== armintr.h - ARM Windows intrinsics ---=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ + +/* Only include this if we're compiling for the windows platform. */ +#ifndef _MSC_VER +#include_next +#else + +#ifndef __ARMINTR_H +#define __ARMINTR_H + +typedef enum +{ + _ARM_BARRIER_SY= 0xF, + _ARM_BARRIER_ST= 0xE, + _ARM_BARRIER_ISH = 0xB, + _ARM_BARRIER_ISHST = 0xA, + _ARM_BARRIER_NSH = 0x7, + _ARM_BARRIER_NSHST = 0x6, + _ARM_BARRIER_OSH = 0x3, + _ARM_BARRIER_OSHST = 0x2 +} _ARMINTR_BARRIER_TYPE; + +#endif /* __ARMINTR_H */ +#endif /* _MSC_VER */ Modified: cfe/trunk/lib/Headers/intrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=277928&r1=277927&r2=277928&view=diff == --- cfe/trunk/lib/Headers/intrin.h (original) +++ cfe/trunk/lib/Headers/intrin.h Sat Aug 6 12:58:24 2016 @@ -34,6 +34,10 @@ #include #endif +#if defined(__arm__) +#include +#endif + /* For the definition of jmp_buf. */ #if __STDC_HOSTED__ #include Modified: cfe/trunk/test/Headers/ms-intrin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/ms-intrin.cpp?rev=277928&r1=277927&r2=277928&view=diff == --- cfe/trunk/test/Headers/ms-intrin.cpp (original) +++ cfe/trunk/test/Headers/ms-intrin.cpp Sat Aug 6 12:58:24 2016 @@ -60,4 +60,8 @@ void f() { __readcr3(); __writecr3(0); #endif + +#ifdef _M_ARM + __dmb(_ARM_BARRIER_ISHST); +#endif } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
compnerd closed this revision. compnerd added a comment. SVN r277928 https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23239: [CUDA] Add __device__ overloads for placement new and delete.
jlebar created this revision. jlebar added a reviewer: tra. jlebar added a subscriber: cfe-commits. Previously these sort of worked because they didn't end up resulting in calls at the ptx layer. But I'm adding stricter checks that break placement new without these changes. https://reviews.llvm.org/D23239 Files: clang/lib/Headers/__clang_cuda_runtime_wrapper.h Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h === --- clang/lib/Headers/__clang_cuda_runtime_wrapper.h +++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -312,5 +312,15 @@ #pragma pop_macro("uint3") #pragma pop_macro("__USE_FAST_MATH__") +// Device overrides for placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) { + return __ptr; +} +__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) { + return __ptr; +} +__device__ inline void operator delete(void *, void *) {} +__device__ inline void operator delete[](void *, void *) {} + #endif // __CUDA__ #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__ Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h === --- clang/lib/Headers/__clang_cuda_runtime_wrapper.h +++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -312,5 +312,15 @@ #pragma pop_macro("uint3") #pragma pop_macro("__USE_FAST_MATH__") +// Device overrides for placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) { + return __ptr; +} +__device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) { + return __ptr; +} +__device__ inline void operator delete(void *, void *) {} +__device__ inline void operator delete[](void *, void *) {} + #endif // __CUDA__ #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23238: [CUDA] Rename CheckCUDATarget to IsAllowedCUDACall. NFC
jlebar created this revision. jlebar added a reviewer: tra. jlebar added a subscriber: cfe-commits. I want to reuse "CheckCUDAFoo" in a later patch. Also, I think IsAllowedCUDACall gets the point across more clearly. https://reviews.llvm.org/D23238 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOverload.cpp Index: clang/lib/Sema/SemaOverload.cpp === --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -5816,7 +5816,7 @@ // case we may not yet know what the member's target is; the target is // inferred for the member automatically, based on the bases and fields of // the class. - if (!Caller->isImplicit() && CheckCUDATarget(Caller, Function)) { + if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_target; return; @@ -6193,7 +6193,7 @@ // (CUDA B.1): Check for invalid calls between targets. if (getLangOpts().CUDA) if (const FunctionDecl *Caller = dyn_cast(CurContext)) - if (CheckCUDATarget(Caller, Method)) { + if (!IsAllowedCUDACall(Caller, Method)) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_target; return; @@ -10468,7 +10468,7 @@ if (FunctionDecl *FunDecl = dyn_cast(Fn)) { if (S.getLangOpts().CUDA) if (FunctionDecl *Caller = dyn_cast(S.CurContext)) - if (!Caller->isImplicit() && S.CheckCUDATarget(Caller, FunDecl)) + if (!Caller->isImplicit() && !S.IsAllowedCUDACall(Caller, FunDecl)) return false; // If any candidate has a placeholder return type, trigger its deduction @@ -12330,7 +12330,7 @@ // (CUDA B.1): Check for invalid calls between targets. if (getLangOpts().CUDA) { if (const FunctionDecl *Caller = dyn_cast(CurContext)) { - if (CheckCUDATarget(Caller, Method)) { + if (!IsAllowedCUDACall(Caller, Method)) { Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target) << IdentifyCUDATarget(Method) << Method->getIdentifier() << IdentifyCUDATarget(Caller); Index: clang/lib/Sema/SemaExpr.cpp === --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -1749,7 +1749,7 @@ if (getLangOpts().CUDA) if (const FunctionDecl *Caller = dyn_cast(CurContext)) if (const FunctionDecl *Callee = dyn_cast(D)) { -if (CheckCUDATarget(Caller, Callee)) { +if (!IsAllowedCUDACall(Caller, Callee)) { Diag(NameInfo.getLoc(), diag::err_ref_bad_target) << IdentifyCUDATarget(Callee) << D->getIdentifier() << IdentifyCUDATarget(Caller); Index: clang/include/clang/Sema/Sema.h === --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -9145,9 +9145,13 @@ const FunctionDecl *Callee); /// Determines whether Caller may invoke Callee, based on their CUDA - /// host/device attributes. Returns true if the call is not allowed. - bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee) { -return IdentifyCUDAPreference(Caller, Callee) == CFP_Never; + /// host/device attributes. Returns false if the call is not allowed. + /// + /// Note: Will return true for CFP_WrongSide calls. These may appear in + /// semantically correct CUDA programs, but only if they're never codegen'ed. + bool IsAllowedCUDACall(const FunctionDecl *Caller, + const FunctionDecl *Callee) { +return IdentifyCUDAPreference(Caller, Callee) != CFP_Never; } /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, Index: clang/lib/Sema/SemaOverload.cpp === --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -5816,7 +5816,7 @@ // case we may not yet know what the member's target is; the target is // inferred for the member automatically, based on the bases and fields of // the class. - if (!Caller->isImplicit() && CheckCUDATarget(Caller, Function)) { + if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_target; return; @@ -6193,7 +6193,7 @@ // (CUDA B.1): Check for invalid calls between targets. if (getLangOpts().CUDA) if (const FunctionDecl *Caller = dyn_cast(CurContext)) - if (CheckCUDATarget(Caller, Method)) { + if (!IsAllowedCUDACall(Caller, Method)) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_target; return; @@ -10468,7 +10468,7 @@ if (FunctionDecl *FunDecl = dyn_cast(Fn)) {
[PATCH] D23240: [CUDA] Print a "previous-decl" note when calling an illegal member fn.
jlebar created this revision. jlebar added a reviewer: tra. jlebar added a subscriber: cfe-commits. When we emit err_ref_bad_target, we should emit a "'method' declared here" note. We already do so in most places, just not in BuildCallToMemberFunction. https://reviews.llvm.org/D23240 Files: clang/lib/Sema/SemaOverload.cpp clang/test/SemaCUDA/method-target.cu Index: clang/test/SemaCUDA/method-target.cu === --- clang/test/SemaCUDA/method-target.cu +++ clang/test/SemaCUDA/method-target.cu @@ -6,7 +6,7 @@ // Test 1: host method called from device function struct S1 { - void method() {} + void method() {} // expected-note {{'method' declared here}} }; __device__ void foo1(S1& s) { @@ -29,7 +29,7 @@ // Test 3: device method called from host function struct S3 { - __device__ void method() {} + __device__ void method() {} // expected-note {{'method' declared here}}; }; void foo3(S3& s) { @@ -63,7 +63,7 @@ // Test 6: call method through pointer struct S6 { - void method() {} + void method() {} // expected-note {{'method' declared here}}; }; __device__ void foo6(S6* s) { Index: clang/lib/Sema/SemaOverload.cpp === --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -12334,6 +12334,7 @@ Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target) << IdentifyCUDATarget(Method) << Method->getIdentifier() << IdentifyCUDATarget(Caller); +Diag(Method->getLocation(), diag::note_previous_decl) << Method; return ExprError(); } } Index: clang/test/SemaCUDA/method-target.cu === --- clang/test/SemaCUDA/method-target.cu +++ clang/test/SemaCUDA/method-target.cu @@ -6,7 +6,7 @@ // Test 1: host method called from device function struct S1 { - void method() {} + void method() {} // expected-note {{'method' declared here}} }; __device__ void foo1(S1& s) { @@ -29,7 +29,7 @@ // Test 3: device method called from host function struct S3 { - __device__ void method() {} + __device__ void method() {} // expected-note {{'method' declared here}}; }; void foo3(S3& s) { @@ -63,7 +63,7 @@ // Test 6: call method through pointer struct S6 { - void method() {} + void method() {} // expected-note {{'method' declared here}}; }; __device__ void foo6(S6* s) { Index: clang/lib/Sema/SemaOverload.cpp === --- clang/lib/Sema/SemaOverload.cpp +++ clang/lib/Sema/SemaOverload.cpp @@ -12334,6 +12334,7 @@ Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target) << IdentifyCUDATarget(Method) << Method->getIdentifier() << IdentifyCUDATarget(Caller); +Diag(Method->getLocation(), diag::note_previous_decl) << Method; return ExprError(); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23241: Add the notion of deferred diagnostics.
jlebar created this revision. jlebar added a reviewer: rnk. jlebar added subscribers: tra, cfe-commits. This patch lets you create diagnostics that are emitted if and only if a particular FunctionDecl is codegen'ed. This is necessary for CUDA, where some constructs -- e.g. calls from host+device functions to host functions when compiling for device -- are allowed to appear in semantically-correct programs, but only if they're never codegen'ed. https://reviews.llvm.org/D23241 Files: clang/include/clang/AST/Decl.h clang/lib/AST/Decl.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h Index: clang/lib/CodeGen/CodeGenModule.h === --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -490,6 +490,10 @@ /// MDNodes. llvm::DenseMap MetadataIdMap; + /// Diags gathered from FunctionDecl::takeDeferredDiags(). Emitted at the + /// very end of codegen. + std::vector> DeferredDiags; + public: CodeGenModule(ASTContext &C, const HeaderSearchOptions &headersearchopts, const PreprocessorOptions &ppopts, Index: clang/lib/CodeGen/CodeGenModule.cpp === --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -497,6 +497,16 @@ EmitVersionIdentMetadata(); EmitTargetMetadata(); + + // Emit any deferred diagnostics gathered during codegen. We didn't emit them + // when we first discovered them because that would have halted codegen, + // preventing us from gathering other deferred diags. + for (const PartialDiagnosticAt &DiagAt : DeferredDiags) { +SourceLocation Loc = DiagAt.first; +const PartialDiagnostic &PD = DiagAt.second; +DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID())); +PD.Emit(Builder); + } } void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { @@ -2872,6 +2882,19 @@ llvm::GlobalValue *GV) { const auto *D = cast(GD.getDecl()); + // Check if this function has diagnostics that should be emitted when we + // codegen it. If so, don't eit this function definition, but don't emit the + // diags just yet. Emitting an error during codegen stops codegen, and we + // want to display as many deferred diags as possible. We'll emit the now + // twice-deferred diags at the very end of codegen. + auto Diags = D->takeDeferredDiags(); + bool HasDiags = !Diags.empty(); + DeferredDiags.insert(DeferredDiags.end(), + std::make_move_iterator(Diags.begin()), + std::make_move_iterator(Diags.end())); + if (HasDiags) +return; + // Compute the function info and LLVM type. const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); Index: clang/lib/AST/Decl.cpp === --- clang/lib/AST/Decl.cpp +++ clang/lib/AST/Decl.cpp @@ -3436,6 +3436,22 @@ return 0; } +void FunctionDecl::addDeferredDiag(PartialDiagnosticAt PD) { + if (!DeferredDiags) +DeferredDiags = llvm::make_unique>(); + DeferredDiags->emplace_back(PD); +} + +std::vector FunctionDecl::takeDeferredDiags() const { + if (!DeferredDiags) +return {}; + assert(!DeferredDiags->empty() && + "DeferredDiags should be non-null only if it's also non-empty."); + auto Ret = std::move(*DeferredDiags); + DeferredDiags.reset(); + return Ret; +} + //===--===// // FieldDecl Implementation //===--===// Index: clang/include/clang/AST/Decl.h === --- clang/include/clang/AST/Decl.h +++ clang/include/clang/AST/Decl.h @@ -1638,6 +1638,14 @@ /// declaration name embedded in the DeclaratorDecl base class. DeclarationNameLoc DNLoc; + /// Storage for diagnostics deferred until this function is codegen'ed (if it + /// ever is). + /// + /// These are rarely used, so we use a pointer-to-vector to save two words + /// inside FunctionDecl. This is mutable because emitting diagnostics (which + /// clears this list) needs to be a logically-const operation. + mutable std::unique_ptr> DeferredDiags; + /// \brief Specify that this function declaration is actually a function /// template specialization. /// @@ -2271,6 +2279,14 @@ /// returns 0. unsigned getMemoryFunctionKind() const; + /// Add a diagnostic to be emitted if and when this function is codegen'ed. + void addDeferredDiag(PartialDiagnosticAt PD); + + /// Gets this object's list of deferred diagnostics, if there are any. + /// + /// Although this is logically const, it clears our list of deferred diags. + std::vector takeDeferredDiags() const; + // Implement
[PATCH] D23242: [CUDA] Raise an error if a wrong-side call is codegen'ed.
jlebar created this revision. jlebar added reviewers: tra, rnk. jlebar added a subscriber: cfe-commits. Some function calls in CUDA are allowed to appear in semantically-correct programs but are an error if they're ever codegen'ed. Specifically, a host+device function may call a host function, but it's an error if such a function is ever codegen'ed in device mode (and vice versa). Previously, clang made no attempt to catch these errors. For the most part, they would be caught by ptxas, and reported as "call to unknown function 'foo'". Now we catch these errors and report them the same as we report other illegal calls (e.g. a call from a host function to a device function). This has a small change in error-message behavior for calls that were previously disallowed (e.g. calls from a host to a device function). Previously, we'd catch disallowed calls fairly early, before doing additional semantic checking e.g. of the call's arguments. Now we catch these illegal calls at the very end of our semantic checks, so we'll only emit a "illegal CUDA call" error if the call is otherwise well-formed. https://reviews.llvm.org/D23242 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOverload.cpp clang/test/CodeGenCUDA/host-device-calls-host.cu clang/test/SemaCUDA/Inputs/cuda.h clang/test/SemaCUDA/call-device-fn-from-host.cu clang/test/SemaCUDA/call-host-fn-from-device.cu Index: clang/test/SemaCUDA/call-host-fn-from-device.cu === --- /dev/null +++ clang/test/SemaCUDA/call-host-fn-from-device.cu @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -emit-llvm -o - -verify + +// Note: This test won't work with -fsyntax-only, because some of these errors +// are emitted during codegen. + +#include "Inputs/cuda.h" + +__device__ void device_fn() {} + +struct S { + __device__ S() {} + __device__ ~S() { device_fn(); } + int x; +}; + +struct T { + __host__ __device__ void hd() { device_fn(); } + // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} + + // No error; this is (implicitly) inline and is never called, so isn't + // codegen'ed. + __host__ __device__ void hd2() { device_fn(); } + + __host__ __device__ void hd3(); + + __device__ void d() {} +}; + +__host__ __device__ void T::hd3() { + device_fn(); + // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} +} + +template __host__ __device__ void hd2() { device_fn(); } +// expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} +void host_fn() { hd2(); } + +__host__ __device__ void hd() { device_fn(); } +// expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} + +template __host__ __device__ void hd3() { device_fn(); } +// expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} +__device__ void device_fn() { hd3(); } + +// No error because this is never instantiated. +template __host__ __device__ void hd4() { device_fn(); } + +__host__ __device__ void local_var() { + S s; + // expected-error@-1 {{reference to __device__ function 'S' in __host__ __device__ function}} +} + +__host__ __device__ void placement_new(char *ptr) { + ::new(ptr) S(); + // expected-error@-1 {{reference to __device__ function 'S' in __host__ __device__ function}} +} + +__host__ __device__ void explicit_destructor(S *s) { + s->~S(); + // expected-error@-1 {{reference to __device__ function '~S' in __host__ __device__ function}} +} + +__host__ __device__ void hd_member_fn() { + T t; + // Necessary to trigger an error on T::hd. It's (implicitly) inline, so + // isn't codegen'ed until we call it. + t.hd(); +} + +__host__ __device__ void h_member_fn() { + T t; + t.d(); + // expected-error@-1 {{reference to __device__ function 'h' in __host__ __device__ function}} +} + +__host__ __device__ void fn_ptr() { + auto* ptr = &device_fn; + // expected-error@-1 {{reference to __device__ function 'device_fn' in __host__ __device__ function}} +} + +template +__host__ __device__ void fn_ptr_template() { + auto* ptr = &device_fn; // Not an error because the template isn't instantiated. +} Index: clang/test/SemaCUDA/call-device-fn-from-host.cu === --- /dev/null +++ clang/test/SemaCUDA/call-device-fn-from-host.cu @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - -verify + +// Note: This test won't work with -fsyntax-only, because some of these errors +// are emitted during codegen. + +#include "Inputs/cuda.h" + +extern "C" void host_fn() {} + +struct S { + S() {} + ~S() { host_fn(); } + int x; +}; + +struct T { + __host__ __de
r277935 - Add the new scan-build option (--show-description) in the 4.0 release notes
Author: sylvestre Date: Sat Aug 6 15:23:54 2016 New Revision: 277935 URL: http://llvm.org/viewvc/llvm-project?rev=277935&view=rev Log: Add the new scan-build option (--show-description) in the 4.0 release notes Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=277935&r1=277934&r2=277935&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Sat Aug 6 15:23:54 2016 @@ -133,6 +133,10 @@ libclang ... +With the option --show-description, scan-build's list of defects will also +show the description of the defects. + + Static Analyzer --- ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file
omtcyfz added a comment. `.cpp.rename-at.yaml`? I understand it's done for the purpose of doing `-input %s.rename-at.yaml`, though I don't think getting proper names for them and either doing some string magic in tool invocation or just passing full name is wrong. Other than that my concerns seem to be resolved. I'd wait for Manuel to jump in if he has time on Monday, though. https://reviews.llvm.org/D23198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file
omtcyfz added a comment. + I'll take a look again on Monday, too. May be too sleepy now :) https://reviews.llvm.org/D23198 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator
omtcyfz created this revision. omtcyfz added reviewers: alexfh, Eugene.Zelenko. omtcyfz added a subscriber: cfe-commits. Fixing bug https://llvm.org/bugs/show_bug.cgi?id=28854. Implicit cast with ternary operator makes AST look in a way in which it feels reasonable to add second matcher to detect implicit casts in ternary operators. https://reviews.llvm.org/D23243 Files: clang-tidy/modernize/UseBoolLiteralsCheck.cpp test/clang-tidy/modernize-use-bool-literals.cpp Index: test/clang-tidy/modernize-use-bool-literals.cpp === --- test/clang-tidy/modernize-use-bool-literals.cpp +++ test/clang-tidy/modernize-use-bool-literals.cpp @@ -116,3 +116,20 @@ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}} } + +static int Value = 1; + +bool Function1() { + bool Result = Value == 1 ? 1 : 0; + // CHECK-MESSAGES: :[[@LINE-1]]:30: {{.*}} + // CHECK-MESSAGES: :[[@LINE-2]]:34: {{.*}} + // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}} + return Result; +} + +bool Function2() { + return Value == 1 ? 1 : 0; + // CHECK-MESSAGES: :[[@LINE-1]]:23: {{.*}} + // CHECK-MESSAGES: :[[@LINE-2]]:27: {{.*}} + // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}} +} Index: clang-tidy/modernize/UseBoolLiteralsCheck.cpp === --- clang-tidy/modernize/UseBoolLiteralsCheck.cpp +++ clang-tidy/modernize/UseBoolLiteralsCheck.cpp @@ -29,25 +29,43 @@ unless(isInTemplateInstantiation()), anyOf(hasParent(explicitCastExpr().bind("cast")), anything())), this); + + Finder->addMatcher( + conditionalOperator( + hasParent(implicitCastExpr( + hasImplicitDestinationType(qualType(booleanType())), + unless(isInTemplateInstantiation(, + anyOf(hasTrueExpression(ignoringParenImpCasts( +integerLiteral().bind("trueBranchLiteral"))), +anything()), + anyOf(hasFalseExpression(ignoringParenImpCasts( +integerLiteral().bind("falseBranchLiteral"))), +anything())), + this); } void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult &Result) { - const auto *Literal = Result.Nodes.getNodeAs("literal"); - const auto *Cast = Result.Nodes.getNodeAs("cast"); - bool LiteralBooleanValue = Literal->getValue().getBoolValue(); + for (const auto &BindingName : + {"literal", "trueBranchLiteral", "falseBranchLiteral"}) { +const auto *Literal = Result.Nodes.getNodeAs(BindingName); +if (!Literal) + continue; +const auto *Cast = Result.Nodes.getNodeAs("cast"); +bool LiteralBooleanValue = Literal->getValue().getBoolValue(); - if (Literal->isInstantiationDependent()) -return; +if (Literal->isInstantiationDependent()) + continue; - const Expr *Expression = Cast ? Cast : Literal; +const Expr *Expression = Cast ? Cast : Literal; - auto Diag = - diag(Expression->getExprLoc(), - "converting integer literal to bool, use bool literal instead"); +auto Diag = +diag(Expression->getExprLoc(), + "converting integer literal to bool, use bool literal instead"); - if (!Expression->getLocStart().isMacroID()) -Diag << FixItHint::CreateReplacement( -Expression->getSourceRange(), LiteralBooleanValue ? "true" : "false"); +if (!Expression->getLocStart().isMacroID()) + Diag << FixItHint::CreateReplacement( + Expression->getSourceRange(), LiteralBooleanValue ? "true" : "false"); + } } } // namespace modernize Index: test/clang-tidy/modernize-use-bool-literals.cpp === --- test/clang-tidy/modernize-use-bool-literals.cpp +++ test/clang-tidy/modernize-use-bool-literals.cpp @@ -116,3 +116,20 @@ // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}} } + +static int Value = 1; + +bool Function1() { + bool Result = Value == 1 ? 1 : 0; + // CHECK-MESSAGES: :[[@LINE-1]]:30: {{.*}} + // CHECK-MESSAGES: :[[@LINE-2]]:34: {{.*}} + // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}} + return Result; +} + +bool Function2() { + return Value == 1 ? 1 : 0; + // CHECK-MESSAGES: :[[@LINE-1]]:23: {{.*}} + // CHECK-MESSAGES: :[[@LINE-2]]:27: {{.*}} + // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}} +} Index: clang-tidy/modernize/UseBoolLiteralsCheck.cpp === --- clang-tidy/modernize/UseBoolLiteralsCheck.cpp +++ clang-tidy/modernize/UseBoolLiteralsCheck.cpp @@ -29,25 +29,43 @@ unless(isInTemplateInstantiation()), anyOf(hasParent(explicitCastExpr().bind("cast")), anything())), this); + + Finder->addMatcher( + conditionalOperator( + hasParent(implicitCa
[PATCH] [clang-format] add AfterMultilineControlStatement
Hi. When indent is four spaces, "if" conditions spanning multiple lines could be difficult to discern from the "if" body. Indentation is the same, so they are visually blending. (See example below). One of the solutions is to place opening brace on a separate line when "if" condition spans multiple lines. Always putting it on a separate line in undesired, as there are usually no so many "if"s with multiline conditions. To make that possible, proposed patch adds another setting, BraceWrapping.AfterMultilineControlStatement which acts like BraceWrapping.AfterControlStatement, but only if condition in control statement spans over multiple lines. I didn't see a way to detach brace and move it to the next line once unwrapped lines are constructed. So when AfterMultilineControlStatement is enabled, all opening braces go to a separate unwrapped line. Then, if length of the line is not higher that column limit, code tries to reattach brace back. To make what I said above a bit clearer, here are examples: if (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15) { some_code(); some_other_code(); } This patch allows to change that to: if (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15) { some_code(); some_other_code(); } while keeping opening brace for short conditions on the same line: if (0) { some_code(); } --- Rinat--- docs/ClangFormatStyleOptions.rst | 1 + include/clang/Format/Format.h| 2 + lib/Format/Format.cpp| 7 +- lib/Format/UnwrappedLineFormatter.cpp| 28 +- lib/Format/UnwrappedLineParser.cpp | 14 +-- test/Format/multiline-control-statements.cpp | 123 +++ unittests/Format/FormatTest.cpp | 1 + 7 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 test/Format/multiline-control-statements.cpp diff --git a/docs/ClangFormatStyleOptions.rst b/docs/ClangFormatStyleOptions.rst index a548e83..e83f144 100644 --- a/docs/ClangFormatStyleOptions.rst +++ b/docs/ClangFormatStyleOptions.rst @@ -340,6 +340,7 @@ the configuration (without a prefix: ``Auto``). * ``bool AfterControlStatement`` Wrap control statements (``if``/``for``/``while``/``switch``/..). * ``bool AfterEnum`` Wrap enum definitions. * ``bool AfterFunction`` Wrap function definitions. + * ``bool AfterMultilineControlStatement`` Wrap control statements that span over more than one line. * ``bool AfterNamespace`` Wrap namespace definitions. * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..). * ``bool AfterStruct`` Wrap struct definitions. diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index 1ff305d..80434dc 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -257,6 +257,8 @@ struct FormatStyle { bool AfterEnum; /// \brief Wrap function definitions. bool AfterFunction; +/// \bried Wrap control statements spanning over more than one line. +bool AfterMultilineControlStatement; /// \brief Wrap namespace definitions. bool AfterNamespace; /// \brief Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..). diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index b0f64e2..3afacd2 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -363,6 +363,8 @@ template <> struct MappingTraits { IO.mapOptional("AfterControlStatement", Wrapping.AfterControlStatement); IO.mapOptional("AfterEnum", Wrapping.AfterEnum); IO.mapOptional("AfterFunction", Wrapping.AfterFunction); +IO.mapOptional("AfterMultilineControlStatement", + Wrapping.AfterMultilineControlStatement); IO.mapOptional("AfterNamespace", Wrapping.AfterNamespace); IO.mapOptional("AfterObjCDeclaration", Wrapping.AfterObjCDeclaration); IO.mapOptional("AfterStruct", Wrapping.AfterStruct); @@ -440,7 +442,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) { return Style; FormatStyle Expanded = Style; Expanded.BraceWrapping = {false, false, false, false, false, false, -false, false, false, false, false}; +false, false, false, false, false, false}; switch (Style.BreakBeforeBraces) { case FormatStyle::BS_Linux: Expanded.BraceWrapping.AfterClass = true; @@ -464,6 +466,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) { Expanded.BraceWrapping.AfterControlStatement = true; Expanded.BraceWrapping.AfterEnum = true; Expanded.BraceWrapping.AfterFunction = true; +Expanded.BraceWrapping.AfterMultilineControlStatement = true; Expanded.BraceWrapping.AfterNamespace = true; Expanded.BraceWrapping.AfterObjCDeclaration = true; Expanded.BraceWrapping.AfterStruct = true; @@ -472,7 +475,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) { b
Re: [PATCH] D23243: [clang-tidy] enhance modernize-use-bool-literals to check ternary operator
Prazek added inline comments. Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:38-43 @@ +37,8 @@ + unless(isInTemplateInstantiation(, + anyOf(hasTrueExpression(ignoringParenImpCasts( +integerLiteral().bind("trueBranchLiteral"))), +anything()), + anyOf(hasFalseExpression(ignoringParenImpCasts( +integerLiteral().bind("falseBranchLiteral"))), +anything())), + this); Do I understand it correctly, that you have to have this 2 anyOf matchers, because if you would have it in one then because anyOf is lazy, it would not bind to the second branch? I think it would be good to write some comment about it, because on the first sight it looks like it could be simplified. Comment at: test/clang-tidy/modernize-use-bool-literals.cpp:119 @@ -118,1 +118,3 @@ } + +static int Value = 1; Please add a test with only one branch with constant, and none of them. Also one test like bool Result = Value == 1 ? true : 0; or bool Result = Value == 1 ? false : bool(0); Repository: rL LLVM https://reviews.llvm.org/D23243 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits