[PATCH] D33877: [test] Fix baremetal test to allow any -resource-dir
mgorny created this revision. The baremetal test (r303873) has been added with expectance of very specific -resource-dir. However, the test itself nor the BareMetal driver does not enforce any specific -resource-dir, making this constraint invalid. It already has been altered twice -- in r303910 for Windows compatibility, and in r304085 for systems using lib64. To account for even more systems, just use [[RESOURCE_DIR]] like a number of other tests do. This is needed for Gentoo where RESOURCE_DIR starts with ../ (uses relative path to a parent directory). Repository: rL LLVM https://reviews.llvm.org/D33877 Files: test/Driver/baremetal.cpp Index: test/Driver/baremetal.cpp === --- test/Driver/baremetal.cpp +++ test/Driver/baremetal.cpp @@ -5,13 +5,13 @@ // RUN: --sysroot=%S/Inputs/baremetal_arm \ // RUN: | FileCheck --check-prefix=CHECK-V6M-C %s // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi" -// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]" +// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]" // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic" -// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal" +// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" // CHECK-V6M-C-SAME: "-o" "{{.*}}.o" Index: test/Driver/baremetal.cpp === --- test/Driver/baremetal.cpp +++ test/Driver/baremetal.cpp @@ -5,13 +5,13 @@ // RUN: --sysroot=%S/Inputs/baremetal_arm \ // RUN: | FileCheck --check-prefix=CHECK-V6M-C %s // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi" -// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]" +// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]" // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1" // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include" // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp" // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic" -// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal" +// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal" // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for" // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a" // CHECK-V6M-C-SAME: "-o" "{{.*}}.o" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304684 - Implement isDefined by call to isThisDeclarationADefinition.
Author: sepavloff Date: Sun Jun 4 07:53:12 2017 New Revision: 304684 URL: http://llvm.org/viewvc/llvm-project?rev=304684&view=rev Log: Implement isDefined by call to isThisDeclarationADefinition. Modifies FunctionDecl::isThisDeclarationADefinition so that it covers all the cases checked by FunctionDecl::isDefined. Implements the latter method by call to isThisDeclarationADefinition. This change is a part of the patch D30170. Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/lib/AST/Decl.cpp cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=304684&r1=304683&r2=304684&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Sun Jun 4 07:53:12 2017 @@ -1829,14 +1829,15 @@ public: return getBody(Definition); } - /// isThisDeclarationADefinition - Returns whether this specific - /// declaration of the function is also a definition. This does not - /// determine whether the function has been defined (e.g., in a - /// previous definition); for that information, use isDefined. Note - /// that this returns false for a defaulted function unless that function - /// has been implicitly defined (possibly as deleted). + /// Returns whether this specific declaration of the function is also a + /// definition that does not contain uninstantiated body. + /// + /// This does not determine whether the function has been defined (e.g., in a + /// previous definition); for that information, use isDefined. + /// bool isThisDeclarationADefinition() const { -return IsDeleted || Body || IsLateTemplateParsed; +return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed || + hasDefiningAttr(); } /// doesThisDeclarationHaveABody - Returns whether this specific Modified: cfe/trunk/lib/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=304684&r1=304683&r2=304684&view=diff == --- cfe/trunk/lib/AST/Decl.cpp (original) +++ cfe/trunk/lib/AST/Decl.cpp Sun Jun 4 07:53:12 2017 @@ -2534,9 +2534,8 @@ bool FunctionDecl::hasTrivialBody() cons bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const { for (auto I : redecls()) { -if (I->IsDeleted || I->IsDefaulted || I->Body || I->IsLateTemplateParsed || -I->hasDefiningAttr()) { - Definition = I->IsDeleted ? I->getCanonicalDecl() : I; +if (I->isThisDeclarationADefinition()) { + Definition = I; return true; } } Modified: cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp?rev=304684&r1=304683&r2=304684&view=diff == --- cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp Sun Jun 4 07:53:12 2017 @@ -136,13 +136,13 @@ struct bad_decls { }; struct DefaultDelete { - DefaultDelete() = default; // expected-note {{previous declaration is here}} + DefaultDelete() = default; // expected-note {{previous definition is here}} DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}} - ~DefaultDelete() = default; // expected-note {{previous declaration is here}} + ~DefaultDelete() = default; // expected-note {{previous definition is here}} ~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}} - DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous declaration is here}} + DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous definition is here}} DefaultDelete &operator=(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}} }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33852: Enable __declspec(selectany) on linux
Prazek updated this revision to Diff 101352. Prazek added a comment. - Fixes https://reviews.llvm.org/D33852 Files: include/clang/Basic/Attr.td test/Sema/attr-selectany-not-supported.c test/Sema/attr-selectany.c test/SemaCXX/attr-selectany.cpp utils/TableGen/ClangAttrEmitter.cpp Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -2659,6 +2659,23 @@ } Test += ")"; } + + // If one or more CXX ABIs are specified, check those as well. + if (!R->isValueUnset("ObjectFormats")) { +Test += " && ("; +std::vector ObjectFormats = +R->getValueAsListOfStrings("ObjectFormats"); +for (auto I = ObjectFormats.begin(), E = ObjectFormats.end(); I != E; ++I) { + StringRef Part = *I; + Test += "T.getObjectFormat() == llvm::Triple::"; + Test += Part; + if (I + 1 != E) +Test += " || "; + if (FnName) +*FnName += Part; +} +Test += ")"; + } } static void GenerateHasAttrSpellingStringSwitch( Index: test/SemaCXX/attr-selectany.cpp === --- test/SemaCXX/attr-selectany.cpp +++ test/SemaCXX/attr-selectany.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s + // MSVC produces similar diagnostics. __declspec(selectany) void foo() { } // expected-error{{'selectany' can only be applied to data items with external linkage}} Index: test/Sema/attr-selectany.c === --- test/Sema/attr-selectany.c +++ test/Sema/attr-selectany.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-win32 -fdeclspec -verify %s // RUN: %clang_cc1 -triple x86_64-mingw32 -verify %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -verify -fdeclspec %s extern __declspec(selectany) const int x1 = 1; // no warning, const means we need extern in C++ Index: test/Sema/attr-selectany-not-supported.c === --- /dev/null +++ test/Sema/attr-selectany-not-supported.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple x86_64-win32-macho -verify -fdeclspec %s + +// selectany is not supported for macho object files. +__declspec(selectany) int x1; // expected-warning{{__declspec attribute 'selectany' is not supported}} Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -261,6 +261,7 @@ list Arches = arches; list OSes; list CXXABIs; + list ObjectFormats; } def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>; def TargetAVR : TargetArch<["avr"]>; @@ -274,6 +275,10 @@ def TargetMicrosoftCXXABI : TargetArch<["x86", "x86_64", "arm", "thumb"]> { let CXXABIs = ["Microsoft"]; } +def TargetWindowsAndLinux : TargetArch<["x86", "x86_64", "arm", "thumb"]> { + let OSes = ["Win32", "Linux"]; + let ObjectFormats = ["COFF", "ELF"]; +} // Attribute subject match rules that are used for #pragma clang attribute. // @@ -2413,7 +2418,7 @@ let Documentation = [DLLImportDocs]; } -def SelectAny : InheritableAttr, TargetSpecificAttr { +def SelectAny : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"selectany">, GCC<"selectany">]; let Documentation = [Undocumented]; } Index: utils/TableGen/ClangAttrEmitter.cpp === --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -2659,6 +2659,23 @@ } Test += ")"; } + + // If one or more CXX ABIs are specified, check those as well. + if (!R->isValueUnset("ObjectFormats")) { +Test += " && ("; +std::vector ObjectFormats = +R->getValueAsListOfStrings("ObjectFormats"); +for (auto I = ObjectFormats.begin(), E = ObjectFormats.end(); I != E; ++I) { + StringRef Part = *I; + Test += "T.getObjectFormat() == llvm::Triple::"; + Test += Part; + if (I + 1 != E) +Test += " || "; + if (FnName) +*FnName += Part; +} +Test += ")"; + } } static void GenerateHasAttrSpellingStringSwitch( Index: test/SemaCXX/attr-selectany.cpp === --- test/SemaCXX/attr-selectany.cpp +++ test/SemaCXX/attr-selectany.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-win32 -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux -fms-compatibility -fms-extensions -fsyntax-only -verify -std=c++11 %s + // MSVC produces similar diagnostics. __declspec(selectany) void foo() { } // expected-err
[PATCH] D33852: Enable __declspec(selectany) on linux
Prazek added a comment. I fired bug about the crash: https://bugs.llvm.org/show_bug.cgi?id=33300 https://reviews.llvm.org/D33852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33732: Catch invalid bitwise operation on vector of floats
sepavloff added inline comments. Comment at: test/Sema/types.c:92 + +typedef float __attribute__((ext_vector_type(4))) float4; +float4 test3(float4 x) { bruno wrote: > Can you also add a test for the `vector_type` variant? It might be more > appropriate to put this at test/Sema/ext_vector* and test/Sema/vector* The test for the `vector_type` variant already exists in `test/Sema/vector-ops.c`. I tried to made similar test file for `ext_vector_type` by copying vector-ops.c and replacing vector types accordingly, but there are many differences in diagnostic, so only the part that checks the complement operation was copied. https://reviews.llvm.org/D33732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33732: Catch invalid bitwise operation on vector of floats
sepavloff updated this revision to Diff 101359. sepavloff added a comment. Updated regression test The new regression test was obtained from Sema/vector-ops.c, the part of it that checks binary complement was copied. https://reviews.llvm.org/D33732 Files: lib/Sema/SemaExpr.cpp test/Sema/ext_vector_ops.c Index: test/Sema/ext_vector_ops.c === --- /dev/null +++ test/Sema/ext_vector_ops.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 + +typedef unsigned int v2u __attribute__ ((ext_vector_type(2))); +typedef int v2s __attribute__ ((ext_vector_type(2))); +typedef float v2f __attribute__ ((ext_vector_type(2))); + +void test1(v2u v2ua, v2s v2sa, v2f v2fa) { + // Bitwise binary operators + (void)(v2ua & v2ua); + (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}} + + // Unary operators + (void)(~v2ua); + (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} + + // Comparison operators + v2sa = (v2ua==v2sa); + + // Arrays + int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}} + int array2[17]; + // FIXME: error message below needs type! + (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}} + + v2u *v2u_ptr = 0; + v2s *v2s_ptr; +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -11953,16 +11953,13 @@ << resultType << Input.get()->getSourceRange(); else if (resultType->hasIntegerRepresentation()) break; -else if (resultType->isExtVectorType()) { - if (Context.getLangOpts().OpenCL) { -// OpenCL v1.1 s6.3.f: The bitwise operator not (~) does not operate -// on vector float types. -QualType T = resultType->getAs()->getElementType(); -if (!T->isIntegerType()) - return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) - << resultType << Input.get()->getSourceRange()); - } - break; +else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) { + // OpenCL v1.1 s6.3.f: The bitwise operator not (~) does not operate + // on vector float types. + QualType T = resultType->getAs()->getElementType(); + if (!T->isIntegerType()) +return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) + << resultType << Input.get()->getSourceRange()); } else { return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) << resultType << Input.get()->getSourceRange()); Index: test/Sema/ext_vector_ops.c === --- /dev/null +++ test/Sema/ext_vector_ops.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 + +typedef unsigned int v2u __attribute__ ((ext_vector_type(2))); +typedef int v2s __attribute__ ((ext_vector_type(2))); +typedef float v2f __attribute__ ((ext_vector_type(2))); + +void test1(v2u v2ua, v2s v2sa, v2f v2fa) { + // Bitwise binary operators + (void)(v2ua & v2ua); + (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}} + + // Unary operators + (void)(~v2ua); + (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} + + // Comparison operators + v2sa = (v2ua==v2sa); + + // Arrays + int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}} + int array2[17]; + // FIXME: error message below needs type! + (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}} + + v2u *v2u_ptr = 0; + v2s *v2s_ptr; +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -11953,16 +11953,13 @@ << resultType << Input.get()->getSourceRange(); else if (resultType->hasIntegerRepresentation()) break; -else if (resultType->isExtVectorType()) { - if (Context.getLangOpts().OpenCL) { -// OpenCL v1.1 s6.3.f: The bitwise operator not (~) does not operate -// on vector float types. -QualType T = resultType->getAs()->getElementType(); -if (!T->isIntegerType()) - return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) - << resultType << Input.get()->getSourceRange()); - } - break; +else if (resultType->isExtVectorType() && Context.getLangOpts().OpenCL) { + // OpenCL v1.1 s6.3.f: The bitwise operator not (~) does not operate + // on vector float types. + QualType T = resultType->getAs()->getElementType(); + if (!T->isInteger
[PATCH] D30170: Function definition may have uninstantiated body
sepavloff updated this revision to Diff 101362. sepavloff added a comment. Updated patch according to review notes https://reviews.llvm.org/D30170 Files: include/clang/AST/Decl.h lib/Sema/SemaDecl.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/friend2.cpp Index: test/SemaCXX/friend2.cpp === --- test/SemaCXX/friend2.cpp +++ test/SemaCXX/friend2.cpp @@ -101,6 +101,34 @@ friend void func_12(int x = 0); // expected-error{{friend declaration specifying a default argument must be the only declaration}} }; +// Friend function with uninstantiated body is still a definition. + +template struct C20 { + friend void func_20() {} // expected-note{{previous definition is here}} +}; +C20 c20i; +void func_20() {} // expected-error{{redefinition of 'func_20'}} + +template struct C21a { + friend void func_21() {} // expected-note{{previous definition is here}} +}; +template struct C21b { + friend void func_21() {} // expected-error{{redefinition of 'func_21'}} +}; +C21a c21ai; +C21b c21bi; // expected-note{{in instantiation of template class 'C21b' requested here}} + +template struct C22a { + friend void func_22() {} // expected-note{{previous definition is here}} +}; +template struct C22b { + friend void func_22(); +}; +C22a c22ai; +C22b c22bi; +void func_22() {} // expected-error{{redefinition of 'func_22'}} + + namespace pr22307 { Index: lib/Sema/SemaTemplateInstantiateDecl.cpp === --- lib/Sema/SemaTemplateInstantiateDecl.cpp +++ lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1804,45 +1804,24 @@ // apply to non-template function declarations and definitions also apply // to these implicit definitions. if (D->isThisDeclarationADefinition()) { - // Check for a function body. - const FunctionDecl *Definition = nullptr; - if (Function->isDefined(Definition) && - Definition->getTemplateSpecializationKind() == TSK_Undeclared) { -SemaRef.Diag(Function->getLocation(), diag::err_redefinition) -<< Function->getDeclName(); -SemaRef.Diag(Definition->getLocation(), diag::note_previous_definition); - } - // Check for redefinitions due to other instantiations of this or - // a similar friend function. - else for (auto R : Function->redecls()) { -if (R == Function) - continue; - -// If some prior declaration of this function has been used, we need -// to instantiate its definition. -if (!QueuedInstantiation && R->isUsed(false)) { - if (MemberSpecializationInfo *MSInfo = - Function->getMemberSpecializationInfo()) { -if (MSInfo->getPointOfInstantiation().isInvalid()) { - SourceLocation Loc = R->getLocation(); // FIXME - MSInfo->setPointOfInstantiation(Loc); - SemaRef.PendingLocalImplicitInstantiations.push_back( - std::make_pair(Function, Loc)); - QueuedInstantiation = true; -} - } -} - -// If some prior declaration of this function was a friend with an -// uninstantiated definition, reject it. -if (R->getFriendObjectKind()) { - if (const FunctionDecl *RPattern = - R->getTemplateInstantiationPattern()) { -if (RPattern->isDefined(RPattern)) { - SemaRef.Diag(Function->getLocation(), diag::err_redefinition) -<< Function->getDeclName(); - SemaRef.Diag(R->getLocation(), diag::note_previous_definition); - break; + SemaRef.CheckForFunctionRedefinition(Function); + if (!Function->isInvalidDecl()) { +for (auto R : Function->redecls()) { + if (R == Function) +continue; + + // If some prior declaration of this function has been used, we need + // to instantiate its definition. + if (!QueuedInstantiation && R->isUsed(false)) { +if (MemberSpecializationInfo *MSInfo = +Function->getMemberSpecializationInfo()) { + if (MSInfo->getPointOfInstantiation().isInvalid()) { +SourceLocation Loc = R->getLocation(); // FIXME +MSInfo->setPointOfInstantiation(Loc); +SemaRef.PendingLocalImplicitInstantiations.push_back( +std::make_pair(Function, Loc)); +QueuedInstantiation = true; + } } } } Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -11886,9 +11886,31 @@ const FunctionDecl *EffectiveDefinition, SkipBodyInfo *SkipBody) { const FunctionDecl *Definition = EffectiveDefinition; + if (!Def
r304687 - [clang-format] Don't align too long broken trailing comments
Author: krasimir Date: Sun Jun 4 14:27:02 2017 New Revision: 304687 URL: http://llvm.org/viewvc/llvm-project?rev=304687&view=rev Log: [clang-format] Don't align too long broken trailing comments Summary: This patch fixes a bug where clang-format will align newly broken trailing comments even if this will make them exceed the line limit. The bug was caused by a combination of unsigned arithmetic overflow and an imprecise computation of the length of broken comment lines. Reviewers: djasper, alexfh Reviewed By: alexfh Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33830 Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp cfe/trunk/unittests/Format/FormatTestComments.cpp Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=304687&r1=304686&r2=304687&view=diff == --- cfe/trunk/lib/Format/WhitespaceManager.cpp (original) +++ cfe/trunk/lib/Format/WhitespaceManager.cpp Sun Jun 4 14:27:02 2017 @@ -111,7 +111,7 @@ void WhitespaceManager::calculateLineBre // If there are multiple changes in this token, sum up all the changes until // the end of the line. -if (Changes[i - 1].IsInsideToken) +if (Changes[i - 1].IsInsideToken && Changes[i - 1].NewlinesBefore == 0) LastOutsideTokenChange->TokenLength += Changes[i - 1].TokenLength + Changes[i - 1].Spaces; else @@ -434,7 +434,9 @@ void WhitespaceManager::alignTrailingCom continue; unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn; -unsigned ChangeMaxColumn = Style.ColumnLimit - Changes[i].TokenLength; +unsigned ChangeMaxColumn = Style.ColumnLimit >= Changes[i].TokenLength + ? Style.ColumnLimit - Changes[i].TokenLength + : ChangeMinColumn; // If we don't create a replacement for this change, we have to consider // it to be immovable. Modified: cfe/trunk/unittests/Format/FormatTestComments.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestComments.cpp?rev=304687&r1=304686&r2=304687&view=diff == --- cfe/trunk/unittests/Format/FormatTestComments.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestComments.cpp Sun Jun 4 14:27:02 2017 @@ -2170,6 +2170,15 @@ TEST_F(FormatTestComments, AlignTrailing "// long", getLLVMStyleWithColumns(15))); + // Don't align newly broken trailing comments if that would put them over the + // column limit. + EXPECT_EQ("int i, j; // line 1\n" +"int k; // line longg\n" +" // long", +format("int i, j; // line 1\n" + "int k; // line longg long", + getLLVMStyleWithColumns(20))); + // Align comment line sections aligned with the next token with the next // token. EXPECT_EQ("class A {\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602
CaseyCarter updated this revision to Diff 101366. CaseyCarter added a comment. Fix merge conflicts. https://reviews.llvm.org/D32385 Files: include/optional test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp test/std/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp test/std/utilities/optional/optional.object/special_member_gen.pass.cpp Index: test/std/utilities/optional/optional.object/special_member_gen.pass.cpp === --- test/std/utilities/optional/optional.object/special_member_gen.pass.cpp +++ test/std/utilities/optional/optional.object/special_member_gen.pass.cpp @@ -33,10 +33,10 @@ "optional is copy assignable if and only if T is both copy " "constructible and copy assignable."); static_assert(std::is_move_assignable_v == -((std::is_copy_constructible_v && std::is_copy_assignable_v) || - (std::is_move_constructible_v && std::is_move_assignable_v)), -"optional is move assignable if and only if T is both move assignable and " -"move constructible, or both copy constructible and copy assignable."); +((std::is_move_constructible_v && std::is_move_assignable_v) || + (std::is_copy_constructible_v && std::is_copy_assignable_v)), +"optional is move assignable if and only if T is both move constructible and " +"move assignable, or both copy constructible and copy assignable."); }; template static void sink(Args&&...) {} Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -55,10 +55,10 @@ void test_throwing_ctor() { #ifndef TEST_HAS_NO_EXCEPTIONS struct Z { - Z() : count(0) {} - Z(Z&& o) : count(o.count + 1) - { if (count == 2) throw 6; } - int count; +Z() : count(0) {} +Z(Z&& o) : count(o.count + 1) +{ if (count == 2) throw 6; } +int count; }; Z z; optional rhs(std::move(z)); @@ -150,6 +150,21 @@ #endif } +template +constexpr bool triviality_test = +std::is_trivially_move_constructible>::value == +std::is_trivially_move_constructible::value; + +void test_triviality_extension() { +#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER) +static_assert(triviality_test, ""); +static_assert(triviality_test>, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +#endif +} int main() { @@ -200,9 +215,9 @@ test(); test(42); } -{ -test_throwing_ctor(); -} + +test_throwing_ctor(); + { struct ThrowsMove { ThrowsMove() noexcept(false) {} @@ -217,9 +232,10 @@ }; static_assert(std::is_nothrow_move_constructible>::value, ""); } -{ -test_reference_extension(); -} + +test_reference_extension(); +test_triviality_extension(); + { constexpr std::optional o1{4}; constexpr std::optional o2 = std::move(o1); Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp === --- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp +++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -45,10 +45,10 @@ void test_throwing_ctor() { #ifndef TEST_HAS_NO_EXCEPTIONS struct Z { - Z() : count(0) {} - Z(Z const& o) : count(o.count + 1) - { if (count == 2) throw 6; } - int count; +Z() : count(0) {} +Z(Z const& o) : count(o.count + 1) +{ if (count == 2) throw 6; } +int count; }; const Z z; const optional rhs(z); @@ -114,6 +114,22 @@ #endif } +template +constexpr bool triviality_test = +std::is_trivially_copy_constructible>::value == +std::is_trivially_copy_constructible::value; + +void test_triviality_extension() { +#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER) +static_assert(triviality_test, ""); +static_assert(triviality_test>, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +static_assert(triviality_test, ""); +#endif +} + int main() { test(); @@ -159,12 +175,9 @@ test(); test(42); } -{ -test_throwing_ctor(); -} -{
[PATCH] D33852: Enable __declspec(selectany) on linux
majnemer added inline comments. Comment at: include/clang/Basic/Attr.td:2421 -def SelectAny : InheritableAttr, TargetSpecificAttr { +def SelectAny : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"selectany">, GCC<"selectany">]; selectany should work on targets other than "x86", "x86_64", "arm", "thumb", etc. I think it is only necessary to require that it be a COFF or ELF target. https://reviews.llvm.org/D33852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33719: Add _Float16 as a C/C++ source language type
ahatanak added inline comments. Comment at: include/clang/Basic/TokenKinds.def:379 +// C11 Extension +KEYWORD(_Float16, KEYALL) + Just wanted to confirm that your intention is to unconditionally support _Float16 (for example, c99 supports it too) even though it is a c11 extension. Is that correct? Comment at: lib/Lex/LiteralSupport.cpp:588 + if (s+1 < ThisTokEnd && s[1] == '1') { +if(s+2 < ThisTokEnd && s[2] == '6') { + s += 2; // success, eat up 2 tokens. Do you want to break out of the switch only when the second digit of the suffix is not 6 (for example, f15)? I feel this is a bit simpler: ``` if (s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') s += 2; ``` https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").
ahatanak added inline comments. Comment at: lib/Basic/Targets.cpp:5444 +Feature = "-thumb-mode"; + if (Feature.compare("+thumb") == 0) +Feature = "+thumb-mode"; This can be "else if". https://reviews.llvm.org/D33721 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33719: Add _Float16 as a C/C++ source language type
ahatanak added a comment. Also, please create your new patch with context (git diff -U99 other-branch). https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits