[PATCH] D15849: Fix several accidental DOS line endings in source files
dim created this revision. dim added a reviewer: joerg. dim added a subscriber: cfe-commits. There are a number of files in the tree which have been accidentally checked in with DOS line endings. Convert these to native line endings. There are also a few files which have DOS line endings on purpose, and I have set the svn:eol-style property to 'CRLF' on those. http://reviews.llvm.org/D15849 Files: test/CXX/lex/lex.literal/lex.string/p4.cpp test/CodeGen/avx512cdintrin.c test/CodeGen/pku.c test/CodeGen/x86_32-xsave.c test/CodeGen/x86_64-xsave.c test/Driver/mingw-libgcc.c test/Driver/mingw.cpp test/Parser/cxx1z-attributes.cpp test/Sema/attr-ownership.c test/Sema/warn-documentation-crlf.c test/SemaCXX/attr-cxx0x-fixit.cpp test/SemaCXX/attr-no-sanitize-address.cpp test/SemaCXX/attr-no-sanitize-memory.cpp test/SemaCXX/attr-no-sanitize-thread.cpp test/SemaCXX/cdtor-fn-try-block.cpp test/SemaCXX/cxx0x-noexcept-expression.cpp Index: test/SemaCXX/cxx0x-noexcept-expression.cpp === --- test/SemaCXX/cxx0x-noexcept-expression.cpp +++ test/SemaCXX/cxx0x-noexcept-expression.cpp @@ -1,19 +1,19 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -void f(); // expected-note {{possible target for call}} -void f(int); // expected-note {{possible target for call}} - -void g() { - bool b = noexcept(f); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} - bool b2 = noexcept(f(0)); -} - -struct S { - void g(); // expected-note {{possible target for call}} - void g(int); // expected-note {{possible target for call}} - - void h() { -bool b = noexcept(this->g); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}} -bool b2 = noexcept(this->g(0)); - } -}; +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +void f(); // expected-note {{possible target for call}} +void f(int); // expected-note {{possible target for call}} + +void g() { + bool b = noexcept(f); // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} + bool b2 = noexcept(f(0)); +} + +struct S { + void g(); // expected-note {{possible target for call}} + void g(int); // expected-note {{possible target for call}} + + void h() { +bool b = noexcept(this->g); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}} +bool b2 = noexcept(this->g(0)); + } +}; Index: test/SemaCXX/cdtor-fn-try-block.cpp === --- test/SemaCXX/cdtor-fn-try-block.cpp +++ test/SemaCXX/cdtor-fn-try-block.cpp @@ -1,97 +1,97 @@ -// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14 - -int FileScope; - -struct A { - int I; - void f(); - A() try { - } catch (...) { -I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}} -f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}} - -FileScope = 12; // ok -A a; -a.I = 12; // ok - } -}; - -struct B { - int I; - void f(); -}; - -struct C : B { - C() try { - } catch (...) { -I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}} -f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}} - } -}; - -struct D { - static int I; - static void f(); - - D() try { - } catch (...) { -I = 12; // ok -f(); // ok - } -}; -int D::I; - -struct E { - int I; - void f(); - static int J; - static void g(); - - ~E() try { - } catch (...) { -I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}} -f(); // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}} - -J = 12; // ok -g(); // ok - } -}; -int E::J; - -struct F { - static int I; - static void f(); -}; -int F::I; - -struct G : F { - G() try { - } catch (...) { -I = 12; // ok -f(); // ok - } -}; - -struct H { - struct A {}; - enum { -E - }; - - H() try { - } catch (...) { -H::A a; // ok -int I = E; // ok - } -}; - -struct I { - int J; - - I() { -try { // not a function-try-block -} catch (...) { - J = 12; // ok - } - } +// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14 + +int FileScope; + +struct A { + int I; + void f(); + A() try { + } catch (...) { +I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}} +f(); // expected-warning {{cannot refer to a non-static membe
Re: [PATCH] D15849: Fix several accidental DOS line endings in source files
aaron.ballman added a subscriber: aaron.ballman. aaron.ballman accepted this revision. aaron.ballman added a reviewer: aaron.ballman. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you for this! http://reviews.llvm.org/D15849 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256704 - Fix several accidental DOS line endings in source files
Author: dim Date: Sun Jan 3 09:55:40 2016 New Revision: 256704 URL: http://llvm.org/viewvc/llvm-project?rev=256704&view=rev Log: Fix several accidental DOS line endings in source files Summary: There are a number of files in the tree which have been accidentally checked in with DOS line endings. Convert these to native line endings. There are also a few files which have DOS line endings on purpose, and I have set the svn:eol-style property to 'CRLF' on those. Reviewers: joerg, aaron.ballman Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D15849 Modified: cfe/trunk/test/CXX/lex/lex.literal/lex.string/p4.cpp cfe/trunk/test/CodeGen/avx512cdintrin.c cfe/trunk/test/CodeGen/pku.c cfe/trunk/test/CodeGen/x86_32-xsave.c cfe/trunk/test/CodeGen/x86_64-xsave.c cfe/trunk/test/Driver/mingw-libgcc.c cfe/trunk/test/Driver/mingw.cpp cfe/trunk/test/Parser/cxx1z-attributes.cpp cfe/trunk/test/Sema/attr-ownership.c cfe/trunk/test/Sema/warn-documentation-crlf.c cfe/trunk/test/SemaCXX/attr-cxx0x-fixit.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp cfe/trunk/test/SemaCXX/cdtor-fn-try-block.cpp cfe/trunk/test/SemaCXX/cxx0x-noexcept-expression.cpp Modified: cfe/trunk/test/CXX/lex/lex.literal/lex.string/p4.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/lex/lex.literal/lex.string/p4.cpp?rev=256704&r1=256703&r2=256704&view=diff == --- cfe/trunk/test/CXX/lex/lex.literal/lex.string/p4.cpp (original) +++ cfe/trunk/test/CXX/lex/lex.literal/lex.string/p4.cpp Sun Jan 3 09:55:40 2016 @@ -1,17 +1,17 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// expected-no-diagnostics - -// NOTE: This file intentionally uses DOS-style line endings to test -// that we don't propagate them into string literals as per [lex.string]p4. - -constexpr const char* p = R"(a\ -b -c)"; - -static_assert(p[0] == 'a', ""); -static_assert(p[1] == '\\', ""); -static_assert(p[2] == '\n', ""); -static_assert(p[3] == 'b', ""); -static_assert(p[4] == '\n', ""); -static_assert(p[5] == 'c', ""); -static_assert(p[6] == '\0', ""); +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s +// expected-no-diagnostics + +// NOTE: This file intentionally uses DOS-style line endings to test +// that we don't propagate them into string literals as per [lex.string]p4. + +constexpr const char* p = R"(a\ +b +c)"; + +static_assert(p[0] == 'a', ""); +static_assert(p[1] == '\\', ""); +static_assert(p[2] == '\n', ""); +static_assert(p[3] == 'b', ""); +static_assert(p[4] == '\n', ""); +static_assert(p[5] == 'c', ""); +static_assert(p[6] == '\0', ""); Modified: cfe/trunk/test/CodeGen/avx512cdintrin.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512cdintrin.c?rev=256704&r1=256703&r2=256704&view=diff == --- cfe/trunk/test/CodeGen/avx512cdintrin.c (original) +++ cfe/trunk/test/CodeGen/avx512cdintrin.c Sun Jan 3 09:55:40 2016 @@ -1,67 +1,67 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -target-feature +avx512cd -emit-llvm -o - -Werror | FileCheck %s - -// Don't include mm_malloc.h, it's system specific. -#define __MM_MALLOC_H - -#include - -__m512i test_mm512_conflict_epi64(__m512i __A) { - // CHECK-LABEL: @test_mm512_conflict_epi64 - // CHECK: @llvm.x86.avx512.mask.conflict.q.512 - return _mm512_conflict_epi64(__A); -} -__m512i test_mm512_mask_conflict_epi64(__m512i __W, __mmask8 __U, __m512i __A) { - // CHECK-LABEL: @test_mm512_mask_conflict_epi64 - // CHECK: @llvm.x86.avx512.mask.conflict.q.512 - return _mm512_mask_conflict_epi64(__W,__U,__A); -} -__m512i test_mm512_maskz_conflict_epi64(__mmask8 __U, __m512i __A) { - // CHECK-LABEL: @test_mm512_maskz_conflict_epi64 - // CHECK: @llvm.x86.avx512.mask.conflict.q.512 - return _mm512_maskz_conflict_epi64(__U,__A); -} -__m512i test_mm512_conflict_epi32(__m512i __A) { - // CHECK-LABEL: @test_mm512_conflict_epi32 - // CHECK: @llvm.x86.avx512.mask.conflict.d.512 - return _mm512_conflict_epi32(__A); -} -__m512i test_mm512_mask_conflict_epi32(__m512i __W, __mmask16 __U, __m512i __A) { - // CHECK-LABEL: @test_mm512_mask_conflict_epi32 - // CHECK: @llvm.x86.avx512.mask.conflict.d.512 - return _mm512_mask_conflict_epi32(__W,__U,__A); -} -__m512i test_mm512_maskz_conflict_epi32(__mmask16 __U, __m512i __A) { - // CHECK-LABEL: @test_mm512_maskz_conflict_epi32 - // CHECK: @llvm.x86.avx512.mask.conflict.d.512 - return _mm512_maskz_conflict_epi32(__U,__A); -} -__m512i test_mm512_lzcnt_epi32(__m512i __A) { - // CHECK-LABEL: @test_mm512_lzcnt_epi32 - // CHECK: @llvm.x86.avx512.mask.lzcnt.d.512 - return _mm512_lzcnt_epi32(__A); -} -__m512i test_mm512_mask_lzcnt_epi32(__m512i __W, __mmask16 __U, __m
Re: [PATCH] D15647: [X86] Fix stack alignment for MCU target (Clang part)
rjmccall added a comment. LGTM, thanks. http://reviews.llvm.org/D15647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86
rjmccall added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:259 @@ +258,3 @@ +def err_anyx86_interrupt_attribute : Error< + "interrupt service routine %select{must have 'void' return value|" + "can only have a pointer argument and an optional integer argument|" aaron.ballman wrote: > I still dislike "interrupt service routine" -- there is no interrupt service > routine involved here because the attribute does not apply to that function > to make it one. The issue is with the attribute's requirements on the > function type, so I still prefer "x86 |x86-64'interrupt' attribute only > applies to functions that...". Also, "have 'void' return value" is still > incorrect -- they need to have a void return type. Something like: > > "%select{x86|x86-64}0 'interrupt' attribute only applies to functions that > have %select{a 'void' return type|only a pointer parameter optionally > followed by an integer parameter|a pointer as the first parameter|a %2 type > as the second parameter}1" > > (I also changed argument to parameter because arguments are on the caller > side, and parameters are on the function declaration side.) It's fine to call it an interrupt service routine because the user intent to declare it as one is obvious. It's still an ISR, it's just an ill-formed ISR. It would even make some amount of sense to actually apply the attribute in the AST and just mark the declaration ill-formed. http://reviews.llvm.org/D15709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86
aaron.ballman added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:259 @@ +258,3 @@ +def err_anyx86_interrupt_attribute : Error< + "interrupt service routine %select{must have 'void' return value|" + "can only have a pointer argument and an optional integer argument|" rjmccall wrote: > aaron.ballman wrote: > > I still dislike "interrupt service routine" -- there is no interrupt > > service routine involved here because the attribute does not apply to that > > function to make it one. The issue is with the attribute's requirements on > > the function type, so I still prefer "x86 |x86-64'interrupt' attribute only > > applies to functions that...". Also, "have 'void' return value" is still > > incorrect -- they need to have a void return type. Something like: > > > > "%select{x86|x86-64}0 'interrupt' attribute only applies to functions that > > have %select{a 'void' return type|only a pointer parameter optionally > > followed by an integer parameter|a pointer as the first parameter|a %2 type > > as the second parameter}1" > > > > (I also changed argument to parameter because arguments are on the caller > > side, and parameters are on the function declaration side.) > It's fine to call it an interrupt service routine because the user intent to > declare it as one is obvious. It's still an ISR, it's just an ill-formed > ISR. It would even make some amount of sense to actually apply the attribute > in the AST and just mark the declaration ill-formed. That would make this diagnostic inconsistent with the other interrupt attribute diagnostics used for other targets, and I don't think it adds any value to do so. I don't think it makes sense to have the attribute mark the declaration as ill-formed either -- attributes are usually side information to the declaration (otherwise we implement them as keywords). http://reviews.llvm.org/D15709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86
rjmccall added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:259 @@ +258,3 @@ +def err_anyx86_interrupt_attribute : Error< + "interrupt service routine %select{must have 'void' return value|" + "can only have a pointer argument and an optional integer argument|" aaron.ballman wrote: > rjmccall wrote: > > aaron.ballman wrote: > > > I still dislike "interrupt service routine" -- there is no interrupt > > > service routine involved here because the attribute does not apply to > > > that function to make it one. The issue is with the attribute's > > > requirements on the function type, so I still prefer "x86 > > > |x86-64'interrupt' attribute only applies to functions that...". Also, > > > "have 'void' return value" is still incorrect -- they need to have a void > > > return type. Something like: > > > > > > "%select{x86|x86-64}0 'interrupt' attribute only applies to functions > > > that have %select{a 'void' return type|only a pointer parameter > > > optionally followed by an integer parameter|a pointer as the first > > > parameter|a %2 type as the second parameter}1" > > > > > > (I also changed argument to parameter because arguments are on the caller > > > side, and parameters are on the function declaration side.) > > It's fine to call it an interrupt service routine because the user intent > > to declare it as one is obvious. It's still an ISR, it's just an > > ill-formed ISR. It would even make some amount of sense to actually apply > > the attribute in the AST and just mark the declaration ill-formed. > That would make this diagnostic inconsistent with the other interrupt > attribute diagnostics used for other targets, and I don't think it adds any > value to do so. I don't think it makes sense to have the attribute mark the > declaration as ill-formed either -- attributes are usually side information > to the declaration (otherwise we implement them as keywords). If it's more consistent to use the other wording, that's fine. This attribute is quite definitely not side information to the declaration, however, as it significantly changes its language and ABI rules; and that's true of many other attributes. Attributes are very frequently used in lieu of keywords as an open-ended language extension mechanism. http://reviews.llvm.org/D15709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15709: [X86] Support 'interrupt' attribute for x86
aaron.ballman added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:259 @@ +258,3 @@ +def err_anyx86_interrupt_attribute : Error< + "interrupt service routine %select{must have 'void' return value|" + "can only have a pointer argument and an optional integer argument|" rjmccall wrote: > aaron.ballman wrote: > > rjmccall wrote: > > > aaron.ballman wrote: > > > > I still dislike "interrupt service routine" -- there is no interrupt > > > > service routine involved here because the attribute does not apply to > > > > that function to make it one. The issue is with the attribute's > > > > requirements on the function type, so I still prefer "x86 > > > > |x86-64'interrupt' attribute only applies to functions that...". Also, > > > > "have 'void' return value" is still incorrect -- they need to have a > > > > void return type. Something like: > > > > > > > > "%select{x86|x86-64}0 'interrupt' attribute only applies to functions > > > > that have %select{a 'void' return type|only a pointer parameter > > > > optionally followed by an integer parameter|a pointer as the first > > > > parameter|a %2 type as the second parameter}1" > > > > > > > > (I also changed argument to parameter because arguments are on the > > > > caller side, and parameters are on the function declaration side.) > > > It's fine to call it an interrupt service routine because the user intent > > > to declare it as one is obvious. It's still an ISR, it's just an > > > ill-formed ISR. It would even make some amount of sense to actually > > > apply the attribute in the AST and just mark the declaration ill-formed. > > That would make this diagnostic inconsistent with the other interrupt > > attribute diagnostics used for other targets, and I don't think it adds any > > value to do so. I don't think it makes sense to have the attribute mark the > > declaration as ill-formed either -- attributes are usually side information > > to the declaration (otherwise we implement them as keywords). > If it's more consistent to use the other wording, that's fine. This > attribute is quite definitely not side information to the declaration, > however, as it significantly changes its language and ABI rules; and that's > true of many other attributes. Attributes are very frequently used in lieu > of keywords as an open-ended language extension mechanism. That's true, we tend to be more lax with attributes than the standards committees are. My biggest concern is with consistency, but I don't really care which direction we go. It fits my mental model slightly better to complain about the attribute when the attribute mismatches with the declaration, because the declaration can stand on its own. However, since this is an error and not a warning where we drop the attribute, I can see the logic behind diagnosing that the declaration is wrong. The other attributes are inconsistent in this case. ARM and MIPS warns and drops the attribute, MSP430 errs. http://reviews.llvm.org/D15709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256714 - [PGO] Cleanup: Use covmap header definition in the template file
Author: davidxl Date: Sun Jan 3 13:25:54 2016 New Revision: 256714 URL: http://llvm.org/viewvc/llvm-project?rev=256714&view=rev Log: [PGO] Cleanup: Use covmap header definition in the template file This is one last remaining instrumentatation related structure that needs to be migrate to use the centralized template definition. With this change, instrumentation code related to coverage module header will be kept in sync with the coverage mapping reader. The remaining code which makes implicit assumption about covmap control structure layout in the the lowering pass will cleaned up in a different patch. This patch is not intended to have no functional change. Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp cfe/trunk/test/CoverageMapping/ir.c Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=256714&r1=256713&r2=256714&view=diff == --- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original) +++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Sun Jan 3 13:25:54 2016 @@ -993,24 +993,30 @@ void CoverageMappingModuleGen::emit() { llvm::ArrayType::get(FunctionRecordTy, FunctionRecords.size()); auto RecordsVal = llvm::ConstantArray::get(RecordsTy, FunctionRecords); + llvm::Type *CovDataHeaderTypes[] = { +#define COVMAP_HEADER(Type, LLVMType, Name, Init) LLVMType, +#include "llvm/ProfileData/InstrProfData.inc" + }; + auto CovDataHeaderTy = + llvm::StructType::get(Ctx, makeArrayRef(CovDataHeaderTypes)); + llvm::Constant *CovDataHeaderVals[] = { +#define COVMAP_HEADER(Type, LLVMType, Name, Init) Init, +#include "llvm/ProfileData/InstrProfData.inc" + }; + auto CovDataHeaderVal = llvm::ConstantStruct::get( + CovDataHeaderTy, makeArrayRef(CovDataHeaderVals)); + // Create the coverage data record - llvm::Type *CovDataTypes[] = {Int32Ty, Int32Ty, -Int32Ty, Int32Ty, -RecordsTy, FilenamesAndMappingsVal->getType()}; + llvm::Type *CovDataTypes[] = {CovDataHeaderTy, RecordsTy, +FilenamesAndMappingsVal->getType()}; auto CovDataTy = llvm::StructType::get(Ctx, makeArrayRef(CovDataTypes)); - llvm::Constant *TUDataVals[] = { - llvm::ConstantInt::get(Int32Ty, FunctionRecords.size()), - llvm::ConstantInt::get(Int32Ty, FilenamesSize), - llvm::ConstantInt::get(Int32Ty, CoverageMappingSize), - llvm::ConstantInt::get(Int32Ty, - /*Version=*/CoverageMappingVersion1), - RecordsVal, FilenamesAndMappingsVal}; + llvm::Constant *TUDataVals[] = {CovDataHeaderVal, RecordsVal, + FilenamesAndMappingsVal}; auto CovDataVal = llvm::ConstantStruct::get(CovDataTy, makeArrayRef(TUDataVals)); - auto CovData = new llvm::GlobalVariable(CGM.getModule(), CovDataTy, true, - llvm::GlobalValue::InternalLinkage, - CovDataVal, - llvm::getCoverageMappingVarName()); + auto CovData = new llvm::GlobalVariable( + CGM.getModule(), CovDataTy, true, llvm::GlobalValue::InternalLinkage, + CovDataVal, llvm::getCoverageMappingVarName()); CovData->setSection(getCoverageSection(CGM)); CovData->setAlignment(8); Modified: cfe/trunk/test/CoverageMapping/ir.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/ir.c?rev=256714&r1=256713&r2=256714&view=diff == --- cfe/trunk/test/CoverageMapping/ir.c (original) +++ cfe/trunk/test/CoverageMapping/ir.c Sun Jan 3 13:25:54 2016 @@ -9,4 +9,4 @@ int main(void) { return 0; } -// CHECK: @__llvm_coverage_mapping = internal constant { i32, i32, i32, i32, [2 x <{ i8*, i32, i32, i64 }>], [{{[0-9]+}} x i8] } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0, [2 x <{ i8*, i32, i32, i64 }>] [<{ i8*, i32, i32, i64 }> <{ i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i32 3, i32 9, i64 {{[0-9]+}} }>, <{ i8*, i32, i32, i64 }> <{ i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_main, i32 0, i32 0), i32 4, i32 9, i64 {{[0-9]+}} }>] +// CHECK: @__llvm_coverage_mapping = internal constant { { i32, i32, i32, i32 }, [2 x <{ i8*, i32, i32, i64 }>], [{{[0-9]+}} x i8] } { { i32, i32, i32, i32 } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0 }, [2 x <{ i8*, i32, i32, i64 }>] [<{ i8*, i32, i32, i64 }> <{ i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i32 3, i32 9, i64 {{[0-9]+}} }>, <{ i8*, i32, i32, i64 }> <{ i8* getelementptr inbounds ([4 x i8], [4 x i8]* @__profn_main, i32 0, i32 0), i32 4, i32 9, i64 {{[0-9]+}} }>] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://
r256717 - Use std::is_sorted instead of a manual loop. NFC
Author: ctopper Date: Sun Jan 3 13:43:20 2016 New Revision: 256717 URL: http://llvm.org/viewvc/llvm-project?rev=256717&view=rev Log: Use std::is_sorted instead of a manual loop. NFC Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=256717&r1=256716&r2=256717&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Jan 3 13:43:20 2016 @@ -4770,11 +4770,7 @@ llvm::Constant *IvarLayoutBuilder::build // This isn't a stable sort, but our algorithm should handle it fine. llvm::array_pod_sort(IvarsInfo.begin(), IvarsInfo.end()); } else { -#ifndef NDEBUG -for (unsigned i = 1; i != IvarsInfo.size(); ++i) { - assert(IvarsInfo[i - 1].Offset <= IvarsInfo[i].Offset); -} -#endif +assert(std::is_sorted(IvarsInfo.begin(), IvarsInfo.end())); } assert(IvarsInfo.back().Offset < InstanceEnd); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256718 - ArrayRef-ize a function. NFC
Author: ctopper Date: Sun Jan 3 13:43:23 2016 New Revision: 256718 URL: http://llvm.org/viewvc/llvm-project?rev=256718&view=rev Log: ArrayRef-ize a function. NFC Modified: cfe/trunk/lib/AST/ASTContext.cpp Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=256718&r1=256717&r2=256718&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Sun Jan 3 13:43:23 2016 @@ -3658,14 +3658,13 @@ static int CmpProtocolNames(ObjCProtocol return DeclarationName::compare((*LHS)->getDeclName(), (*RHS)->getDeclName()); } -static bool areSortedAndUniqued(ObjCProtocolDecl * const *Protocols, -unsigned NumProtocols) { - if (NumProtocols == 0) return true; +static bool areSortedAndUniqued(ArrayRef Protocols) { + if (Protocols.empty()) return true; if (Protocols[0]->getCanonicalDecl() != Protocols[0]) return false; - for (unsigned i = 1; i != NumProtocols; ++i) + for (unsigned i = 1; i != Protocols.size(); ++i) if (CmpProtocolNames(&Protocols[i - 1], &Protocols[i]) >= 0 || Protocols[i]->getCanonicalDecl() != Protocols[i]) return false; @@ -3730,8 +3729,7 @@ QualType ASTContext::getObjCObjectType( [&](QualType type) { return type.isCanonical(); }); - bool protocolsSorted = areSortedAndUniqued(protocols.data(), - protocols.size()); + bool protocolsSorted = areSortedAndUniqued(protocols); if (!typeArgsAreCanonical || !protocolsSorted || !baseType.isCanonical()) { // Determine the canonical type arguments. ArrayRef canonTypeArgs; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r244070 - [CMake] First pass at adding support for clang bootstrap builds to CMake
Hey Chris, I just noticed that this option is only available when you build Clang as a standalone project, as opposed to building all of LLVM. Was that intentional? Is there any plan to support this in more normal whole-LLVM builds? It seems substantially more useful for stuff like picking up miscompiles... -Chandler On Wed, Aug 5, 2015 at 10:39 AM Chris Bieneman wrote: > Author: cbieneman > Date: Wed Aug 5 12:38:12 2015 > New Revision: 244070 > > URL: http://llvm.org/viewvc/llvm-project?rev=244070&view=rev > Log: > [CMake] First pass at adding support for clang bootstrap builds to CMake > > Summary: > This patch adds a new CLANG_ENABLE_BOOTSTRAP option to CMake which adds > targets for building a stage2 bootstrap compiler. The targets are: > > bootstrap-configure > bootstrap-build > bootstrap (same as bootstrap-configure and bootstrap-build) > bootstrap-install > bootstrap-check-llvm > bootstrap-check-clang > bootstrap-check-all > > If you are using 3.3.20150708 or greater it utilizes the ninja > USES_TERMINAL_* settings on the external project so that the output is > properly buffered. > > Reviewers: bogner, chandlerc > > Subscribers: filcab, cfe-commits > > Differential Revision: http://reviews.llvm.org/D11743 > > Modified: > cfe/trunk/CMakeLists.txt > > Modified: cfe/trunk/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=244070&r1=244069&r2=244070&view=diff > > == > --- cfe/trunk/CMakeLists.txt (original) > +++ cfe/trunk/CMakeLists.txt Wed Aug 5 12:38:12 2015 > @@ -96,6 +96,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR > >option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN > "Set to ON to force using an old, unsupported host toolchain." OFF) > + option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF) > >include(AddLLVM) >include(TableGen) > @@ -551,3 +552,76 @@ if (CLANG_BUILT_STANDALONE) > ${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake > COPYONLY) > endif () > + > +if (CLANG_ENABLE_BOOTSTRAP) > + include(ExternalProject) > + > + if(CMAKE_VERSION VERSION_LESS 3.3.20150708) > +set(cmake_3_4_USES_TERMINAL_OPTIONS) > + else() > +set(cmake_3_4_USES_TERMINAL_OPTIONS > + USES_TERMINAL_CONFIGURE 1 > + USES_TERMINAL_BUILD 1 > + USES_TERMINAL_INSTALL 1 > + ) > + endif() > + > + set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-stamps/) > + set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-bins/) > + > + add_custom_target(bootstrap-clear > +DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared > +) > + add_custom_command( > +OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared > +DEPENDS clang > +COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR} > +COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR} > +COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR} > +COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR} > +COMMAND ${CMAKE_COMMAND} -E touch > ${CMAKE_CURRENT_BINARY_DIR}/bootstrap-cleared > +COMMENT "Clobberring bootstrap build and stamp directories" > +) > + > + ExternalProject_Add(bootstrap > +DEPENDS clang > +PREFIX bootstrap > +SOURCE_DIR ${CMAKE_SOURCE_DIR} > +STAMP_DIR ${STAMP_DIR} > +BINARY_DIR ${BINARY_DIR} > +CMAKE_ARGS > +# We shouldn't need to set this here, but INSTALL_DIR > doesn't > +# seem to work, so instead I'm passing this through > +-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} > +${CLANG_BOOTSTRAP_CMAKE_ARGS} > +-DCMAKE_CXX_COMPILER=${CMAKE_BINARY_DIR}/bin/clang++ > +-DCMAKE_C_COMPILER=${CMAKE_BINARY_DIR}/bin/clang > +INSTALL_COMMAND "" > +STEP_TARGETS configure build > +${cmake_3_4_USES_TERMINAL_OPTIONS} > +) > + > + # exclude really-install from main target > + set_target_properties(bootstrap PROPERTIES > _EP_really-install_EXCLUDE_FROM_MAIN On) > + ExternalProject_Add_Step(bootstrap really-install > +COMMAND ${CMAKE_COMMAND} --build --target install > +COMMENT "Performing install step for 'bootstrap'" > +DEPENDEES build > + ) > + ExternalProject_Add_StepTargets(bootstrap really-install) > + add_custom_target(bootstrap-install DEPENDS bootstrap-really-install) > + > + > + set(ADDITIONAL_TARGETS_TO_ADD check-llvm check-clang check-all) > + foreach(target ${ADDITIONAL_TARGETS_TO_ADD}) > +# exclude from main target > +set_target_properties(bootstrap PROPERTIES > _EP_${target}_EXCLUDE_FROM_MAIN On) > + > +ExternalProject_Add_Step(bootstrap ${target} > + COMMAND ${CMAKE_COMMAND} --build --target ${target} > + COMMENT "Performing ${target} for 'bootstrap'" > + DEPENDEES configure > +) > +ExternalProject_Add_StepTargets(bootstrap ${target}) > + endforeach() > +endif() > > > ___ > cfe-co
[PATCH] D15853: [PGO]: Simplify coverage data lowering code
davidxl created this revision. davidxl added a reviewer: vsk. davidxl added a subscriber: cfe-commits. The names referenced by the coverage data may be associated with functions that are never emitted by Clang. That means those PGO names won't be materialized into the __llvm_prf_names section during instr-prof lowering. To make sure those names are emitted, the lowering pass will need to go through the coverage map global variable and check the referenced names. The lowering code makes assumption about the layout of the coverage map and function record data which is error prone. Besides, in the near future, when name compression is implemented, the name references won't be available from the coverage data anymore. In this patch, the referenced names are explicitly recorded in an internal global var and passed to the middle end. This simplifies the lowering code and also make it possible to do name compression. This is part-2 of the patch. Part-1 is http://reviews.llvm.org/D15852 http://reviews.llvm.org/D15853 Files: lib/CodeGen/CoverageMappingGen.cpp lib/CodeGen/CoverageMappingGen.h Index: lib/CodeGen/CoverageMappingGen.h === --- lib/CodeGen/CoverageMappingGen.h +++ lib/CodeGen/CoverageMappingGen.h @@ -54,6 +54,7 @@ CoverageSourceInfo &SourceInfo; llvm::SmallDenseMap FileEntries; std::vector FunctionRecords; + std::vector FunctionNames; llvm::StructType *FunctionRecordTy; std::string CoverageMappings; Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -929,6 +929,8 @@ }; FunctionRecords.push_back(llvm::ConstantStruct::get( FunctionRecordTy, makeArrayRef(FunctionRecordVals))); + FunctionNames.push_back( + llvm::ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx))); CoverageMappings += CoverageMapping; if (CGM.getCodeGenOpts().DumpCoverageMapping) { @@ -1023,6 +1025,15 @@ // Make sure the data doesn't get deleted. CGM.addUsedGlobal(CovData); + // Create the deferred function records array + auto NamesArrTy = + llvm::ArrayType::get(llvm::Type::getInt8PtrTy(Ctx), FunctionNames.size()); + auto NamesArrVal = llvm::ConstantArray::get(NamesArrTy, FunctionNames); + // This variable will *NOT* be emitted to the object file. It is used + // to pass the list of names referenced to codegen. + new llvm::GlobalVariable(CGM.getModule(), NamesArrTy, true, + llvm::GlobalValue::InternalLinkage, NamesArrVal, + llvm::getCoverageNamesVarName()); } unsigned CoverageMappingModuleGen::getFileID(const FileEntry *File) { Index: lib/CodeGen/CoverageMappingGen.h === --- lib/CodeGen/CoverageMappingGen.h +++ lib/CodeGen/CoverageMappingGen.h @@ -54,6 +54,7 @@ CoverageSourceInfo &SourceInfo; llvm::SmallDenseMap FileEntries; std::vector FunctionRecords; + std::vector FunctionNames; llvm::StructType *FunctionRecordTy; std::string CoverageMappings; Index: lib/CodeGen/CoverageMappingGen.cpp === --- lib/CodeGen/CoverageMappingGen.cpp +++ lib/CodeGen/CoverageMappingGen.cpp @@ -929,6 +929,8 @@ }; FunctionRecords.push_back(llvm::ConstantStruct::get( FunctionRecordTy, makeArrayRef(FunctionRecordVals))); + FunctionNames.push_back( + llvm::ConstantExpr::getBitCast(NamePtr, llvm::Type::getInt8PtrTy(Ctx))); CoverageMappings += CoverageMapping; if (CGM.getCodeGenOpts().DumpCoverageMapping) { @@ -1023,6 +1025,15 @@ // Make sure the data doesn't get deleted. CGM.addUsedGlobal(CovData); + // Create the deferred function records array + auto NamesArrTy = + llvm::ArrayType::get(llvm::Type::getInt8PtrTy(Ctx), FunctionNames.size()); + auto NamesArrVal = llvm::ConstantArray::get(NamesArrTy, FunctionNames); + // This variable will *NOT* be emitted to the object file. It is used + // to pass the list of names referenced to codegen. + new llvm::GlobalVariable(CGM.getModule(), NamesArrTy, true, + llvm::GlobalValue::InternalLinkage, NamesArrVal, + llvm::getCoverageNamesVarName()); } unsigned CoverageMappingModuleGen::getFileID(const FileEntry *File) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r256727 - Remove unsafe "__as_link()" cast member function.
Author: ericwf Date: Sun Jan 3 21:27:52 2016 New Revision: 256727 URL: http://llvm.org/viewvc/llvm-project?rev=256727&view=rev Log: Remove unsafe "__as_link()" cast member function. "__as_link()" can only be used safely on "__list_node" objects. This patch moves the "__as_link()" member function from "__list_node_base" to "__list_node" so it cannot be used incorrectly. Unsafe downcasts now use a non-member function so we don't defer the type-punned pointer. Modified: libcxx/trunk/include/list Modified: libcxx/trunk/include/list URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=256727&r1=256726&r2=256727&view=diff == --- libcxx/trunk/include/list (original) +++ libcxx/trunk/include/list Sun Jan 3 21:27:52 2016 @@ -207,6 +207,22 @@ struct __list_node_pointer_traits { >::type __link_pointer; #endif + typedef typename conditional< + is_same<__link_pointer, __node_pointer>::value, + __base_pointer, + __node_pointer + >::type __non_link_pointer; + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { + return __p; + } + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) { + return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p)); + } + }; template @@ -221,22 +237,17 @@ struct __list_node_base __link_pointer __next_; _LIBCPP_INLINE_VISIBILITY -__list_node_base() : __prev_(__as_link()), __next_(__as_link()) {} +__list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), + __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} _LIBCPP_INLINE_VISIBILITY -__base_pointer __as_base() { +__base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); } _LIBCPP_INLINE_VISIBILITY -__link_pointer __as_link() { -return static_cast<__link_pointer>(static_cast<_VoidPtr>( -__as_base())); -} - -_LIBCPP_INLINE_VISIBILITY __node_pointer __as_node() { -return static_cast<__node_pointer>(__as_base()); +return static_cast<__node_pointer>(__self()); } }; @@ -245,6 +256,14 @@ struct __list_node : public __list_node_base<_Tp, _VoidPtr> { _Tp __value_; + +typedef __list_node_base<_Tp, _VoidPtr> __base; +typedef typename __base::__link_pointer __link_pointer; + +_LIBCPP_INLINE_VISIBILITY +__link_pointer __as_link() { +return static_cast<__link_pointer>(__base::__self()); +} }; template > class _LIBCPP_TYPE_VIS_ONLY list; @@ -520,7 +539,8 @@ protected: typedef allocator_traits<__node_allocator> __node_alloc_traits; typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; -typedef typename __list_node_pointer_traits::__link_pointer __link_pointer; +typedef __list_node_pointer_traits __node_pointer_traits; +typedef typename __node_pointer_traits::__link_pointer __link_pointer; typedef __link_pointer __link_const_pointer; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; @@ -533,6 +553,12 @@ protected: __compressed_pair __size_alloc_; _LIBCPP_INLINE_VISIBILITY +__link_pointer __end_as_link() const _NOEXCEPT { +return __node_pointer_traits::__unsafe_link_pointer_cast( +const_cast<__node_base&>(__end_).__self()); +} + +_LIBCPP_INLINE_VISIBILITY size_type& __sz() _NOEXCEPT {return __size_alloc_.first();} _LIBCPP_INLINE_VISIBILITY const size_type& __sz() const _NOEXCEPT @@ -576,18 +602,18 @@ protected: iterator end() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 -return iterator(__end_.__as_link(), this); +return iterator(__end_as_link(), this); #else -return iterator(__end_.__as_link()); +return iterator(__end_as_link()); #endif } _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 -return const_iterator(const_cast<__node_base&>(__end_).__as_link(), this); +return const_iterator(__end_as_link(), this); #else -return const_iterator(const_cast<__node_base&>(__end_).__as_link()); +return const_iterator(__end_as_link()); #endif } @@ -681,7 +707,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCE { __node_allocator& __na = __node_alloc(); __link_pointer __f = __end_.__next_; -__link_pointer __l = __end_.__as_link(); +__link_pointer __l = __end_as_link(); __unlink_nodes(__f, __l->__prev_); __sz() = 0;
[libcxx] r256729 - Print stacktrace with UBSAN
Author: ericwf Date: Sun Jan 3 21:54:58 2016 New Revision: 256729 URL: http://llvm.org/viewvc/llvm-project?rev=256729&view=rev Log: Print stacktrace with UBSAN Modified: libcxx/trunk/test/libcxx/test/config.py Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=256729&r1=256728&r2=256729&view=diff == --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Sun Jan 3 21:54:58 2016 @@ -558,6 +558,7 @@ class Configuration(object): '-fno-sanitize=vptr,function', '-fno-sanitize-recover'] self.cxx.compile_flags += ['-O3'] +self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1' self.config.available_features.add('ubsan') elif san == 'Thread': self.cxx.flags += ['-fsanitize=thread'] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256731 - [TableGen] Call llvm_shutdown on exit so that all the ManagedStatic objects in the support library will be deleted.
Author: ctopper Date: Sun Jan 3 22:51:46 2016 New Revision: 256731 URL: http://llvm.org/viewvc/llvm-project?rev=256731&view=rev Log: [TableGen] Call llvm_shutdown on exit so that all the ManagedStatic objects in the support library will be deleted. Modified: cfe/trunk/utils/TableGen/TableGen.cpp Modified: cfe/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/TableGen.cpp?rev=256731&r1=256730&r2=256731&view=diff == --- cfe/trunk/utils/TableGen/TableGen.cpp (original) +++ cfe/trunk/utils/TableGen/TableGen.cpp Sun Jan 3 22:51:46 2016 @@ -13,6 +13,7 @@ #include "TableGenBackends.h" // Declares all backends. #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/TableGen/Error.h" @@ -244,6 +245,8 @@ int main(int argc, char **argv) { PrettyStackTraceProgram X(argc, argv); cl::ParseCommandLineOptions(argc, argv); + llvm_shutdown_obj Y; + return TableGenMain(argv[0], &ClangTableGenMain); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256736 - clang-format: [Proto] Improve wrapping of message field attributes.
Author: djasper Date: Mon Jan 4 01:27:33 2016 New Revision: 256736 URL: http://llvm.org/viewvc/llvm-project?rev=256736&view=rev Log: clang-format: [Proto] Improve wrapping of message field attributes. Before: optional AAA aaa = 1 [foo = { key: "a" // }, bar = { key: "a" // }]; After: optional AAA aaa = 1 [ foo = { key: "a" // }, bar = { key: "a" // } ]; Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestProto.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256736&r1=256735&r2=256736&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jan 4 01:27:33 2016 @@ -153,7 +153,8 @@ bool ContinuationIndenter::mustBreak(con !Current.isOneOf(tok::r_paren, tok::r_brace)) return true; if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) || - Previous.is(TT_ArrayInitializerLSquare)) && + (Previous.is(TT_ArrayInitializerLSquare) && +Previous.ParameterCount > 1)) && Style.ColumnLimit > 0 && getLengthToMatchingParen(Previous) + State.Column - 1 > getColumnLimit(State)) @@ -728,7 +729,7 @@ unsigned ContinuationIndenter::moveState // }, a, b, c); if (Current.isNot(tok::comment) && Previous && Previous->isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) && - State.Stack.size() > 1) { + !Previous->is(TT_DictLiteral) && State.Stack.size() > 1) { if (State.Stack[State.Stack.size() - 2].NestedBlockInlined && Newline) for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) State.Stack[i].NoLineBreak = true; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256736&r1=256735&r2=256736&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 01:27:33 2016 @@ -285,10 +285,11 @@ private: Contexts.back().ContextKind == tok::l_brace && Parent->isOneOf(tok::l_brace, tok::comma)) { Left->Type = TT_JsComputedPropertyName; - } else if (Parent && - Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren, - tok::l_square, tok::question, tok::colon, - tok::kw_return)) { + } else if (Style.Language == FormatStyle::LK_Proto || + (Parent && + Parent->isOneOf(tok::at, tok::equal, tok::comma, tok::l_paren, + tok::l_square, tok::question, tok::colon, + tok::kw_return))) { Left->Type = TT_ArrayInitializerLSquare; } else { BindingIncrease = 10; Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=256736&r1=256735&r2=256736&view=diff == --- cfe/trunk/unittests/Format/FormatTestProto.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jan 4 01:27:33 2016 @@ -88,9 +88,10 @@ TEST_F(FormatTestProto, UnderstandsRetur TEST_F(FormatTestProto, MessageFieldAttributes) { verifyFormat("optional string test = 1 [default = \"test\"];"); verifyFormat("optional bool a = 1 [default = true, deprecated = true];"); - verifyFormat("optional LongMessageType long_proto_field = 1\n" - "[default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n" - " deprecated = true];"); + verifyFormat("optional LongMessageType long_proto_field = 1 [\n" + " default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n" + " deprecated = true\n" + "];"); verifyFormat("optional LongMessageType long_proto_field = 1\n" "[default = REALLY_REALLY_LONG_CONSTANT_VALUE];"); verifyFormat("repeated double value = 1\n" @@ -103,6 +104,16 @@ TEST_F(FormatTestProto, MessageFieldAttr " : AA\n" " : BB\n" "}];"); + verifyFormat("repeated double value = 1 [\n" + " (aaa.a) = {\n" + ": AA\n" + ": BB\n" + " },\n" + " (bbb.b) = {\n" +
r256737 - clang-format: [Proto] Basic support for options with <> for repeated fields.
Author: djasper Date: Mon Jan 4 01:28:12 2016 New Revision: 256737 URL: http://llvm.org/viewvc/llvm-project?rev=256737&view=rev Log: clang-format: [Proto] Basic support for options with <> for repeated fields. Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestProto.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256737&r1=256736&r2=256737&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 01:28:12 2016 @@ -459,7 +459,8 @@ private: break; } } - if (Contexts.back().ColonIsDictLiteral) { + if (Contexts.back().ColonIsDictLiteral || + Style.Language == FormatStyle::LK_Proto) { Tok->Type = TT_DictLiteral; } else if (Contexts.back().ColonIsObjCMethodExpr || Line.startsWith(TT_ObjCMethodSpecifier)) { @@ -1878,6 +1879,8 @@ bool TokenAnnotator::spaceRequiredBetwee tok::numeric_constant, tok::l_paren, tok::l_brace, tok::kw_true, tok::kw_false)) return false; + if (Left.is(tok::colon)) +return !Left.is(TT_ObjCMethodExpr); if (Left.is(tok::coloncolon)) return false; if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) @@ -1928,8 +1931,6 @@ bool TokenAnnotator::spaceRequiredBetwee !Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare) && !Left.isOneOf(tok::numeric_constant, TT_DictLiteral)) return false; - if (Left.is(tok::colon)) -return !Left.is(TT_ObjCMethodExpr); if (Left.is(tok::l_brace) && Right.is(tok::r_brace)) return !Left.Children.empty(); // No spaces in "{}". if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) || Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=256737&r1=256736&r2=256737&view=diff == --- cfe/trunk/unittests/Format/FormatTestProto.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jan 4 01:28:12 2016 @@ -168,6 +168,12 @@ TEST_F(FormatTestProto, FormatsOptions) " field_c: \"OK\"\n" " msg_field{field_d: 123}\n" "};"); + + // Support syntax with <> instead of {}. + verifyFormat("option (MyProto.options) = {\n" + " field_c: \"OK\",\n" + " msg_field: \n" + "};"); } TEST_F(FormatTestProto, FormatsService) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256738 - clang-format: Fix corner-case in ObjC method declaration formatting
Author: djasper Date: Mon Jan 4 01:29:07 2016 New Revision: 256738 URL: http://llvm.org/viewvc/llvm-project?rev=256738&view=rev Log: clang-format: Fix corner-case in ObjC method declaration formatting Before: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } After: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=256738&r1=256737&r2=256738&view=diff == --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jan 4 01:29:07 2016 @@ -317,16 +317,16 @@ void ContinuationIndenter::addTokenOnCur if (Current.is(TT_SelectorName) && !State.Stack.back().ObjCSelectorNameFound) { +unsigned MinIndent = +std::max(State.FirstIndent + Style.ContinuationIndentWidth, + State.Stack.back().Indent); +unsigned FirstColonPos = State.Column + Spaces + Current.ColumnWidth; if (Current.LongestObjCSelectorName == 0) State.Stack.back().AlignColons = false; -else if (State.Stack.back().Indent + Current.LongestObjCSelectorName > - State.Column + Spaces + Current.ColumnWidth) - State.Stack.back().ColonPos = - std::max(State.FirstIndent + Style.ContinuationIndentWidth, - State.Stack.back().Indent) + - Current.LongestObjCSelectorName; +else if (MinIndent + Current.LongestObjCSelectorName > FirstColonPos) + State.Stack.back().ColonPos = MinIndent + Current.LongestObjCSelectorName; else - State.Stack.back().ColonPos = State.Column + Spaces + Current.ColumnWidth; + State.Stack.back().ColonPos = FirstColonPos; } // In "AlwaysBreak" mode, enforce wrapping directly after the parenthesis by Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256738&r1=256737&r2=256738&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 01:29:07 2016 @@ -467,9 +467,8 @@ private: Tok->Type = TT_ObjCMethodExpr; Tok->Previous->Type = TT_SelectorName; if (Tok->Previous->ColumnWidth > -Contexts.back().LongestObjCSelectorName) { +Contexts.back().LongestObjCSelectorName) Contexts.back().LongestObjCSelectorName = Tok->Previous->ColumnWidth; -} if (!Contexts.back().FirstObjCSelectorName) Contexts.back().FirstObjCSelectorName = Tok->Previous; } else if (Contexts.back().ColonIsForRangeExpr) { Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256738&r1=256737&r2=256738&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 4 01:29:07 2016 @@ -7281,6 +7281,11 @@ TEST_F(FormatTest, FormatObjCMethodDecla " interval:(float)theInterval {\n" "}"); verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" + " longKeyword:(NSRect)theRect\n" + "longerKeyword:(float)theInterval\n" + "error:(NSError **)theError {\n" + "}"); + verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n" " longKeyword:(NSRect)theRect\n" "evenLongerKeyword:(float)theInterval\n" "error:(NSError **)theError {\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256739 - clang-format: Fix corner case for lambda assignments.
Author: djasper Date: Mon Jan 4 01:29:40 2016 New Revision: 256739 URL: http://llvm.org/viewvc/llvm-project?rev=256739&view=rev Log: clang-format: Fix corner case for lambda assignments. Before: std::function my_lambda = []( const string &s) { return s; }; After: std::function my_lambda = [](const string &s) { return s; }; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256739&r1=256738&r2=256739&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 4 01:29:40 2016 @@ -1722,7 +1722,7 @@ unsigned TokenAnnotator::splitPenalty(co return 25; // Slightly prefer formatting local lambda definitions like functions. if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal)) - return 50; + return 35; if (!Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare, TT_ArrayInitializerLSquare)) return 500; Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256739&r1=256738&r2=256739&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 4 01:29:40 2016 @@ -10512,6 +10512,8 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("auto my_lambda = [](const string &some_parameter) {\n" " return some_parameter.size();\n" "};"); + verifyFormat("std::function my_lambda =\n" + "[](const string &s) { return s; };"); verifyFormat("int i = aa ? 1 //\n" " : [] {\n" " return 2; //\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256740 - clang-format: Align long braced init lists even if they are nested in
Author: djasper Date: Mon Jan 4 01:30:44 2016 New Revision: 256740 URL: http://llvm.org/viewvc/llvm-project?rev=256740&view=rev Log: clang-format: Align long braced init lists even if they are nested in function calls. Modified: cfe/trunk/lib/Format/FormatToken.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/FormatToken.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=256740&r1=256739&r2=256740&view=diff == --- cfe/trunk/lib/Format/FormatToken.cpp (original) +++ cfe/trunk/lib/Format/FormatToken.cpp Mon Jan 4 01:30:44 2016 @@ -218,10 +218,12 @@ void CommaSeparatedList::precomputeForma ItemBegin = ItemEnd->Next; } - // Don't use column layout for nested lists, lists with few elements and in - // presence of separating comments. - if ((Token->NestingLevel != 0 && Token->is(tok::l_brace)) || - Commas.size() < 5 || HasSeparatingComment) + // Don't use column layout for lists with few elements and in presence of + // separating comments. + if (Commas.size() < 5 || HasSeparatingComment) +return; + + if (Token->NestingLevel != 0 && Token->is(tok::l_brace) && Commas.size() < 19) return; // We can never place more than ColumnLimit / 3 items in a row (because of the Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256740&r1=256739&r2=256740&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 4 01:30:44 2016 @@ -6544,6 +6544,15 @@ TEST_F(FormatTest, FormatsBracedListsInC " struct Dummy {};\n" " f(v);\n" "}"); + + // Long lists should be formatted in columns even if they are nested. + verifyFormat( + "vector x = function({1, 22, 333, , 5, 66, 777,\n" + " 1, 22, 333, , 5, 66, 777,\n" + " 1, 22, 333, , 5, 66, 777,\n" + " 1, 22, 333, , 5, 66, 777,\n" + " 1, 22, 333, , 5, 66, 777,\n" + " 1, 22, 333, , 5, 66, 777});"); } TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits