Re: [PATCH] D13978: [X86] Support MCU psABI when marking inregs
mkuper added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:857 @@ -854,3 +856,3 @@ IsWin32StructABI(Win32StructABI), - IsSoftFloatABI(SoftFloatABI), + IsSoftFloatABI(SoftFloatABI), IsMCUABI(MCUABI), DefaultNumRegisterParameters(NumRegisterParameters) {} rnk wrote: > Rather than taking this as a parameter, how about initializing IsMCUABI with > `getTarget().getTriple().isEnvironmentIAMCU()`? Then you can drop a level of > parameters. Sure, will do. Comment at: test/CodeGen/x86_32-arguments-iamcu.c:1 @@ +1,2 @@ +// RUN: %clang_cc1 -w -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o - %s | FileCheck %s + DavidKreitzer wrote: > Good test! > > I think it would be a good idea to add a varargs function & verify that the > args do not get marked inreg. They do get marked inreg, actually. The varargs handling for -mregparm - and that means for IAMCU as well - happens on the CG level. ``` def CC_X86_32_C : CallingConv<[ ... // The first 3 integer arguments, if marked 'inreg' and if the call is not // a vararg call, are passed in integer registers. **CCIfNotVarArg**>>>, ... ]>; ``` (Yes, this is incredibly ugly. We should probably fix that in a separate patch.) http://reviews.llvm.org/D13978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13978: [X86] Support MCU psABI when marking inregs
This revision was automatically updated to reflect the committed changes. Closed by commit rL251224: [X86] Mark inregs correctly for MCU psABI (authored by mkuper). Changed prior to commit: http://reviews.llvm.org/D13978?vs=38107&id=38341#toc Repository: rL LLVM http://reviews.llvm.org/D13978 Files: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Index: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c === --- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c +++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -w -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: define void @ints(i32 inreg %a, i32 inreg %b, i32 inreg %c, i32 %d) +void ints(int a, int b, int c, int d) {} + +// CHECK-LABEL: define void @floats(float inreg %a, float inreg %b, float inreg %c, float %d) +void floats(float a, float b, float c, float d) {} + +// CHECK-LABEL: define void @mixed(i32 inreg %a, float inreg %b, i32 inreg %c, float %d) +void mixed(int a, float b, int c, float d) {} + +// CHECK-LABEL: define void @doubles(double inreg %d1, double %d2) +void doubles(double d1, double d2) {} + +// CHECK-LABEL: define void @mixedDoubles(i32 inreg %a, double inreg %d1) +void mixedDoubles(int a, double d1) {} + +typedef struct st4_t { + int a; +} st4_t; + +typedef struct st5_t { + int a; + char b; +} st5_t; + +typedef struct st12_t { + int a; + int b; + int c; +} st12_t; + +// CHECK-LABEL: define void @smallStructs(i32 inreg %st1.coerce, i32 inreg %st2.coerce, i32 inreg %st3.coerce) +void smallStructs(st4_t st1, st4_t st2, st4_t st3) {} + +// CHECK-LABEL: define void @paddedStruct(i32 inreg %i1, i32 inreg %st.coerce0, i32 inreg %st.coerce1, i32 %st4.0) +void paddedStruct(int i1, st5_t st, st4_t st4) {} + +// CHECK-LABEL: define void @largeStruct(i32 %st.0, i32 %st.1, i32 %st.2) +void largeStruct(st12_t st) {} + +// CHECK-LABEL: define void @largeStructMiddle(i32 inreg %i1, i32 %st.0, i32 %st.1, i32 %st.2, i32 inreg %i2, i32 inreg %i3) +void largeStructMiddle(int i1, st12_t st, int i2, int i3) {} + +// CHECK-LABEL: define i32 @retSmallStruct(i32 inreg %r.coerce) +st4_t retSmallStruct(st4_t r) { return r; } + +// CHECK-LABEL: define i64 @retPaddedStruct(i32 inreg %r.coerce0, i32 inreg %r.coerce1) +st5_t retPaddedStruct(st5_t r) { return r; } + +// CHECK-LABEL: define void @retLargeStruct(%struct.st12_t* inreg noalias sret %agg.result, i32 inreg %i1, i32 %r.0, i32 %r.1, i32 %r.2) +st12_t retLargeStruct(int i1, st12_t r) { return r; } + +// FIXME: We really shouldn't be marking this inreg. Right now the +// inreg gets ignored by the CG for varargs functions, but that's +// insane. +// CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...) +int varArgs(int i1, ...) { return i1; } Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp === --- cfe/trunk/lib/CodeGen/TargetInfo.cpp +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp @@ -799,6 +799,7 @@ bool IsRetSmallStructInRegABI; bool IsWin32StructABI; bool IsSoftFloatABI; + bool IsMCUABI; unsigned DefaultNumRegisterParameters; static bool isRegisterSize(unsigned Size) { @@ -853,6 +854,7 @@ IsRetSmallStructInRegABI(RetSmallStructInRegABI), IsWin32StructABI(Win32StructABI), IsSoftFloatABI(SoftFloatABI), + IsMCUABI(CGT.getTarget().getTriple().isEnvironmentIAMCU()), DefaultNumRegisterParameters(NumRegisterParameters) {} }; @@ -986,7 +988,7 @@ } /// shouldReturnTypeInRegister - Determine if the given type should be -/// returned in a register (for the Darwin ABI). +/// returned in a register (for the Darwin and MCU ABI). bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, ASTContext &Context) const { uint64_t Size = Context.getTypeSize(Ty); @@ -1226,9 +1228,18 @@ if (SizeInRegs == 0) return false; - if (SizeInRegs > State.FreeRegs) { -State.FreeRegs = 0; -return false; + if (!IsMCUABI) { +if (SizeInRegs > State.FreeRegs) { + State.FreeRegs = 0; + return false; +} + } else { +// The MCU psABI allows passing parameters in-reg even if there are +// earlier parameters that are passed on the stack. Also, +// it does not allow passing >8-byte structs in-register, +// even if there are 3 free registers available. +if (SizeInRegs > State.FreeRegs || SizeInRegs > 2) + return false; } State.FreeRegs -= SizeInRegs; @@ -1372,6 +1383,8 @@ State.FreeSSERegs = 6; } else if (FI.getHasRegParm()) State.FreeRegs = FI.getRegParm(); + else if (IsMCUABI) +State.FreeRegs = 3; else State.FreeRegs = DefaultNumRegisterParameters; @@ -1520,7 +1533,7 @@ return true; } - if (Triple.isOSDarwin()) + if (Triple.isOSDarwin() || Triple.isEnvironmentIAMCU()) return tru
r251224 - [X86] Mark inregs correctly for MCU psABI
Author: mkuper Date: Sun Oct 25 03:18:20 2015 New Revision: 251224 URL: http://llvm.org/viewvc/llvm-project?rev=251224&view=rev Log: [X86] Mark inregs correctly for MCU psABI The MCU psABI calling convention is somewhat, but not quite, like -mregparm 3. In particular, the rules involving structs are different. Differential Revision: http://reviews.llvm.org/D13978 Added: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=251224&r1=251223&r2=251224&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sun Oct 25 03:18:20 2015 @@ -799,6 +799,7 @@ class X86_32ABIInfo : public ABIInfo { bool IsRetSmallStructInRegABI; bool IsWin32StructABI; bool IsSoftFloatABI; + bool IsMCUABI; unsigned DefaultNumRegisterParameters; static bool isRegisterSize(unsigned Size) { @@ -853,6 +854,7 @@ public: IsRetSmallStructInRegABI(RetSmallStructInRegABI), IsWin32StructABI(Win32StructABI), IsSoftFloatABI(SoftFloatABI), + IsMCUABI(CGT.getTarget().getTriple().isEnvironmentIAMCU()), DefaultNumRegisterParameters(NumRegisterParameters) {} }; @@ -986,7 +988,7 @@ void X86_32TargetCodeGenInfo::addReturnR } /// shouldReturnTypeInRegister - Determine if the given type should be -/// returned in a register (for the Darwin ABI). +/// returned in a register (for the Darwin and MCU ABI). bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, ASTContext &Context) const { uint64_t Size = Context.getTypeSize(Ty); @@ -1226,9 +1228,18 @@ bool X86_32ABIInfo::shouldUseInReg(QualT if (SizeInRegs == 0) return false; - if (SizeInRegs > State.FreeRegs) { -State.FreeRegs = 0; -return false; + if (!IsMCUABI) { +if (SizeInRegs > State.FreeRegs) { + State.FreeRegs = 0; + return false; +} + } else { +// The MCU psABI allows passing parameters in-reg even if there are +// earlier parameters that are passed on the stack. Also, +// it does not allow passing >8-byte structs in-register, +// even if there are 3 free registers available. +if (SizeInRegs > State.FreeRegs || SizeInRegs > 2) + return false; } State.FreeRegs -= SizeInRegs; @@ -1372,6 +1383,8 @@ void X86_32ABIInfo::computeInfo(CGFuncti State.FreeSSERegs = 6; } else if (FI.getHasRegParm()) State.FreeRegs = FI.getRegParm(); + else if (IsMCUABI) +State.FreeRegs = 3; else State.FreeRegs = DefaultNumRegisterParameters; @@ -1520,7 +1533,7 @@ bool X86_32TargetCodeGenInfo::isStructRe return true; } - if (Triple.isOSDarwin()) + if (Triple.isOSDarwin() || Triple.isEnvironmentIAMCU()) return true; switch (Triple.getOS()) { Added: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c?rev=251224&view=auto == --- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c (added) +++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c Sun Oct 25 03:18:20 2015 @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -w -triple i386-pc-elfiamcu -mfloat-abi soft -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: define void @ints(i32 inreg %a, i32 inreg %b, i32 inreg %c, i32 %d) +void ints(int a, int b, int c, int d) {} + +// CHECK-LABEL: define void @floats(float inreg %a, float inreg %b, float inreg %c, float %d) +void floats(float a, float b, float c, float d) {} + +// CHECK-LABEL: define void @mixed(i32 inreg %a, float inreg %b, i32 inreg %c, float %d) +void mixed(int a, float b, int c, float d) {} + +// CHECK-LABEL: define void @doubles(double inreg %d1, double %d2) +void doubles(double d1, double d2) {} + +// CHECK-LABEL: define void @mixedDoubles(i32 inreg %a, double inreg %d1) +void mixedDoubles(int a, double d1) {} + +typedef struct st4_t { + int a; +} st4_t; + +typedef struct st5_t { + int a; + char b; +} st5_t; + +typedef struct st12_t { + int a; + int b; + int c; +} st12_t; + +// CHECK-LABEL: define void @smallStructs(i32 inreg %st1.coerce, i32 inreg %st2.coerce, i32 inreg %st3.coerce) +void smallStructs(st4_t st1, st4_t st2, st4_t st3) {} + +// CHECK-LABEL: define void @paddedStruct(i32 inreg %i1, i32 inreg %st.coerce0, i32 inreg %st.coerce1, i32 %st4.0) +void paddedStruct(int i1, st5_t st, st4_t st4) {} + +// CHECK-LABEL: define void @largeStruct(i32 %st.0, i32 %st.1, i32 %st.2) +void largeStruct(st12_t st) {} + +// CHECK-LABEL: define void @largeStructMiddle(i32 inreg %i1, i32 %st.0, i32 %st.1, i32 %st.2, i32 inreg %i2, i32 inreg %i3) +void largeStructMiddle(int i1, st12_t st, int i2, int i3) {} + +// CHECK-LABEL: define i32 @r
[clang-tools-extra] r251235 - [clang-tidy] Add check readability-implicit-bool-cast
Author: piotrdz Date: Sun Oct 25 10:31:25 2015 New Revision: 251235 URL: http://llvm.org/viewvc/llvm-project?rev=251235&view=rev Log: [clang-tidy] Add check readability-implicit-bool-cast Summary: This is another check that I ported to clang-tidy from colobot-lint tool. As previously discussed on cfe-dev mailing list, this is one of those checks that I think is general and useful enough for contribution to clang-tidy. This patch contains implementation of check taken from colobot-lint, but it is extended a great deal, including FixIt hints for automated refactoring, exhaustive testcases, and user documentation. Reviewers: sbenza, aaron.ballman, alexfh Subscribers: Eugene.Zelenko Differential Revision: http://reviews.llvm.org/D13635 Added: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-cast.rst clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=251235&r1=251234&r2=251235&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Sun Oct 25 10:31:25 2015 @@ -6,6 +6,7 @@ add_clang_library(clangTidyReadabilityMo ElseAfterReturnCheck.cpp FunctionSizeCheck.cpp IdentifierNamingCheck.cpp + ImplicitBoolCastCheck.cpp InconsistentDeclarationParameterNameCheck.cpp NamedParameterCheck.cpp NamespaceCommentCheck.cpp Added: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251235&view=auto == --- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Sun Oct 25 10:31:25 2015 @@ -0,0 +1,425 @@ +//===--- ImplicitBoolCastCheck.cpp - clang-tidy===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ImplicitBoolCastCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { + +namespace { + +const internal::VariadicDynCastAllOfMatcher parenExpr; + +AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) { + return Node.getCastKind() == Kind; +} + +AST_MATCHER(QualType, isBool) { + return !Node.isNull() && Node->isBooleanType(); +} + +AST_MATCHER(Stmt, isMacroExpansion) { + SourceManager &SM = Finder->getASTContext().getSourceManager(); + SourceLocation Loc = Node.getLocStart(); + return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc); +} + +bool isNULLMacroExpansion(const Stmt *Statement, ASTContext &Context) { + SourceManager &SM = Context.getSourceManager(); + const LangOptions &LO = Context.getLangOpts(); + SourceLocation Loc = Statement->getLocStart(); + return SM.isMacroBodyExpansion(Loc) && + clang::Lexer::getImmediateMacroName(Loc, SM, LO) == "NULL"; +} + +AST_MATCHER(Stmt, isNULLMacroExpansion) { + return isNULLMacroExpansion(&Node, Finder->getASTContext()); +} + +ast_matchers::internal::Matcher createExceptionCasesMatcher() { + return expr(anyOf(hasParent(explicitCastExpr()), +allOf(isMacroExpansion(), unless(isNULLMacroExpansion())), +isInTemplateInstantiation(), +hasAncestor(functionTemplateDecl(; +} + +StatementMatcher createImplicitCastFromBoolMatcher() { + return implicitCastExpr( + unless(createExceptionCasesMatcher()), + anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating), +// Prior to C++11 cast from bool literal to pointer was allowed. +allOf(anyOf(hasCastKind(CK_NullToPointer), +hasCastKind(CK_NullToMemberPointer)), + hasSourceExpression(c
[clang-tools-extra] r251239 - [clang-tidy] Fix for build bots not liking #include
Author: piotrdz Date: Sun Oct 25 10:47:21 2015 New Revision: 251239 URL: http://llvm.org/viewvc/llvm-project?rev=251239&view=rev Log: [clang-tidy] Fix for build bots not liking #include Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp?rev=251239&r1=251238&r2=251239&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp Sun Oct 25 10:47:21 2015 @@ -1,6 +1,9 @@ // RUN: clang-tidy %s -checks=-*,readability-implicit-bool-cast -- -std=c++98 -#include // for NULL +// We need NULL macro, but some buildbots don't like including header +// This is a portable way of getting it to work +#undef NULL +#define NULL 0L template void functionTaking(T); Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=251239&r1=251238&r2=251239&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp Sun Oct 25 10:47:21 2015 @@ -1,6 +1,9 @@ // RUN: %check_clang_tidy %s readability-implicit-bool-cast %t -#include // for NULL +// We need NULL macro, but some buildbots don't like including header +// This is a portable way of getting it to work +#undef NULL +#define NULL 0L template void functionTaking(T); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13289: [libc++] Provide additional templates for valarray transcendentals that satisfy the standard synopsis
petpav01 added a comment. Thank you for having a look at this patch. I should get to updating it as requested soon. Apologies for the delay. http://reviews.llvm.org/D13289 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r251244 - [clang-tidy] Another fix for failing buildbots regarding signedness of char
Author: piotrdz Date: Sun Oct 25 12:11:13 2015 New Revision: 251244 URL: http://llvm.org/viewvc/llvm-project?rev=251244&view=rev Log: [clang-tidy] Another fix for failing buildbots regarding signedness of char I totally forgot that char can be defined as unsigned on some platforms. Now I made explicit mention of signed type where necessary in tests. Also fixed '//RUN: ' header of cxx98 test to correct format. Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp?rev=251244&r1=251243&r2=251244&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp Sun Oct 25 12:11:13 2015 @@ -1,4 +1,4 @@ -// RUN: clang-tidy %s -checks=-*,readability-implicit-bool-cast -- -std=c++98 +// RUN: %check_clang_tidy %s readability-implicit-bool-cast %t -- -- -std=c++98 // We need NULL macro, but some buildbots don't like including header // This is a portable way of getting it to work Modified: clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=251244&r1=251243&r2=251244&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp Sun Oct 25 12:11:13 2015 @@ -94,9 +94,9 @@ void implicitCastFromBoolLiterals() { // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit cast bool -> 'unsigned long' // CHECK-FIXES: functionTaking(0u); - functionTaking(true); - // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast bool -> 'char' - // CHECK-FIXES: functionTaking(1); + functionTaking(true); + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: implicit cast bool -> 'signed char' + // CHECK-FIXES: functionTaking(1); functionTaking(false); // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: implicit cast bool -> 'float' @@ -183,9 +183,9 @@ void implicitCastToBoolSimpleCases() { // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast 'double' -> bool // CHECK-FIXES: functionTaking(doubleFloating != 0.0); - char character = 'a'; + signed char character = 'a'; functionTaking(character); - // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast 'char' -> bool + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit cast 'signed char' -> bool // CHECK-FIXES: functionTaking(character != 0); int* pointer = nullptr; @@ -210,9 +210,9 @@ void implicitCastToBoolInSingleExpressio // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: implicit cast 'float' -> bool // CHECK-FIXES: bool boolComingFromFloat = floating != 0.0f; - char character = 'a'; + signed char character = 'a'; bool boolComingFromChar = character; - // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: implicit cast 'char' -> bool + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: implicit cast 'signed char' -> bool // CHECK-FIXES: bool boolComingFromChar = character != 0; int* pointer = nullptr; @@ -252,9 +252,9 @@ void implicitCastInNegationExpressions() // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: implicit cast 'float' -> bool // CHECK-FIXES: bool boolComingFromNegatedFloat = floating == 0.0f; - char character = 'a'; + signed char character = 'a'; bool boolComingFromNegatedChar = (! character); - // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: implicit cast 'char' -> bool + // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: implicit cast 'signed char' -> bool // CHECK-FIXES: bool boolComingFromNegatedChar = (character == 0); int* pointer = nullptr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251246 - Fix LWG#2244: basic_istream::seekg
Author: marshall Date: Sun Oct 25 13:31:51 2015 New Revision: 251246 URL: http://llvm.org/viewvc/llvm-project?rev=251246&view=rev Log: Fix LWG#2244: basic_istream::seekg Modified: libcxx/trunk/include/istream libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/istream URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=251246&r1=251245&r2=251246&view=diff == --- libcxx/trunk/include/istream (original) +++ libcxx/trunk/include/istream Sun Oct 25 13:31:51 2015 @@ -1407,6 +1407,7 @@ basic_istream<_CharT, _Traits>::seekg(of try { #endif // _LIBCPP_NO_EXCEPTIONS +this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { Modified: libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp?rev=251246&r1=251245&r2=251246&view=diff == --- libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp (original) +++ libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp Sun Oct 25 13:31:51 2015 @@ -71,4 +71,13 @@ int main() assert(is.fail()); assert(seekoff_called == 4); } +{ +testbuf sb(" 123456789"); +std::istream is(&sb); +is.setstate(std::ios_base::eofbit); +assert(is.eof()); +is.seekg(5, std::ios_base::beg); +assert(is.good()); +assert(!is.eof()); +} } Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251246&r1=251245&r2=251246&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 13:31:51 2015 @@ -159,7 +159,7 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2219";>2219INVOKE-ing a pointer to member with a reference_wrapper as the object expressionKona http://cplusplus.github.io/LWG/lwg-defects.html#2224";>2224Ambiguous status of access to non-live objectsKona http://cplusplus.github.io/LWG/lwg-defects.html#2234";>2234assert() should allow usage in constant expressionsKona - http://cplusplus.github.io/LWG/lwg-defects.html#2244";>2244Issue on basic_istream::seekgKonaPatch Ready + http://cplusplus.github.io/LWG/lwg-defects.html#2244";>2244Issue on basic_istream::seekgKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2250";>2250Follow-up On Library Issue 2207Kona http://cplusplus.github.io/LWG/lwg-defects.html#2259";>2259Issues in 17.6.5.5 rules for member functionsKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2273";>2273regex_match ambiguityKona ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay
mgehre updated this revision to Diff 38353. mgehre marked an inline comment as done. mgehre added a comment. Do not flag explicit casts http://reviews.llvm.org/D13640 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp Index: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp @@ -0,0 +1,41 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-array-to-pointer-decay %t +#include + +namespace gsl { +template +class array_view { +public: + template + array_view(U (&arr)[N]); +}; +} + +void pointerfun(int *p); +void arrayfun(int p[]); +void arrayviewfun(gsl::array_view &p); +size_t s(); + +void f() { + int a[5]; + pointerfun(a); + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay] + pointerfun((int *)a); // OK, explicit cast + arrayfun(a); + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not implicitly decay an array into a pointer + + pointerfun(a + s() - 10); // Convert to &a[g() - 10]; + // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not implicitly decay an array into a pointer + + gsl::array_view av(a); + arrayviewfun(av); // OK + + int i = a[0]; // OK + pointerfun(&a[0]); // OK + + for (auto &e : a) // OK, iteration internally decays array to pointer +e = 1; +} + +const char *g() { + return "clang"; // OK, decay string literal to pointer +} Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -4,6 +4,7 @@ .. toctree:: cert-setlongjmp cert-variadic-function-def + cppcoreguidelines-pro-bounds-array-to-pointer-decay cppcoreguidelines-pro-bounds-pointer-arithmetic cppcoreguidelines-pro-type-const-cast cppcoreguidelines-pro-type-reinterpret-cast Index: docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst === --- /dev/null +++ docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.rst @@ -0,0 +1,9 @@ +cppcoreguidelines-pro-bounds-array-to-pointer-decay +=== + +This check flags all array to pointer decays. + +Pointers should not be used as arrays. array_view is a bounds-checked, safe alternative to using pointers to access arrays. + +This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see +https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h === --- /dev/null +++ clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h @@ -0,0 +1,34 @@ +//===--- ProBoundsArrayToPointerDecayCheck.h - clang-tidy*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// This check flags all array to pointer decays +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-array-to-pointer-decay.html +class ProBoundsArrayToPointerDecayCheck : public ClangTidyCheck { +public: + ProBoundsArrayToPointerDecayCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H + Index: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp === --- /dev/null +++ clang-tidy/cppcoreguidelines/ProBoundsArrayToP
Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
mgehre added inline comments. Comment at: lib/Analysis/CFG.cpp:1949-1952 @@ +1948,6 @@ + } + if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) { +// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt +addAutomaticObjDtors(ScopePos, scopeBeginPos, C); + } + klimek wrote: > If the body is non-empty, but the return is not the last statement, won't > that still call addAutomaticObjDtors twice? Yes, if there are statements after a "return" (i.e. dead code), it will still call addAutomaticObjDtors twice, just like before this patch. I guess that this case is not to common, and would be flagged by other checks. http://reviews.llvm.org/D13973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14049: clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests
mgehre created this revision. mgehre added reviewers: alexfh, sbenza, bkramer, aaron.ballman. mgehre added a subscriber: cfe-commits. Adapt clang-tidy/add_new_check.py according to commit r251010 "Add %check_clang_tidy and %clang_tidy_diff" http://reviews.llvm.org/D14049 Files: clang-tidy/add_new_check.py Index: clang-tidy/add_new_check.py === --- clang-tidy/add_new_check.py +++ clang-tidy/add_new_check.py @@ -193,7 +193,7 @@ print('Creating %s...' % filename) with open(filename, 'wb') as f: f.write( -"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t +"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t // FIXME: Add something that triggers the check here. void f(); Index: clang-tidy/add_new_check.py === --- clang-tidy/add_new_check.py +++ clang-tidy/add_new_check.py @@ -193,7 +193,7 @@ print('Creating %s...' % filename) with open(filename, 'wb') as f: f.write( -"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t +"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t // FIXME: Add something that triggers the check here. void f(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
majnemer added a subscriber: majnemer. Comment at: lib/Analysis/CFG.cpp:1949 @@ +1948,3 @@ + } + if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) { +// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt mgehre wrote: > klimek wrote: > > If the body is non-empty, but the return is not the last statement, won't > > that still call addAutomaticObjDtors twice? > Yes, if there are statements after a "return" (i.e. dead code), it will still > call addAutomaticObjDtors twice, just like before this patch. > I guess that this case is not to common, and would be flagged by other checks. Please don't use `dyn_cast` if you just need to perform a type test, use `isa` instead. You need a space between `if` and `(`. http://reviews.llvm.org/D13973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251247 - Fix LWG#2127: Move-construction with raw_storage_iterator.
Author: marshall Date: Sun Oct 25 13:58:07 2015 New Revision: 251247 URL: http://llvm.org/viewvc/llvm-project?rev=251247&view=rev Log: Fix LWG#2127: Move-construction with raw_storage_iterator. Modified: libcxx/trunk/include/memory libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=251247&r1=251246&r2=251247&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Sun Oct 25 13:58:07 2015 @@ -1909,6 +1909,10 @@ public: _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) {::new(&*__x_) _Tp(__element); return *this;} +#if _LIBCPP_STD_VER >= 14 +_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element) +{::new(&*__x_) _Tp(_VSTD::move(__element)); return *this;} +#endif _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) {raw_storage_iterator __t(*this); ++__x_; return __t;} Modified: libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp?rev=251247&r1=251246&r2=251247&view=diff == --- libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp Sun Oct 25 13:58:07 2015 @@ -13,6 +13,8 @@ #include #include +#include + int A_constructed = 0; struct A @@ -29,16 +31,33 @@ public: int main() { -typedef std::aligned_storage<3*sizeof(A), std::alignment_of::value>::type +{ +typedef A S; +typedef std::aligned_storage<3*sizeof(S), std::alignment_of::value>::type Storage; Storage buffer; -std::raw_storage_iterator it((A*)&buffer); +std::raw_storage_iterator it((S*)&buffer); assert(A_constructed == 0); for (int i = 0; i < 3; ++i) { -*it++ = A(i+1); -A* ap = (A*)&buffer + i; +*it++ = S(i+1); +S* ap = (S*)&buffer + i; assert(*ap == i+1); assert(A_constructed == i+1); } +} +#if _LIBCPP_STD_VER >= 14 +{ +typedef MoveOnly S; +typedef std::aligned_storage<3*sizeof(S), std::alignment_of::value>::type +Storage; +Storage buffer; +std::raw_storage_iterator it((S*)&buffer); +S m{1}; +*it++ = std::move(m); +assert(m.get() == 0); // moved from +S *ap = (S*) &buffer; +assert(ap->get() == 1); // original value +} +#endif } Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251247&r1=251246&r2=251247&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 13:58:07 2015 @@ -152,7 +152,7 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2101";>2101Some transformation types can produce impossible typesKona http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which unexpected/terminate handler is called from the exception handling runtime?KonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2119";>2119Missing hash specializations for extended integer typesKona - http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction with raw_storage_iteratorKonaPatch Ready + http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction with raw_storage_iteratorKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2133";>2133Attitude to overloaded comma for iteratorsKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2156";>2156Unordered containers' reserve(n) reserves for n-1 elementsKona http://cplusplus.github.io/LWG/lwg-defects.html#2218";>2218Unclear how containers use allocator_traits::construct()Kona ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251250 - Add a test for LWG#2462: std::ios_base::failure is overspecified
Author: marshall Date: Sun Oct 25 14:20:14 2015 New Revision: 251250 URL: http://llvm.org/viewvc/llvm-project?rev=251250&view=rev Log: Add a test for LWG#2462: std::ios_base::failure is overspecified Modified: libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp Modified: libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp?rev=251250&r1=251249&r2=251250&view=diff == --- libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp (original) +++ libcxx/trunk/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp Sun Oct 25 14:20:14 2015 @@ -19,6 +19,9 @@ int main() { +// LWG2462 std::ios_base::failure is overspecified +static_assert((std::is_base_of::value), ""); + { std::string what_arg("io test message"); std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D10021: Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers
krememek added a subscriber: krememek. krememek accepted this revision. krememek added a reviewer: krememek. krememek added a comment. This revision is now accepted and ready to land. These all look good to me. http://reviews.llvm.org/D10021 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251252 - Add a test for LWG#2466: allocator_traits::max_size() default behavior is incorrect
Author: marshall Date: Sun Oct 25 14:34:04 2015 New Revision: 251252 URL: http://llvm.org/viewvc/llvm-project?rev=251252&view=rev Log: Add a test for LWG#2466: allocator_traits::max_size() default behavior is incorrect Modified: libcxx/trunk/include/memory libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=251252&r1=251251&r2=251252&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Sun Oct 25 14:34:04 2015 @@ -1678,7 +1678,7 @@ private: {return __a.max_size();} _LIBCPP_INLINE_VISIBILITY static size_type __max_size(false_type, const allocator_type&) -{return numeric_limits::max();} +{return numeric_limits::max() / sizeof(value_type);} _LIBCPP_INLINE_VISIBILITY static allocator_type Modified: libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp?rev=251252&r1=251251&r2=251252&view=diff == --- libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp Sun Oct 25 14:34:04 2015 @@ -45,12 +45,12 @@ int main() { A a; assert(std::allocator_traits >::max_size(a) == - std::numeric_limits::max()); + std::numeric_limits::max() / sizeof(int)); } { const A a = {}; assert(std::allocator_traits >::max_size(a) == - std::numeric_limits::max()); + std::numeric_limits::max() / sizeof(int)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE { Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251252&r1=251251&r2=251252&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 14:34:04 2015 @@ -172,7 +172,7 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s Remark should be deletedKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2447";>2447Allocators and volatile-qualified value typesKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2462";>2462std::ios_base::failure is overspecifiedKonaComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size() default behavior is incorrectKonaPatch Ready + http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size() default behavior is incorrectKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2469";>2469Wrong specification of Requires clause of operator[] for map and unordered_mapKona http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's relation to C FILE semanticsKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor is not assignableKonaPatch Ready @@ -184,7 +184,6 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2487";>2487bind() should be const-overloaded, not cv-overloadedKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn() should be noexceptKonaPatch Ready http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify requirements for compKonaComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2494";>2494[fund.ts.v2] ostream_joiner needs noexceptKona http://cplusplus.github.io/LWG/lwg-defects.html#2495";>2495There is no such thing as an Exception Safety elementKona
[libcxx] r251253 - Fix LWG#2476: scoped_allocator_adaptor is not assignable
Author: marshall Date: Sun Oct 25 14:52:47 2015 New Revision: 251253 URL: http://llvm.org/viewvc/llvm-project?rev=251253&view=rev Log: Fix LWG#2476: scoped_allocator_adaptor is not assignable Modified: libcxx/trunk/include/scoped_allocator Modified: libcxx/trunk/include/scoped_allocator URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/scoped_allocator?rev=251253&r1=251252&r2=251253&view=diff == --- libcxx/trunk/include/scoped_allocator (original) +++ libcxx/trunk/include/scoped_allocator Sun Oct 25 14:52:47 2015 @@ -58,6 +58,8 @@ public: template scoped_allocator_adaptor(const scoped_allocator_adaptor&& other) noexcept; +scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; +scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; ~scoped_allocator_adaptor(); inner_allocator_type& inner_allocator() noexcept; @@ -457,6 +459,8 @@ public: scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT : base(_VSTD::move(__other)) {} +// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; +// scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; // ~scoped_allocator_adaptor() = default; _LIBCPP_INLINE_VISIBILITY ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251254 - Add the tests for the last commit
Author: marshall Date: Sun Oct 25 14:53:29 2015 New Revision: 251254 URL: http://llvm.org/viewvc/llvm-project?rev=251254&view=rev Log: Add the tests for the last commit Added: libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp Added: libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp?rev=251254&view=auto == --- libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp Sun Oct 25 14:53:29 2015 @@ -0,0 +1,72 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor& other); + + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +{ +typedef std::scoped_allocator_adaptor> A; +A a1(A1(3)); +A aN; +A1::copy_called = false; +A1::move_called = false; +aN = a1; +assert(A1::copy_called == true); +assert(A1::move_called == false); +assert(aN == a1); +} +{ +typedef std::scoped_allocator_adaptor, A2> A; +A a1(A1(4), A2(5)); +A aN; +A1::copy_called = false; +A1::move_called = false; +A2::copy_called = false; +A2::move_called = false; +aN = a1; +assert(A1::copy_called == true); +assert(A1::move_called == false); +assert(A2::copy_called == true); +assert(A2::move_called == false); +assert(aN == a1); +} +{ +typedef std::scoped_allocator_adaptor, A2, A3> A; +A a1(A1(4), A2(5), A3(6)); +A aN; +A1::copy_called = false; +A1::move_called = false; +A2::copy_called = false; +A2::move_called = false; +A3::copy_called = false; +A3::move_called = false; +aN = a1; +assert(A1::copy_called == true); +assert(A1::move_called == false); +assert(A2::copy_called == true); +assert(A2::move_called == false); +assert(A3::copy_called == true); +assert(A3::move_called == false); +assert(aN == a1); +} +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} Added: libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp?rev=251254&view=auto == --- libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp Sun Oct 25 14:53:29 2015 @@ -0,0 +1,72 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&& other); + + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +{ +typedef std::scoped_allocator_adaptor> A; +A a1(A1(3)); +A aN; +A1::copy_called = false; +A1::move_called = false; +aN = std::move(a1); +assert(A1::copy_called == false); +assert(A1::move_called == true); +assert(aN == a1); +} +{ +typedef std::scoped_allocator_adaptor, A2> A; +A a1(A1(4), A2(5)); +A aN; +A1::copy_called = false; +A1::move_called = false; +A2::copy_called = false; +A2::move_called = false; +aN = std::move(a1); +assert(A1::copy_called == false); +assert(A1::move_called == true); +assert(A2::copy_called == false); +assert(A2::move_called == tru
[libcxx] r251257 - Fix LWG#2489: mem_fn() should be noexcept
Author: marshall Date: Sun Oct 25 15:12:16 2015 New Revision: 251257 URL: http://llvm.org/viewvc/llvm-project?rev=251257&view=rev Log: Fix LWG#2489: mem_fn() should be noexcept Modified: libcxx/trunk/include/functional libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/functional URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=251257&r1=251256&r2=251257&view=diff == --- libcxx/trunk/include/functional (original) +++ libcxx/trunk/include/functional Sun Oct 25 15:12:16 2015 @@ -1249,7 +1249,7 @@ private: type __f_; public: -_LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} +_LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} #ifndef _LIBCPP_HAS_NO_VARIADICS // invoke @@ -1364,7 +1364,7 @@ public: template inline _LIBCPP_INLINE_VISIBILITY __mem_fn<_Rp _Tp::*> -mem_fn(_Rp _Tp::* __pm) +mem_fn(_Rp _Tp::* __pm) _NOEXCEPT { return __mem_fn<_Rp _Tp::*>(__pm); } Modified: libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp?rev=251257&r1=251256&r2=251257&view=diff == --- libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp Sun Oct 25 15:12:16 2015 @@ -69,4 +69,7 @@ int main() test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); +#if __has_feature(cxx_noexcept) +static_assert((noexcept(std::mem_fn(&A::test0))), ""); // LWG#2489 +#endif } Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251257&r1=251256&r2=251257&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 15:12:16 2015 @@ -175,14 +175,14 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size() default behavior is incorrectKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2469";>2469Wrong specification of Requires clause of operator[] for map and unordered_mapKona http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's relation to C FILE semanticsKonaComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor is not assignableKonaPatch Ready + http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor is not assignableKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2477";>2477Inconsistency of wordings in std::vector::erase() and std::deque::erase()KonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2483";>2483throw_with_nested() should use is_finalKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2484";>2484rethrow_if_nested() is doubly unimplementableKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2485";>2485get() should be overloaded for const tuple&&Kona http://cplusplus.github.io/LWG/lwg-defects.html#2486";>2486mem_fn() should be required to use perfect forwardingKona http://cplusplus.github.io/LWG/lwg-defects.html#2487";>2487bind() should be const-overloaded, not cv-overloadedKonaComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn() should be noexceptKonaPatch Ready + http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn() should be noexceptKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify requirements for compKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2495";>2495There is no such thing as an Exception Safety elementKona ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r251258 - Mark LWG#2495 as complete. No code changes needed
Author: marshall Date: Sun Oct 25 15:12:58 2015 New Revision: 251258 URL: http://llvm.org/viewvc/llvm-project?rev=251258&view=rev Log: Mark LWG#2495 as complete. No code changes needed Modified: libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=251258&r1=251257&r2=251258&view=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Sun Oct 25 15:12:58 2015 @@ -184,7 +184,7 @@ http://cplusplus.github.io/LWG/lwg-defects.html#2487";>2487bind() should be const-overloaded, not cv-overloadedKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn() should be noexceptKonaComplete http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify requirements for compKonaComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2495";>2495There is no such thing as an Exception Safety elementKona + http://cplusplus.github.io/LWG/lwg-defects.html#2495";>2495There is no such thing as an Exception Safety elementKonaComplete
Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
klimek added inline comments. Comment at: lib/Analysis/CFG.cpp:1949-1952 @@ +1948,6 @@ + } + if(!C->body_empty() && !dyn_cast(*C->body_rbegin())) { +// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt +addAutomaticObjDtors(ScopePos, scopeBeginPos, C); + } + majnemer wrote: > mgehre wrote: > > klimek wrote: > > > If the body is non-empty, but the return is not the last statement, won't > > > that still call addAutomaticObjDtors twice? > > Yes, if there are statements after a "return" (i.e. dead code), it will > > still call addAutomaticObjDtors twice, just like before this patch. > > I guess that this case is not to common, and would be flagged by other > > checks. > Please don't use `dyn_cast` if you just need to perform a type test, use > `isa` instead. > You need a space between `if` and `(`. Is there a reason to not fix that while we're here (seems like a related issue into which somebody might run down the road otherwise?) http://reviews.llvm.org/D13973 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13973: CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmt
mgehre updated this revision to Diff 38359. mgehre added a comment. Update for review comments http://reviews.llvm.org/D13973 Files: lib/Analysis/CFG.cpp test/Analysis/no-unreachable-dtors.cpp Index: test/Analysis/no-unreachable-dtors.cpp === --- /dev/null +++ test/Analysis/no-unreachable-dtors.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.Stats -verify -Wno-unreachable-code %s + +struct S { + ~S(); +}; + +// the return at the end of an CompoundStmt does not lead to an unreachable block containing the dtors +void test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}} + S s; + return; +} Index: lib/Analysis/CFG.cpp === --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -1942,7 +1942,15 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C) { - addLocalScopeAndDtors(C); + LocalScope::const_iterator scopeBeginPos = ScopePos; + if (BuildOpts.AddImplicitDtors) { +addLocalScopeForStmt(C); + } + if (!C->body_empty() && !isa(*C->body_rbegin())) { +// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt +addAutomaticObjDtors(ScopePos, scopeBeginPos, C); + } + CFGBlock *LastBlock = Block; for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend(); Index: test/Analysis/no-unreachable-dtors.cpp === --- /dev/null +++ test/Analysis/no-unreachable-dtors.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.Stats -verify -Wno-unreachable-code %s + +struct S { + ~S(); +}; + +// the return at the end of an CompoundStmt does not lead to an unreachable block containing the dtors +void test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}} + S s; + return; +} Index: lib/Analysis/CFG.cpp === --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -1942,7 +1942,15 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C) { - addLocalScopeAndDtors(C); + LocalScope::const_iterator scopeBeginPos = ScopePos; + if (BuildOpts.AddImplicitDtors) { +addLocalScopeForStmt(C); + } + if (!C->body_empty() && !isa(*C->body_rbegin())) { +// If the body ends with a ReturnStmt, the dtors will be added in VisitReturnStmt +addAutomaticObjDtors(ScopePos, scopeBeginPos, C); + } + CFGBlock *LastBlock = Block; for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r251262 - [clang-tidy] Add return value for non-assert builds.
Author: djasper Date: Sun Oct 25 16:44:55 2015 New Revision: 251262 URL: http://llvm.org/viewvc/llvm-project?rev=251262&view=rev Log: [clang-tidy] Add return value for non-assert builds. Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251262&r1=251261&r2=251262&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Sun Oct 25 16:44:55 2015 @@ -84,6 +84,7 @@ getZeroLiteralToCompareWithForGivenType( default: assert(false && "Unexpected cast kind"); } + return ""; } bool isUnaryLogicalNotOperator(const Stmt *Statement) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r251265 - assert(false) -> llvm_unreachable.
Author: d0k Date: Sun Oct 25 17:03:00 2015 New Revision: 251265 URL: http://llvm.org/viewvc/llvm-project?rev=251265&view=rev Log: assert(false) -> llvm_unreachable. Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251265&r1=251264&r2=251265&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Sun Oct 25 17:03:00 2015 @@ -82,7 +82,7 @@ getZeroLiteralToCompareWithForGivenType( return Context.getLangOpts().CPlusPlus11 ? "nullptr" : "0"; default: -assert(false && "Unexpected cast kind"); +llvm_unreachable("Unexpected cast kind"); } return ""; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14052: clang-format: Format std::function template parameter consistently inside function
jeanphilippeD created this revision. jeanphilippeD added a reviewer: djasper. jeanphilippeD added a subscriber: cfe-commits. Herald added a subscriber: klimek. The function type declared in an std::function template parameter is confused for a cast: Currently: Pass: "std::function< void(int, int) > fct;", Spaces); Fail: "void inFunction() { std::function< void(int, int) > fct; }", Actual result "void inFunction() { std::function< void(int, int)> fct; }" (no space between ")>") Root cause: -Inside a function definition, Line.MustBeDeclaration is not true. -This allows the context IsExpression to be true. "Contexts.back().IsExpression = !ParametersOfFunctionType && !IsForOrCatch;" -which then allow the right parenthesis to be marked incorrectly as cast, and the left there after. "if (ParensAreType && !ParensCouldEndDecl && !IsSizeOfOrAlignOf && (Contexts.size() > 1 && Contexts[Contexts.size() - 2].IsExpression)) IsCast = true;" Because at the time of this marking, the angle bracket is not yet established as a template opener and closer, this fix address the issue by resetting the type to unknown for the parenthesis.(Unknown is the type the parenthesis hold in the case the line must be a declaration). It seems there should be a better alternative, but I am not sure where I should look. The tests are updated in 2 places as this incorrect deduction result in incorrect spacing before the angle bracket, but also inside the parenthesis if space is required there but not in cast. Run all the test in FormatTests project and spot checked clang format output for TokenAnnotator.cpp and FormatTest.cpp is the same before and after the patch. http://reviews.llvm.org/D14052 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -8398,8 +8398,6 @@ verifyFormat("call( x, y, z );", Spaces); verifyFormat("call();", Spaces); verifyFormat("std::function callback;", Spaces); - verifyFormat("void inFunction() { std::function fct; }", - Spaces); verifyFormat("while ( (bool)1 )\n" " continue;", Spaces); @@ -10635,9 +10633,6 @@ verifyFormat("f< int, float >();", Spaces); verifyFormat("template <> g() {}", Spaces); verifyFormat("template < std::vector< int > > f() {}", Spaces); - verifyFormat("std::function< void(int, int) > fct;", Spaces); - verifyFormat("void inFunction() { std::function< void(int, int) > fct; }", - Spaces); Spaces.Standard = FormatStyle::LS_Cpp03; Spaces.SpacesInAngles = true; Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -67,12 +67,6 @@ Left->MatchingParen = CurrentToken; CurrentToken->MatchingParen = Left; CurrentToken->Type = TT_TemplateCloser; -if (CurrentToken->Previous->is(TT_CastRParen) && -CurrentToken->Previous->MatchingParen) { - // Fix incorrect cast detection - CurrentToken->Previous->Type = TT_Unknown; - CurrentToken->Previous->MatchingParen->Type = TT_Unknown; -} next(); return true; } Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -8398,8 +8398,6 @@ verifyFormat("call( x, y, z );", Spaces); verifyFormat("call();", Spaces); verifyFormat("std::function callback;", Spaces); - verifyFormat("void inFunction() { std::function fct; }", - Spaces); verifyFormat("while ( (bool)1 )\n" " continue;", Spaces); @@ -10635,9 +10633,6 @@ verifyFormat("f< int, float >();", Spaces); verifyFormat("template <> g() {}", Spaces); verifyFormat("template < std::vector< int > > f() {}", Spaces); - verifyFormat("std::function< void(int, int) > fct;", Spaces); - verifyFormat("void inFunction() { std::function< void(int, int) > fct; }", - Spaces); Spaces.Standard = FormatStyle::LS_Cpp03; Spaces.SpacesInAngles = true; Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -67,12 +67,6 @@ Left->MatchingParen = CurrentToken; CurrentToken->MatchingParen = Left; CurrentToken->Type = TT_TemplateCloser; -if (CurrentToken->Previous->is(TT_CastRParen) && -CurrentToken->Previous->MatchingParen) { - // Fix incorrect cast detection - CurrentToken->Previous->Type = TT_Unknown; - CurrentToken->Previous->MatchingParen->Type = TT_Unknown; -} next();
Re: [PATCH] D13800: ccc-analyzer: Fix -isystem value passing
dcoughlin accepted this revision. dcoughlin added a comment. This revision is now accepted and ready to land. Looks good to me. I will commit. http://reviews.llvm.org/D13800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r251262 - [clang-tidy] Add return value for non-assert builds.
On Oct 25, 2015 2:47 PM, "Daniel Jasper via cfe-commits" < cfe-commits@lists.llvm.org> wrote: > > Author: djasper > Date: Sun Oct 25 16:44:55 2015 > New Revision: 251262 > > URL: http://llvm.org/viewvc/llvm-project?rev=251262&view=rev > Log: > [clang-tidy] Add return value for non-assert builds. > > Modified: > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > > Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251262&r1=251261&r2=251262&view=diff > == > --- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp (original) > +++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Sun Oct 25 16:44:55 2015 > @@ -84,6 +84,7 @@ getZeroLiteralToCompareWithForGivenType( >default: > assert(false && "Unexpected cast kind"); Prefer llvm_unreachable over assert(false) and the return shouldn't be needed. (He unreachable will amount to a call to a noreturn function in both asserts and non-asserts builds) >} > + return ""; > } > > bool isUnaryLogicalNotOperator(const Stmt *Statement) { > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r251265 - assert(false) -> llvm_unreachable.
On Oct 25, 2015 3:05 PM, "Benjamin Kramer via cfe-commits" < cfe-commits@lists.llvm.org> wrote: > > Author: d0k > Date: Sun Oct 25 17:03:00 2015 > New Revision: 251265 > > URL: http://llvm.org/viewvc/llvm-project?rev=251265&view=rev > Log: > assert(false) -> llvm_unreachable. > > Modified: > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > > Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251265&r1=251264&r2=251265&view=diff > == > --- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp (original) > +++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp Sun Oct 25 17:03:00 2015 > @@ -82,7 +82,7 @@ getZeroLiteralToCompareWithForGivenType( > return Context.getLangOpts().CPlusPlus11 ? "nullptr" : "0"; > >default: > -assert(false && "Unexpected cast kind"); > +llvm_unreachable("Unexpected cast kind"); >} >return ""; I think you can drop the return here, then? > } > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r251262 - [clang-tidy] Add return value for non-assert builds.
Ah, I see Benjamin got to this in 251265 On Oct 25, 2015 9:54 PM, "David Blaikie" wrote: > > On Oct 25, 2015 2:47 PM, "Daniel Jasper via cfe-commits" < > cfe-commits@lists.llvm.org> wrote: > > > > Author: djasper > > Date: Sun Oct 25 16:44:55 2015 > > New Revision: 251262 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=251262&view=rev > > Log: > > [clang-tidy] Add return value for non-assert builds. > > > > Modified: > > > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > > > > Modified: > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > > URL: > http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=251262&r1=251261&r2=251262&view=diff > > > == > > --- > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > (original) > > +++ > clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp > Sun Oct 25 16:44:55 2015 > > @@ -84,6 +84,7 @@ getZeroLiteralToCompareWithForGivenType( > >default: > > assert(false && "Unexpected cast kind"); > > Prefer llvm_unreachable over assert(false) and the return shouldn't be > needed. (He unreachable will amount to a call to a noreturn function in > both asserts and non-asserts builds) > > >} > > + return ""; > > } > > > > bool isUnaryLogicalNotOperator(const Stmt *Statement) { > > > > > > ___ > > cfe-commits mailing list > > cfe-commits@lists.llvm.org > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14049: clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in tests
LG. Thanks, totally missed this. On Sun, Oct 25, 2015, 7:46 PM Matthias Gehre via cfe-commits < cfe-commits@lists.llvm.org> wrote: > mgehre created this revision. > mgehre added reviewers: alexfh, sbenza, bkramer, aaron.ballman. > mgehre added a subscriber: cfe-commits. > > Adapt clang-tidy/add_new_check.py according to commit r251010 "Add > %check_clang_tidy and %clang_tidy_diff" > > http://reviews.llvm.org/D14049 > > Files: > clang-tidy/add_new_check.py > > Index: clang-tidy/add_new_check.py > === > --- clang-tidy/add_new_check.py > +++ clang-tidy/add_new_check.py > @@ -193,7 +193,7 @@ >print('Creating %s...' % filename) >with open(filename, 'wb') as f: > f.write( > -"""// RUN: %%python %%S/check_clang_tidy.py %%s %(check_name_dashes)s %%t > +"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t > > // FIXME: Add something that triggers the check here. > void f(); > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14052: clang-format: Format std::function template parameter consistently inside function
djasper added a comment. I'll take a look. I agree that there should be a better approach. Also, you seem to have created the inverse patch :-). http://reviews.llvm.org/D14052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.
ABataev marked an inline comment as done. ABataev added a comment. Hi Chandler, thanks for the review. In http://reviews.llvm.org/D13802#272053, @chandlerc wrote: > Some minor issues below. Also, Hans and Tom should have a glance at the > release bits of this, I don't know any of that stuff. > > Also, there are still some bugs with check-libomp. The immediate one I > noticed was that when i run it in a clean build with enough parallelism, it > fails to find the just-built clang binary. I suspect that the 'check-libomp' > CMake target is missing dependencies on all of the binaries used when running > the lit tests because it copied the libc++ CMake rules for it. While the > libc++ CMake rules are *mostly* a good proxy, the *testing* strategy for > libc++ is notably different here. In fact, libomp's testing is (IMO) quite a > bit *better* here, and uncovers a nasty missing dependency. > > The libc++ test suite tests libc++ with the *host* compiler, not the > just-built compiler. This has some advantages and disadvantages, but for a > library with close coupling to the compiler (such as compiler-rt or libomp) > it is inappropriate. Your libomp tests very correctly use the just-built > Clang, but the CMake needs to model this now. You can see in > projects/compiler-rt/test/CMakeLists.txt lines 19-33 how compiler-rt sets up > variables with these tools (clang, clang-headers, etc) which end up used on > line 99 of projects/compiler-rt/test/asan/CMakeLists.txt for example. > > I don't know what all tools you need (other than clang and probably > clang-headers), probably not as many as the sanitizers do, so I'll let you > put together a correct patch here. I've hacked around it locally to test > further. I created a separate patch for libomp, that fixes this issue. > I've also had one test fail, and then start passing for me on Linux (after > fixing the above). I haven't had it fail again, but I don't have a good way > of running tests repeatedly (see below, llvm-lit doesn't yet work). It might > be good to give the test suite a good 10 or 50 runs and see if anything > starts failing. I'll do that overnight and report back if so. Actually, these tests are written so, that they repeats about 1000 times to be sure that they are correct. But some of them might be sensible to system load. Comment at: configure:5953 @@ -5952,3 +5952,3 @@ else - withval="libgomp" + withval="libomp" fi chandlerc wrote: > You should be modifying the configure.ac file and regenerating this? Ok, done Comment at: utils/llvm-lit/llvm-lit.in:42-46 @@ -41,2 +41,7 @@ +openmp_obj_root = os.path.join(llvm_obj_root, 'projects', 'openmp') +if os.path.exists(openmp_obj_root): +builtin_parameters['openmp_site_basedir'] = \ +os.path.join(openmp_obj_root, 'runtime', 'test') + if __name__=='__main__': chandlerc wrote: > This change is independent of enabling anything; can you break it out? > > Also, manually patching this bit in order to test things didn't actually > allow me to use llvm-lit with libomp, so I don't think this is quite working > as intended yet. Ok, reverted it http://reviews.llvm.org/D13802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13802: [OPENMP] Make -fopenmp to turn on OpenMP support by default.
ABataev added reviewers: hans, tstellarAMD. ABataev updated this revision to Diff 38374. ABataev marked an inline comment as done. http://reviews.llvm.org/D13802 Files: autoconf/configure.ac configure docs/GettingStarted.rst docs/ReleaseProcess.rst utils/release/test-release.sh Index: autoconf/configure.ac === --- autoconf/configure.ac +++ autoconf/configure.ac @@ -1340,7 +1340,7 @@ AC_ARG_WITH(clang-default-openmp-runtime, AS_HELP_STRING([--with-clang-default-openmp-runtime], [The default OpenMP runtime for Clang.]),, -withval="libgomp") +withval="libomp") AC_DEFINE_UNQUOTED(CLANG_DEFAULT_OPENMP_RUNTIME,"$withval", [Default OpenMP runtime used by -fopenmp.]) Index: utils/release/test-release.sh === --- utils/release/test-release.sh +++ utils/release/test-release.sh @@ -34,7 +34,7 @@ do_libs="yes" do_libunwind="yes" do_test_suite="yes" -do_openmp="no" +do_openmp="yes" BuildDir="`pwd`" use_autoconf="no" ExtraConfigureFlags="" @@ -62,7 +62,7 @@ echo " -no-libs Disable check-out & build libcxx/libcxxabi/libunwind" echo " -no-libunwindDisable check-out & build libunwind" echo " -no-test-suite Disable check-out & build test-suite" -echo " -openmp Check out and build the OpenMP run-time (experimental)" +echo " -no-openmp Disable check-out & build libomp" } if [ `uname -s` = "Darwin" ]; then @@ -143,8 +143,8 @@ -no-test-suite ) do_test_suite="no" ;; --openmp ) -do_openmp="yes" +-no-openmp ) +do_openmp="no" ;; -help | --help | -h | --h | -\? ) usage @@ -293,6 +293,9 @@ if [ -d $BuildDir/compiler-rt.src ] && [ ! -h compiler-rt ]; then ln -s ../../compiler-rt.src compiler-rt fi +if [ -d $BuildDir/openmp.src ] && [ ! -h openmp ]; then +ln -s ../../openmp.src openmp +fi if [ -d $BuildDir/libcxx.src ] && [ ! -h libcxx ]; then ln -s ../../libcxx.src libcxx fi @@ -443,46 +446,6 @@ cd $cwd } -# Build and package the OpenMP run-time. This is still experimental and not -# meant for official testing in the release, but as a way for providing -# binaries as a convenience to those who want to try it out. -function build_OpenMP() { -cwd=`pwd` - -rm -rf $BuildDir/Phase3/openmp -rm -rf $BuildDir/Phase3/openmp.install -mkdir -p $BuildDir/Phase3/openmp -cd $BuildDir/Phase3/openmp -clang=$BuildDir/Phase3/Release/llvmCore-$Release-$RC.install/usr/local/bin/clang - -echo "#" cmake -DCMAKE_C_COMPILER=${clang} -DCMAKE_CXX_COMPILER=${clang}++ \ --DCMAKE_BUILD_TYPE=Release -DLIBOMP_MICRO_TESTS=on \ -$BuildDir/openmp.src/runtime -cmake -DCMAKE_C_COMPILER=${clang} -DCMAKE_CXX_COMPILER=${clang}++ \ --DCMAKE_BUILD_TYPE=Release -DLIBOMP_MICRO_TESTS=on \ -$BuildDir/openmp.src/runtime - -echo "# Building OpenMP run-time" -echo "# ${MAKE} -j $NumJobs VERBOSE=1" -${MAKE} -j $NumJobs VERBOSE=1 -echo "# ${MAKE} libomp-micro-tests VERBOSE=1" -${MAKE} libomp-micro-tests VERBOSE=1 -echo "# ${MAKE} install DESTDIR=$BuildDir/Phase3/openmp.install" -${MAKE} install DESTDIR=$BuildDir/Phase3/openmp.install - -OpenMPPackage=OpenMP-$Release -if [ $RC != "final" ]; then -OpenMPPackage=$OpenMPPackage-$RC -fi -OpenMPPackage=$OpenMPPackage-$Triple - -mv $BuildDir/Phase3/openmp.install/usr/local $BuildDir/$OpenMPPackage -cd $BuildDir -tar cvfJ $BuildDir/$OpenMPPackage.tar.xz $OpenMPPackage -mv $OpenMPPackage $BuildDir/Phase3/openmp.install/usr/local -cd $cwd -} - # Exit if any command fails # Note: pipefail is necessary for running build commands through # a pipe (i.e. it changes the output of ``false | tee /dev/null ; echo $?``) @@ -594,10 +557,6 @@ fi done -if [ $do_openmp = "yes" ]; then - build_OpenMP -fi - ) 2>&1 | tee $LogDir/testing.$Release-$RC.log package_release Index: docs/ReleaseProcess.rst === --- docs/ReleaseProcess.rst +++ docs/ReleaseProcess.rst @@ -53,7 +53,7 @@ --- This script will check-out, configure and compile LLVM+Clang (+ most add-ons, like ``compiler-rt``, -``libcxx`` and ``clang-extra-tools``) in three stages, and will test the final stage. +``libcxx``, ``libomp`` and ``clang-extra-tools``) in three stages, and will test the final stage. It'll have installed the final binaries on the Phase3/Releasei(+Asserts) directory, and that's the one you should use for the test-suite and other external tests. Index: docs/GettingStarted.rst === --- docs/GettingStarted.rst +++ docs/GettingStarted.rst @@ -55,6 +55,12