[PATCH] D27300: [OpenCL] Fix SPIR version generation.
echuraev updated this revision to Diff 80034. echuraev marked 3 inline comments as done. https://reviews.llvm.org/D27300 Files: lib/CodeGen/TargetInfo.cpp test/CodeGenOpenCL/spir_version.cl Index: test/CodeGenOpenCL/spir_version.cl === --- test/CodeGenOpenCL/spir_version.cl +++ test/CodeGenOpenCL/spir_version.cl @@ -13,12 +13,12 @@ // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0} +// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2} // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0} -// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0} -// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2} +// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2} + // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0} @@ -28,4 +28,4 @@ // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2} // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} \ No newline at end of file +// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7778,8 +7778,10 @@ // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the // opencl.spir.version named metadata. llvm::Metadata *SPIRVerElts[] = { - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)), - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))}; + llvm::ConstantAsMetadata::get( + llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))}; llvm::NamedMDNode *SPIRVerMD = M.getOrInsertNamedMetadata("opencl.spir.version"); SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); Index: test/CodeGenOpenCL/spir_version.cl === --- test/CodeGenOpenCL/spir_version.cl +++ test/CodeGenOpenCL/spir_version.cl @@ -13,12 +13,12 @@ // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0} +// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2} // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0} -// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0} -// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2} +// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2} + // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0} @@ -28,4 +28,4 @@ // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2} // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} \ No newline at end of file +// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7778,8 +7778,10 @@ // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the // opencl.spir.version named metadata. llvm::Metadata *SPIRVerElts[] = { - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)), - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))}; + llvm::ConstantAsMetadata::get( + llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))}; llvm::NamedMDNode *SPIRVerMD = M.getOrInsertNamedMetadata("opencl.spir.version"); SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27211: [clang-format] Implement comment reflowing
xazax.hun added inline comments. Comment at: lib/Format/Encoding.h:136 + } + while (Left + 1 < Right) { +assert(ComputeWidth(Left) <= Width && "binary search left invariant"); Was just skimming through this patch. What is the reason to use a hand written algorithm instead of STL? https://reviews.llvm.org/D27211 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27334: [OpenCL] Ambiguous function call.
echuraev created this revision. echuraev added a reviewer: Anastasia. echuraev added subscribers: bader, cfe-commits, yaxunl. Added warning about potential ambiguity error with built-in overloading. Patch by Alexey Bader https://reviews.llvm.org/D27334 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/SemaOpenCL/warn-potential-abiguity.cl Index: test/SemaOpenCL/warn-potential-abiguity.cl === --- /dev/null +++ test/SemaOpenCL/warn-potential-abiguity.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wconversion-might-lead-to-ambiguity %s + +float __attribute__((overloadable)) ocl_builtin_func(float f) { return f; } +float __attribute__((overloadable)) ocl_builtin_func_2args(float arg1, float arg2) { return arg1 + arg2; } + +__kernel void test() { + int p = ocl_builtin_func(3); // expected-warning {{implicit conversion from integral type to floating point type for overloadable function might lead to ambiguity}} + int q = ocl_builtin_func_2args(3.f, 3); // expected-warning {{implicit conversion from integral type to floating point type for overloadable function might lead to ambiguity}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -2472,6 +2472,19 @@ if (FDecl) { for (const auto *I : FDecl->specific_attrs()) CheckArgumentWithTypeTag(I, Args.data()); + + if (getLangOpts().OpenCL) { +// Check if overloadble built-in function with floating point arguments takes +// integer values. +if (FDecl->hasAttr()) { + for (const auto* Arg : Args) { +const ImplicitCastExpr *ICE = dyn_cast(Arg); +if (!ICE || ICE->getCastKind() != CK_IntegralToFloating) + continue; +Diag(Loc, diag::warn_ocl_bultin_potential_ambiguity) << Range; + } +} + } } } } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8099,6 +8099,10 @@ "missing actual type specifier for pipe">; def err_reference_pipe_type : Error < "pipes packet types cannot be of reference type">; +def warn_ocl_bultin_potential_ambiguity : Warning< +"implicit conversion from integral type to floating point type for" +" overloadable function might lead to ambiguity">, + InGroup>, DefaultIgnore; def err_opencl_no_main : Error<"%select{function|kernel}0 cannot be called 'main'">; def err_opencl_kernel_attr : Error<"attribute %0 can only be applied to a kernel function">; Index: test/SemaOpenCL/warn-potential-abiguity.cl === --- /dev/null +++ test/SemaOpenCL/warn-potential-abiguity.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wconversion-might-lead-to-ambiguity %s + +float __attribute__((overloadable)) ocl_builtin_func(float f) { return f; } +float __attribute__((overloadable)) ocl_builtin_func_2args(float arg1, float arg2) { return arg1 + arg2; } + +__kernel void test() { + int p = ocl_builtin_func(3); // expected-warning {{implicit conversion from integral type to floating point type for overloadable function might lead to ambiguity}} + int q = ocl_builtin_func_2args(3.f, 3); // expected-warning {{implicit conversion from integral type to floating point type for overloadable function might lead to ambiguity}} +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -2472,6 +2472,19 @@ if (FDecl) { for (const auto *I : FDecl->specific_attrs()) CheckArgumentWithTypeTag(I, Args.data()); + + if (getLangOpts().OpenCL) { +// Check if overloadble built-in function with floating point arguments takes +// integer values. +if (FDecl->hasAttr()) { + for (const auto* Arg : Args) { +const ImplicitCastExpr *ICE = dyn_cast(Arg); +if (!ICE || ICE->getCastKind() != CK_IntegralToFloating) + continue; +Diag(Loc, diag::warn_ocl_bultin_potential_ambiguity) << Range; + } +} + } } } } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8099,6 +8099,10 @@ "missing actual type specifier for pipe">; def err_reference_pipe_type : Error < "pipes packet types cannot be of reference type">; +def warn_ocl_bultin_potential_ambiguity : Warning< +"implicit conversion from integral type to floating point type for" +" overloadable
[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
xazax.hun added inline comments. Comment at: docs/clang-tidy/checks/misc-string-compare.rst:10 +equality or inequality operators. The compare method is intended for sorting +functions and thus returns ``-1``, ``0`` or ``1`` depending on the lexicographical +relationship between the strings compared. If an equality or inequality check As far as I remember this is not true. The ``compare`` method can return any integer number, only the sign is defined. It is not guaranteed to return -1 or 1 in case of inequality. https://reviews.llvm.org/D27210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
malcolm.parsons added inline comments. Comment at: clang-tidy/misc/StringCompareCheck.cpp:25 + callee(cxxMethodDecl(hasName("compare"), + ofClass(classTemplateSpecializationDecl( + hasName("::std::basic_string"), This needs to check that it's one of the single parameter overloads of compare. Comment at: clang-tidy/misc/StringCompareCheck.cpp:27 + hasName("::std::basic_string"), + hasArgument(0, declRefExpr()), callee(memberExpr())); + I don't think you need to check what the first argument is. Comment at: clang-tidy/misc/StringCompareCheck.cpp:39 + binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(strCompare), + hasEitherOperand(integerLiteral(equals(0 Is this clang-formatted? Comment at: test/clang-tidy/misc-string-compare.cpp:9 + + if(str1.compare(str2)) {} + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare] malcolm.parsons wrote: > Some other test ideas: > > ``` > if (str1.compare("foo")) {} > > return str1.compare(str2) == 0; > > func(str1.compare(str2) != 0); > > if (str2.empty() || str1.compare(str2) != 0) {} > ``` There's still no test for the single parameter c-string overload. https://reviews.llvm.org/D27210 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
Hi Malcolm, Matching for the single parameter overload of compare is probably a good idea. I will do that. > Comment at: test/clang-tidy/misc-string-compare.cpp:9 > + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test equality of strings; use the string equality operator instead [misc-string-compare] What do you mean by this comment? Best regards, Mads Ravn On Fri, Dec 2, 2016 at 10:26 AM Malcolm Parsons via Phabricator < revi...@reviews.llvm.org> wrote: > malcolm.parsons added inline comments. > > > > Comment at: clang-tidy/misc/StringCompareCheck.cpp:25 > + callee(cxxMethodDecl(hasName("compare"), > + ofClass(classTemplateSpecializationDecl( > + hasName("::std::basic_string"), > > This needs to check that it's one of the single parameter overloads of > compare. > > > > Comment at: clang-tidy/misc/StringCompareCheck.cpp:27 > + hasName("::std::basic_string"), > + hasArgument(0, declRefExpr()), callee(memberExpr())); > + > > I don't think you need to check what the first argument is. > > > > Comment at: clang-tidy/misc/StringCompareCheck.cpp:39 > + binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), > + hasEitherOperand(strCompare), > + > hasEitherOperand(integerLiteral(equals(0 > > Is this clang-formatted? > > > > Comment at: test/clang-tidy/misc-string-compare.cpp:9 > + > + if(str1.compare(str2)) {} > + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test > equality of strings; use the string equality operator instead > [misc-string-compare] > > malcolm.parsons wrote: > > Some other test ideas: > > > > ``` > > if (str1.compare("foo")) {} > > > > return str1.compare(str2) == 0; > > > > func(str1.compare(str2) != 0); > > > > if (str2.empty() || str1.compare(str2) != 0) {} > > ``` > There's still no test for the single parameter c-string overload. > > > https://reviews.llvm.org/D27210 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
On 2 December 2016 at 09:50, Mads Ravn wrote: >> Comment at: test/clang-tidy/misc-string-compare.cpp:9 >> + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test >> equality of strings; use the string equality operator instead >> [misc-string-compare] > What do you mean by this comment? I was replying to my previous line comment, but the line that was commented on has changed since. My comment was: There's still no test for the single parameter c-string overload. -- Malcolm Parsons ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288491 - [Frontend] Fix an issue where a quoted search path is incorrectly
Author: arphaman Date: Fri Dec 2 03:51:51 2016 New Revision: 288491 URL: http://llvm.org/viewvc/llvm-project?rev=288491&view=rev Log: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path The commit r126167 started passing the First index into RemoveDuplicates, but forgot to update 0 to First in the loop that looks for the duplicate. This resulted in a bug where an -iquoted search path was incorrectly removed if you passed in the same path into -iquote and more than one time into -isystem. rdar://23991350 Differential Revision: https://reviews.llvm.org/D27298 Added: cfe/trunk/test/Frontend/include-duplicate-removal.c Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=288491&r1=288490&r2=288491&view=diff == --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Dec 2 03:51:51 2016 @@ -526,7 +526,7 @@ static unsigned RemoveDuplicates(std::ve if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { // Find the dir that this is the same of. unsigned FirstDir; - for (FirstDir = 0; ; ++FirstDir) { + for (FirstDir = First;; ++FirstDir) { assert(FirstDir != i && "Didn't find dupe?"); const DirectoryLookup &SearchEntry = SearchList[FirstDir]; Added: cfe/trunk/test/Frontend/include-duplicate-removal.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/include-duplicate-removal.c?rev=288491&view=auto == --- cfe/trunk/test/Frontend/include-duplicate-removal.c (added) +++ cfe/trunk/test/Frontend/include-duplicate-removal.c Fri Dec 2 03:51:51 2016 @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 2>&1 | FileCheck %s + +#include + +// CHECK: ignoring duplicate directory +// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}} + +// CHECK: #include "..." +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} +// CHECK-NEXT: #include <...> +// CHECK-NEXT: {{.*}}Inputs{{$}} +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27298: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path
This revision was automatically updated to reflect the committed changes. Closed by commit rL288491: [Frontend] Fix an issue where a quoted search path is incorrectly (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D27298?vs=79887&id=80038#toc Repository: rL LLVM https://reviews.llvm.org/D27298 Files: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp cfe/trunk/test/Frontend/include-duplicate-removal.c Index: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp === --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp @@ -526,7 +526,7 @@ if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { // Find the dir that this is the same of. unsigned FirstDir; - for (FirstDir = 0; ; ++FirstDir) { + for (FirstDir = First;; ++FirstDir) { assert(FirstDir != i && "Didn't find dupe?"); const DirectoryLookup &SearchEntry = SearchList[FirstDir]; Index: cfe/trunk/test/Frontend/include-duplicate-removal.c === --- cfe/trunk/test/Frontend/include-duplicate-removal.c +++ cfe/trunk/test/Frontend/include-duplicate-removal.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 2>&1 | FileCheck %s + +#include + +// CHECK: ignoring duplicate directory +// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}} + +// CHECK: #include "..." +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} +// CHECK-NEXT: #include <...> +// CHECK-NEXT: {{.*}}Inputs{{$}} +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} Index: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp === --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp @@ -526,7 +526,7 @@ if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { // Find the dir that this is the same of. unsigned FirstDir; - for (FirstDir = 0; ; ++FirstDir) { + for (FirstDir = First;; ++FirstDir) { assert(FirstDir != i && "Didn't find dupe?"); const DirectoryLookup &SearchEntry = SearchList[FirstDir]; Index: cfe/trunk/test/Frontend/include-duplicate-removal.c === --- cfe/trunk/test/Frontend/include-duplicate-removal.c +++ cfe/trunk/test/Frontend/include-duplicate-removal.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 2>&1 | FileCheck %s + +#include + +// CHECK: ignoring duplicate directory +// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}} + +// CHECK: #include "..." +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} +// CHECK-NEXT: #include <...> +// CHECK-NEXT: {{.*}}Inputs{{$}} +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
ioeric updated this revision to Diff 80039. ioeric added a comment. - Merge branch 'master' of http://llvm.org/git/clang into insert - Still delete #include's in code. https://reviews.llvm.org/D26909 Files: lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -839,6 +839,89 @@ EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, NoInsertionAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionInStringLiteral) { + std::string Code = "#include \"a.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionAfterOtherDirective) { + std::string Code = "#include \"a.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterLongSystemInclude) { + std::string Code = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n"; + std::string Expected = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n" + "#include \n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include ")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterComment) { + std::string Code = "#include \"a.h\"\n" + "// Comment\n" + "/* Comment */\n" + "// Comment\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "// Comment\n" + "/* Comment */\n" + "// Comment\n" + "#include \"b.h\"\n" + "#include \"c.h\"\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanDeleteAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "void f() {}\n"; + tooling::Replacements Replaces = toReplacements({createDeletion("\"b.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1514,10 +1514,23 @@ return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; } -void skipComments(Lexer &Lex, Token &Tok) { - while (Tok.is(tok::comment)) -if (Lex.LexFromRawLexer(Tok)) - return; +// Returns the offset after skipping a sequence of tokens, matched by \p +// GetOffsetAfterSequence, from the start of the code. +// \p GetOffsetAfterSequence should be a function that matches a sequence of +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, +std::function +GetOffsetAfterSequense) { + std::unique_ptr Env = + Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); + const SourceManager &SourceMgr = Env->getSourceManager(); + Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, +getFormattingLangOpts(Style)); + Token Tok; + // Ge
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
djasper added inline comments. Comment at: lib/Format/Format.cpp:1521 +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, I am somewhat hesitant to put more and more code here. Can we move some of this to a separate file? Is there a reasonable separation? Comment at: lib/Format/Format.cpp:1601 + +// Returns the offset of the last #include directive after which a new +// #include can be inserted. If no such #include in the code, this returns the I might be useful to precisely describe (here or elsewhere) what is determined here, not from an implementation standpoint, but from what a user can expect. https://reviews.llvm.org/D26909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxxabi] r288457 - Update implementation of ABI support for throwing noexcept function pointers
On 2 December 2016 at 02:06, Richard Smith via cfe-commits wrote: > Author: rsmith > Date: Thu Dec 1 20:06:53 2016 > New Revision: 288457 > > URL: http://llvm.org/viewvc/llvm-project?rev=288457&view=rev > Log: > Update implementation of ABI support for throwing noexcept function pointers > and catching as non-noexcept to match the final design per discusson on > cxx-abi-dev. Hi Richard, I hope you've seen this: http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/4 http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions/builds/6 http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/97 http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/109 error: exception specifications are not allowed in type aliases template using FnType = void() noexcept(Noexcept); error: exception specifications are not allowed in type aliases template using FnType = void (X::*)() noexcept(Noexcept); cheers, --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
Hi Malcolm, Thanks. I will fix the last couple of things in the weekend and hopefully have something worth showing there. alexfh suggested that fixits seemed easy to implement. I am having a few doubts as to how I would make fixits for case 1 & 2. How important would it be to implement fixits at this point? Best regards, Mads Ravn On Fri, Dec 2, 2016 at 10:57 AM Malcolm Parsons wrote: > On 2 December 2016 at 09:50, Mads Ravn wrote: > >> Comment at: test/clang-tidy/misc-string-compare.cpp:9 > >> + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test > >> equality of strings; use the string equality operator instead > >> [misc-string-compare] > > What do you mean by this comment? > > I was replying to my previous line comment, but the line that was > commented on has changed since. > > My comment was: > > There's still no test for the single parameter c-string overload. > > -- > Malcolm Parsons > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
On 2 December 2016 at 10:29, Mads Ravn wrote: > alexfh suggested that fixits seemed easy to implement. I am having a few > doubts as to how I would make fixits for case 1 & 2. How important would it > be to implement fixits at this point? Add a FIXME comment if they're difficult. -- Malcolm Parsons ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
ioeric updated this revision to Diff 80042. ioeric marked an inline comment as done. ioeric added a comment. - Updated comments. https://reviews.llvm.org/D26909 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -839,6 +839,89 @@ EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, NoInsertionAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionInStringLiteral) { + std::string Code = "#include \"a.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionAfterOtherDirective) { + std::string Code = "#include \"a.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterLongSystemInclude) { + std::string Code = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n"; + std::string Expected = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n" + "#include \n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include ")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterComment) { + std::string Code = "#include \"a.h\"\n" + "// Comment\n" + "/* Comment */\n" + "// Comment\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "// Comment\n" + "/* Comment */\n" + "// Comment\n" + "#include \"b.h\"\n" + "#include \"c.h\"\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanDeleteAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "void f() {}\n"; + tooling::Replacements Replaces = toReplacements({createDeletion("\"b.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1514,10 +1514,23 @@ return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; } -void skipComments(Lexer &Lex, Token &Tok) { - while (Tok.is(tok::comment)) -if (Lex.LexFromRawLexer(Tok)) - return; +// Returns the offset after skipping a sequence of tokens, matched by \p +// GetOffsetAfterSequence, from the start of the code. +// \p GetOffsetAfterSequence should be a function that matches a sequence of +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, +std::function +GetOffsetAfterSequense) { + std::unique_ptr Env = + Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); + const SourceManager &SourceMgr = Env->getSourceManager(); + Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, +getFormattingLangOpts(Style)); + Token Tok; + // Get the f
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
ioeric added inline comments. Comment at: lib/Format/Format.cpp:1521 +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, djasper wrote: > I am somewhat hesitant to put more and more code here. Can we move some of > this to a separate file? Is there a reasonable separation? Yeah, it makes sense to separate these. I'll do the refactoring in a followup patch to make the current change clear. Comment at: lib/Format/Format.cpp:1601 + +// Returns the offset of the last #include directive after which a new +// #include can be inserted. If no such #include in the code, this returns the djasper wrote: > I might be useful to precisely describe (here or elsewhere) what is > determined here, not from an implementation standpoint, but from what a user > can expect. Added some more comments here and in the public interface. https://reviews.llvm.org/D26909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good. Comment at: unittests/Format/CleanupTest.cpp:898 + +TEST_F(CleanUpReplacementsTest, CanInsertAfterComment) { + std::string Code = "#include \"a.h\"\n" Can you add a similar test or update this one that empty lines are also acceptable? https://reviews.llvm.org/D26909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
ioeric updated this revision to Diff 80044. ioeric marked an inline comment as done. ioeric added a comment. - Addressed comment. https://reviews.llvm.org/D26909 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -839,6 +839,93 @@ EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, NoInsertionAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionInStringLiteral) { + std::string Code = "#include \"a.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "const char[] = R\"(\n" + "#include \"b.h\"\n" + ")\";\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoInsertionAfterOtherDirective) { + std::string Code = "#include \"a.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + std::string Expected = "#include \"a.h\"\n" + "#include \"c.h\"\n" + "#ifdef X\n" + "#include \"b.h\"\n" + "#endif\n"; + tooling::Replacements Replaces = toReplacements( + {createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterLongSystemInclude) { + std::string Code = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n"; + std::string Expected = "#include \"a.h\"\n" + "// comment\n\n" + "#include \n" + "#include \n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include ")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanInsertAfterComment) { + std::string Code = "#include \"a.h\"\n" + "// Comment\n" + "\n" + "/* Comment */\n" + "// Comment\n" + "\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "// Comment\n" + "\n" + "/* Comment */\n" + "// Comment\n" + "\n" + "#include \"b.h\"\n" + "#include \"c.h\"\n"; + tooling::Replacements Replaces = + toReplacements({createInsertion("#include \"c.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, CanDeleteAfterCode) { + std::string Code = "#include \"a.h\"\n" + "void f() {}\n" + "#include \"b.h\"\n"; + std::string Expected = "#include \"a.h\"\n" + "void f() {}\n"; + tooling::Replacements Replaces = toReplacements({createDeletion("\"b.h\"")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1514,10 +1514,23 @@ return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; } -void skipComments(Lexer &Lex, Token &Tok) { - while (Tok.is(tok::comment)) -if (Lex.LexFromRawLexer(Tok)) - return; +// Returns the offset after skipping a sequence of tokens, matched by \p +// GetOffsetAfterSequence, from the start of the code. +// \p GetOffsetAfterSequence should be a function that matches a sequence of +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, +std::function +GetOffsetAfterSequense) { + std::unique_ptr Env = + Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); + const SourceManager &SourceMgr = Env->getSourceManager(); + Lexer Lex(Env->getFileID(), Source
[PATCH] D16533: Bug 20796 - GCC's -Wstrict-prototypes warning not implemented in Clang
arphaman added a comment. Ping Repository: rL LLVM https://reviews.llvm.org/D16533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26909: [ClangFormat] Only insert #include into the #include block in the beginning of the file.
This revision was automatically updated to reflect the committed changes. Closed by commit rL288493: [ClangFormat] Only insert #include into the #include block in the beginning of… (authored by ioeric). Changed prior to commit: https://reviews.llvm.org/D26909?vs=80044&id=80045#toc Repository: rL LLVM https://reviews.llvm.org/D26909 Files: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Index: cfe/trunk/include/clang/Format/Format.h === --- cfe/trunk/include/clang/Format/Format.h +++ cfe/trunk/include/clang/Format/Format.h @@ -786,7 +786,14 @@ /// This also supports inserting/deleting C++ #include directives: /// - If a replacement has offset UINT_MAX, length 0, and a replacement text /// that is an #include directive, this will insert the #include into the -/// correct block in the \p Code. +/// correct block in the \p Code. When searching for points to insert new +/// header, this ignores #include's after the #include block(s) in the +/// beginning of a file to avoid inserting headers into code sections where +/// new #include's should not be added by default. These code sections +/// include: +/// - raw string literals (containing #include). +/// - #if blocks. +/// - Special #include's among declarations (e.g. functions). /// - If a replacement has offset UINT_MAX, length 1, and a replacement text /// that is the name of the header to be removed, the header will be removed /// from \p Code if it exists. Index: cfe/trunk/lib/Format/Format.cpp === --- cfe/trunk/lib/Format/Format.cpp +++ cfe/trunk/lib/Format/Format.cpp @@ -1514,10 +1514,23 @@ return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; } -void skipComments(Lexer &Lex, Token &Tok) { - while (Tok.is(tok::comment)) -if (Lex.LexFromRawLexer(Tok)) - return; +// Returns the offset after skipping a sequence of tokens, matched by \p +// GetOffsetAfterSequence, from the start of the code. +// \p GetOffsetAfterSequence should be a function that matches a sequence of +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, +std::function +GetOffsetAfterSequense) { + std::unique_ptr Env = + Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); + const SourceManager &SourceMgr = Env->getSourceManager(); + Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, +getFormattingLangOpts(Style)); + Token Tok; + // Get the first token. + Lex.LexFromRawLexer(Tok); + return GetOffsetAfterSequense(SourceMgr, Lex, Tok); } // Check if a sequence of tokens is like "# ". If it is, @@ -1527,44 +1540,96 @@ bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) && Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) && - Tok.is(tok::raw_identifier); + tok::raw_identifier; if (Matched) Lex.LexFromRawLexer(Tok); return Matched; } +void skipComments(Lexer &Lex, Token &Tok) { + while (Tok.is(tok::comment)) +if (Lex.LexFromRawLexer(Tok)) + return; +} + +// Returns the offset after header guard directives and any comments +// before/after header guards. If no header guard presents in the code, this +// will returns the offset after skipping all comments from the start of the +// code. unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName, StringRef Code, const FormatStyle &Style) { - std::unique_ptr Env = - Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); - const SourceManager &SourceMgr = Env->getSourceManager(); - Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, -getFormattingLangOpts(Style)); - Token Tok; - // Get the first token. - Lex.LexFromRawLexer(Tok); - skipComments(Lex, Tok); - unsigned AfterComments = SourceMgr.getFileOffset(Tok.getLocation()); - if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) { -skipComments(Lex, Tok); -if (checkAndConsumeDirectiveWithName(Lex, "define", Tok)) - return SourceMgr.getFileOffset(Tok.getLocation()); + return getOffsetAfterTokenSequence( + FileName, Code, Style, + [](const SourceManager &SM, Lexer &Lex, Token Tok) { +skipComments(Lex, Tok); +unsigned InitialOffset = SM.getFileOffset(Tok.getLocation()); +if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) { + skipComments(Lex, Tok); + if (checkAndConsumeDirectiveWithName(Lex, "define", Tok)) +return SM.getFileOffset(Tok.getLocation(
r288493 - [ClangFormat] Only insert #include into the #include block in the beginning of the file.
Author: ioeric Date: Fri Dec 2 05:01:43 2016 New Revision: 288493 URL: http://llvm.org/viewvc/llvm-project?rev=288493&view=rev Log: [ClangFormat] Only insert #include into the #include block in the beginning of the file. Summary: This avoid inserting #include into: - raw string literals containing #include. - #if block. - Special #include among declarations (e.g. functions). Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D26909 Modified: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=288493&r1=288492&r2=288493&view=diff == --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Fri Dec 2 05:01:43 2016 @@ -786,7 +786,14 @@ formatReplacements(StringRef Code, const /// This also supports inserting/deleting C++ #include directives: /// - If a replacement has offset UINT_MAX, length 0, and a replacement text /// that is an #include directive, this will insert the #include into the -/// correct block in the \p Code. +/// correct block in the \p Code. When searching for points to insert new +/// header, this ignores #include's after the #include block(s) in the +/// beginning of a file to avoid inserting headers into code sections where +/// new #include's should not be added by default. These code sections +/// include: +/// - raw string literals (containing #include). +/// - #if blocks. +/// - Special #include's among declarations (e.g. functions). /// - If a replacement has offset UINT_MAX, length 1, and a replacement text /// that is the name of the header to be removed, the header will be removed /// from \p Code if it exists. Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=288493&r1=288492&r2=288493&view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Fri Dec 2 05:01:43 2016 @@ -1514,10 +1514,23 @@ inline bool isHeaderDeletion(const tooli return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; } -void skipComments(Lexer &Lex, Token &Tok) { - while (Tok.is(tok::comment)) -if (Lex.LexFromRawLexer(Tok)) - return; +// Returns the offset after skipping a sequence of tokens, matched by \p +// GetOffsetAfterSequence, from the start of the code. +// \p GetOffsetAfterSequence should be a function that matches a sequence of +// tokens and returns an offset after the sequence. +unsigned getOffsetAfterTokenSequence( +StringRef FileName, StringRef Code, const FormatStyle &Style, +std::function +GetOffsetAfterSequense) { + std::unique_ptr Env = + Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); + const SourceManager &SourceMgr = Env->getSourceManager(); + Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, +getFormattingLangOpts(Style)); + Token Tok; + // Get the first token. + Lex.LexFromRawLexer(Tok); + return GetOffsetAfterSequense(SourceMgr, Lex, Tok); } // Check if a sequence of tokens is like "# ". If it is, @@ -1527,31 +1540,88 @@ bool checkAndConsumeDirectiveWithName(Le bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) && Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) && - Tok.is(tok::raw_identifier); + tok::raw_identifier; if (Matched) Lex.LexFromRawLexer(Tok); return Matched; } +void skipComments(Lexer &Lex, Token &Tok) { + while (Tok.is(tok::comment)) +if (Lex.LexFromRawLexer(Tok)) + return; +} + +// Returns the offset after header guard directives and any comments +// before/after header guards. If no header guard presents in the code, this +// will returns the offset after skipping all comments from the start of the +// code. unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName, StringRef Code, const FormatStyle &Style) { - std::unique_ptr Env = - Environment::CreateVirtualEnvironment(Code, FileName, /*Ranges=*/{}); - const SourceManager &SourceMgr = Env->getSourceManager(); - Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()), SourceMgr, -getFormattingLangOpts(Style)); - Token Tok; - // Get the first token. - Lex.LexFromRawLexer(Tok); - skipComments(Lex, Tok); - unsigned AfterComments = SourceMgr.getFileOffset(Tok.getLocation()); - if (checkAndConsumeDirectiveWithName(Lex, "ifnde
[clang-tools-extra] r288495 - Fix a buildbot failure in include-fixer.
Author: ioeric Date: Fri Dec 2 05:23:07 2016 New Revision: 288495 URL: http://llvm.org/viewvc/llvm-project?rev=288495&view=rev Log: Fix a buildbot failure in include-fixer. Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=288495&r1=288494&r2=288495&view=diff == --- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp (original) +++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri Dec 2 05:23:07 2016 @@ -111,13 +111,10 @@ TEST(IncludeFixer, Typo) { EXPECT_EQ("#include \nstd::string foo;\n", runIncludeFixer("std::string foo;\n")); - // FIXME: the current version of include-fixer does not get this test case - // right - header should be inserted before definition. - EXPECT_EQ( - "// comment\n#include \"foo.h\"\nstd::string foo;\n" - "#include \"dir/bar.h\"\n#include \n", - runIncludeFixer("// comment\n#include \"foo.h\"\nstd::string foo;\n" - "#include \"dir/bar.h\"\n")); + EXPECT_EQ("// comment\n#include \"foo.h\"\n#include \n" +"std::string foo;\n#include \"dir/bar.h\"\n", +runIncludeFixer("// comment\n#include \"foo.h\"\nstd::string foo;\n" +"#include \"dir/bar.h\"\n")); EXPECT_EQ("#include \"foo.h\"\n#include \nstd::string foo;\n", runIncludeFixer("#include \"foo.h\"\nstd::string foo;\n")); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain
- Original Message - > From: "Jason Henline via cfe-commits" > To: cfe-commits@lists.llvm.org > Sent: Thursday, December 1, 2016 7:42:54 PM > Subject: r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain > > Author: jhen > Date: Thu Dec 1 19:42:54 2016 > New Revision: 288448 > > URL: http://llvm.org/viewvc/llvm-project?rev=288448&view=rev > Log: > [CUDA] "Support" ASAN arguments in CudaToolChain > > This fixes a bug that was introduced in rL287285. The bug made it > illegal to pass -fsanitize=address during CUDA compilation because > the > CudaToolChain class was switched from deriving from the Linux > toolchain > class to deriving directly from the ToolChain toolchain class. When > CudaToolChain derived from Linux, it used Linux's > getSupportedSanitizers > method, and that method allowed ASAN, but when it switched to > deriving > directly from ToolChain, it inherited a getSupportedSanitizers method > that didn't allow for ASAN. > > This patch fixes that bug by creating a getSupportedSanitizers method > for CudaToolChain that supports ASAN. > > This patch also fixes the test that checks that -fsanitize=address is > passed correctly for CUDA builds. That test didn't used to notice if > an > error message was emitted, and that's why it didn't catch this bug > when > it was first introduced. With the fix from this patch, that test will > now catch any similar bug in the future. > > Modified: > cfe/trunk/lib/Driver/ToolChains.cpp > cfe/trunk/lib/Driver/ToolChains.h > cfe/trunk/test/Driver/cuda-no-sanitizers.cu > > Modified: cfe/trunk/lib/Driver/ToolChains.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288448&r1=288447&r2=288448&view=diff > == > --- cfe/trunk/lib/Driver/ToolChains.cpp (original) > +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Dec 1 19:42:54 2016 > @@ -4973,6 +4973,15 @@ void CudaToolChain::AddIAMCUIncludeArgs( >HostTC.AddIAMCUIncludeArgs(Args, CC1Args); > } > > +SanitizerMask CudaToolChain::getSupportedSanitizers() const { > + // The CudaToolChain only supports address sanitization in the > sense that it > + // allows ASAN arguments on the command line. It must not error > out on these > + // command line arguments because the host code compilation > supports them. > + // However, it doesn't actually do any address sanitization for > device code; > + // instead, it just ignores any ASAN command line arguments it > sees. > + return SanitizerKind::Address; > +} I don't understand why only ASAN is enabled. What about TSAN, etc.? Shouldn't you query whatever the host toolchain is? Thanks again, Hal > + > /// XCore tool chain > XCoreToolChain::XCoreToolChain(const Driver &D, const llvm::Triple > &Triple, > const ArgList &Args) > > Modified: cfe/trunk/lib/Driver/ToolChains.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=288448&r1=288447&r2=288448&view=diff > == > --- cfe/trunk/lib/Driver/ToolChains.h (original) > +++ cfe/trunk/lib/Driver/ToolChains.h Thu Dec 1 19:42:54 2016 > @@ -912,6 +912,8 @@ public: >void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, > llvm::opt::ArgStringList &CC1Args) const > override; > > + SanitizerMask getSupportedSanitizers() const override; > + >const ToolChain &HostTC; >CudaInstallationDetector CudaInstallation; > > > Modified: cfe/trunk/test/Driver/cuda-no-sanitizers.cu > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288448&r1=288447&r2=288448&view=diff > == > --- cfe/trunk/test/Driver/cuda-no-sanitizers.cu (original) > +++ cfe/trunk/test/Driver/cuda-no-sanitizers.cu Thu Dec 1 19:42:54 > 2016 > @@ -6,6 +6,7 @@ > // RUN: %clang -### -target x86_64-linux-gnu -c > --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ > // RUN: FileCheck %s > > +// CHECK-NOT: error: > // CHECK-DAG: "-fcuda-is-device" > // CHECK-NOT: "-fsanitize=address" > // CHECK-DAG: "-triple" "x86_64--linux-gnu" > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > -- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r288498 - [clang-move] some tweaks.
Author: hokein Date: Fri Dec 2 06:39:39 2016 New Revision: 288498 URL: http://llvm.org/viewvc/llvm-project?rev=288498&view=rev Log: [clang-move] some tweaks. * Don't save SourceManager for each declarations. * Rename some out-dated methods. No functionality change. Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-move/ClangMove.h Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=288498&r1=288497&r2=288498&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Dec 2 06:39:39 2016 @@ -147,10 +147,9 @@ public: const clang::NamedDecl *D = FD; if (const auto *FTD = FD->getDescribedFunctionTemplate()) D = FTD; -MoveTool->getMovedDecls().emplace_back(D, - &Result.Context->getSourceManager()); +MoveTool->getMovedDecls().push_back(D); MoveTool->getUnremovedDeclsInOldHeader().erase(D); -MoveTool->addRemovedDecl(MoveTool->getMovedDecls().back()); +MoveTool->addRemovedDecl(D); } private: @@ -180,8 +179,8 @@ private: // Skip inline class methods. isInline() ast matcher doesn't ignore this // case. if (!CMD->isInlined()) { - MoveTool->getMovedDecls().emplace_back(CMD, SM); - MoveTool->addRemovedDecl(MoveTool->getMovedDecls().back()); + MoveTool->getMovedDecls().push_back(CMD); + MoveTool->addRemovedDecl(CMD); // Get template class method from its method declaration as // UnremovedDecls stores template class method. if (const auto *FTD = CMD->getDescribedFunctionTemplate()) @@ -193,8 +192,8 @@ private: void MatchClassStaticVariable(const clang::NamedDecl *VD, clang::SourceManager* SM) { -MoveTool->getMovedDecls().emplace_back(VD, SM); -MoveTool->addRemovedDecl(MoveTool->getMovedDecls().back()); +MoveTool->getMovedDecls().push_back(VD); +MoveTool->addRemovedDecl(VD); MoveTool->getUnremovedDeclsInOldHeader().erase(VD); } @@ -203,12 +202,12 @@ private: // Get class template from its class declaration as UnremovedDecls stores // class template. if (const auto *TC = CD->getDescribedClassTemplate()) - MoveTool->getMovedDecls().emplace_back(TC, SM); + MoveTool->getMovedDecls().push_back(TC); else - MoveTool->getMovedDecls().emplace_back(CD, SM); + MoveTool->getMovedDecls().push_back(CD); MoveTool->addRemovedDecl(MoveTool->getMovedDecls().back()); MoveTool->getUnremovedDeclsInOldHeader().erase( -MoveTool->getMovedDecls().back().Decl); +MoveTool->getMovedDecls().back()); } ClangMoveTool *MoveTool; @@ -217,18 +216,19 @@ private: // Expand to get the end location of the line where the EndLoc of the given // Decl. SourceLocation -getLocForEndOfDecl(const clang::Decl *D, const SourceManager *SM, +getLocForEndOfDecl(const clang::Decl *D, const LangOptions &LangOpts = clang::LangOptions()) { - std::pair LocInfo = SM->getDecomposedLoc(D->getLocEnd()); + const auto &SM = D->getASTContext().getSourceManager(); + std::pair LocInfo = SM.getDecomposedLoc(D->getLocEnd()); // Try to load the file buffer. bool InvalidTemp = false; - llvm::StringRef File = SM->getBufferData(LocInfo.first, &InvalidTemp); + llvm::StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp); if (InvalidTemp) return SourceLocation(); const char *TokBegin = File.data() + LocInfo.second; // Lex from the start of the given location. - Lexer Lex(SM->getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(), + Lexer Lex(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(), TokBegin, File.end()); llvm::SmallVector Line; @@ -239,40 +239,42 @@ getLocForEndOfDecl(const clang::Decl *D, // If we already reach EOF, just return the EOF SourceLocation; // otherwise, move 1 offset ahead to include the trailing newline character // '\n'. - return SM->getLocForEndOfFile(LocInfo.first) == EndLoc + return SM.getLocForEndOfFile(LocInfo.first) == EndLoc ? EndLoc : EndLoc.getLocWithOffset(1); } // Get full range of a Decl including the comments associated with it. clang::CharSourceRange -GetFullRange(const clang::SourceManager *SM, const clang::Decl *D, +getFullRange(const clang::Decl *D, const clang::LangOptions &options = clang::LangOptions()) { - clang::SourceRange Full(SM->getExpansionLoc(D->getLocStart()), - getLocForEndOfDecl(D, SM)); + const auto &SM = D->getASTContext().getSourceManager(); + clang::SourceRange Full(SM.getExpansionLoc(D->getLocStart()), + getLocForEndOfDecl(D)); // Expand to comments th
[PATCH] D27248: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final
flx added inline comments. Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:276 +// Virtual method overrides of dependent types cannot be recognized unless they +// are marked as override or final. Test that check is not triggered on methods +// marked with override or final. malcolm.parsons wrote: > flx wrote: > > malcolm.parsons wrote: > > > Do we want to warn about methods in templated classes at all? > > I think we should still trigger on methods where we can determine that the > > parameter type is expensive to copy. Note that this is not the case when > > the type is dependent. > We still have issues when the overriding method is not marked override or > final. > Is there another way to handle this? I filed https://llvm.org/bugs/show_bug.cgi?id=31236 to keep track of fixing the check for this case as well. https://reviews.llvm.org/D27248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27248: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final
malcolm.parsons added inline comments. Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:276 +// Virtual method overrides of dependent types cannot be recognized unless they +// are marked as override or final. Test that check is not triggered on methods +// marked with override or final. flx wrote: > malcolm.parsons wrote: > > flx wrote: > > > malcolm.parsons wrote: > > > > Do we want to warn about methods in templated classes at all? > > > I think we should still trigger on methods where we can determine that > > > the parameter type is expensive to copy. Note that this is not the case > > > when the type is dependent. > > We still have issues when the overriding method is not marked override or > > final. > > Is there another way to handle this? > I filed https://llvm.org/bugs/show_bug.cgi?id=31236 to keep track of fixing > the check for this case as well. Thanks. https://reviews.llvm.org/D27248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r288502 - [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final
Author: flx Date: Fri Dec 2 08:44:16 2016 New Revision: 288502 URL: http://llvm.org/viewvc/llvm-project?rev=288502&view=rev Log: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final Summary: Virtual method overrides of dependent types cannot be recognized unless they are marked as override or final. Exclude methods marked as final from check and add test. Reviewers: sbenza, hokein, alexfh Subscribers: malcolm.parsons, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D27248 Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Modified: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=288502&r1=288501&r2=288502&view=diff == --- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp Fri Dec 2 08:44:16 2016 @@ -61,7 +61,8 @@ void UnnecessaryValueParamCheck::registe unless(referenceType(), decl().bind("param")); Finder->addMatcher( - functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())), + functionDecl(isDefinition(), + unless(cxxMethodDecl(anyOf(isOverride(), isFinal(, unless(isInstantiated()), has(typeLoc(forEach(ExpensiveValueParamDecl))), decl().bind("functionDecl")), Modified: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=288502&r1=288501&r2=288502&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Fri Dec 2 08:44:16 2016 @@ -271,3 +271,21 @@ void PositiveMessageAndFixAsFunctionIsCa void ReferenceFunctionByCallingIt() { PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType()); } + +// Virtual method overrides of dependent types cannot be recognized unless they +// are marked as override or final. Test that check is not triggered on methods +// marked with override or final. +template +struct NegativeDependentTypeInterface { + virtual void Method(ExpensiveToCopyType E) = 0; +}; + +template +struct NegativeOverrideImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) override {} +}; + +template +struct NegativeFinalImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) final {} +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27248: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final
This revision was automatically updated to reflect the committed changes. Closed by commit rL288502: [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as… (authored by flx). Changed prior to commit: https://reviews.llvm.org/D27248?vs=79732&id=80066#toc Repository: rL LLVM https://reviews.llvm.org/D27248 Files: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -61,7 +61,8 @@ unless(referenceType(), decl().bind("param")); Finder->addMatcher( - functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())), + functionDecl(isDefinition(), + unless(cxxMethodDecl(anyOf(isOverride(), isFinal(, unless(isInstantiated()), has(typeLoc(forEach(ExpensiveValueParamDecl))), decl().bind("functionDecl")), Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp === --- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp +++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp @@ -271,3 +271,21 @@ void ReferenceFunctionByCallingIt() { PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType()); } + +// Virtual method overrides of dependent types cannot be recognized unless they +// are marked as override or final. Test that check is not triggered on methods +// marked with override or final. +template +struct NegativeDependentTypeInterface { + virtual void Method(ExpensiveToCopyType E) = 0; +}; + +template +struct NegativeOverrideImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) override {} +}; + +template +struct NegativeFinalImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) final {} +}; Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -61,7 +61,8 @@ unless(referenceType(), decl().bind("param")); Finder->addMatcher( - functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())), + functionDecl(isDefinition(), + unless(cxxMethodDecl(anyOf(isOverride(), isFinal(, unless(isInstantiated()), has(typeLoc(forEach(ExpensiveValueParamDecl))), decl().bind("functionDecl")), Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp === --- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp +++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp @@ -271,3 +271,21 @@ void ReferenceFunctionByCallingIt() { PositiveMessageAndFixAsFunctionIsCalled(ExpensiveToCopyType()); } + +// Virtual method overrides of dependent types cannot be recognized unless they +// are marked as override or final. Test that check is not triggered on methods +// marked with override or final. +template +struct NegativeDependentTypeInterface { + virtual void Method(ExpensiveToCopyType E) = 0; +}; + +template +struct NegativeOverrideImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) override {} +}; + +template +struct NegativeFinalImpl : public NegativeDependentTypeInterface { + void Method(ExpensiveToCopyType E) final {} +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27300: [OpenCL] Fix SPIR version generation.
Anastasia added inline comments. Comment at: test/CodeGenOpenCL/spir_version.cl:22 + // CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} Could we then use VER here too? Comment at: test/CodeGenOpenCL/spir_version.cl:26 // CHECK-AMDGCN-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL10: [[OCL]] = !{i32 1, i32 0} Btw, would it make sense to add for AMD targets? CHECK-NOT: !opencl.spir.version https://reviews.llvm.org/D27300 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27334: [OpenCL] Ambiguous function call.
Anastasia added a comment. This change seems to modify normal C behavior again. Is there any strong motivation for doing this and if yes could it be done generically with C? Comment at: lib/Sema/SemaChecking.cpp:2479 +// integer values. +if (FDecl->hasAttr()) { + for (const auto* Arg : Args) { How does it check that this is a built-in function? https://reviews.llvm.org/D27334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain
Hi Hal, I don't understand why only ASAN is enabled. What about TSAN, etc.? Shouldn't you query whatever the host toolchain is? I think you're right, I should just implement it as SanitizerMask CudaToolChain::getSupportedSanitizers() const { return HostTC.getSupportedSanitizers(); } I will get a patch up later today to do that. Thanks for the suggestion! -Jason On Fri, Dec 2, 2016 at 4:31 AM Hal Finkel wrote: > - Original Message - > > From: "Jason Henline via cfe-commits" > > To: cfe-commits@lists.llvm.org > > Sent: Thursday, December 1, 2016 7:42:54 PM > > Subject: r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain > > > > Author: jhen > > Date: Thu Dec 1 19:42:54 2016 > > New Revision: 288448 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=288448&view=rev > > Log: > > [CUDA] "Support" ASAN arguments in CudaToolChain > > > > This fixes a bug that was introduced in rL287285. The bug made it > > illegal to pass -fsanitize=address during CUDA compilation because > > the > > CudaToolChain class was switched from deriving from the Linux > > toolchain > > class to deriving directly from the ToolChain toolchain class. When > > CudaToolChain derived from Linux, it used Linux's > > getSupportedSanitizers > > method, and that method allowed ASAN, but when it switched to > > deriving > > directly from ToolChain, it inherited a getSupportedSanitizers method > > that didn't allow for ASAN. > > > > This patch fixes that bug by creating a getSupportedSanitizers method > > for CudaToolChain that supports ASAN. > > > > This patch also fixes the test that checks that -fsanitize=address is > > passed correctly for CUDA builds. That test didn't used to notice if > > an > > error message was emitted, and that's why it didn't catch this bug > > when > > it was first introduced. With the fix from this patch, that test will > > now catch any similar bug in the future. > > > > Modified: > > cfe/trunk/lib/Driver/ToolChains.cpp > > cfe/trunk/lib/Driver/ToolChains.h > > cfe/trunk/test/Driver/cuda-no-sanitizers.cu > > > > Modified: cfe/trunk/lib/Driver/ToolChains.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288448&r1=288447&r2=288448&view=diff > > > == > > --- cfe/trunk/lib/Driver/ToolChains.cpp (original) > > +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Dec 1 19:42:54 2016 > > @@ -4973,6 +4973,15 @@ void CudaToolChain::AddIAMCUIncludeArgs( > >HostTC.AddIAMCUIncludeArgs(Args, CC1Args); > > } > > > > +SanitizerMask CudaToolChain::getSupportedSanitizers() const { > > + // The CudaToolChain only supports address sanitization in the > > sense that it > > + // allows ASAN arguments on the command line. It must not error > > out on these > > + // command line arguments because the host code compilation > > supports them. > > + // However, it doesn't actually do any address sanitization for > > device code; > > + // instead, it just ignores any ASAN command line arguments it > > sees. > > + return SanitizerKind::Address; > > +} > > I don't understand why only ASAN is enabled. What about TSAN, etc.? > Shouldn't you query whatever the host toolchain is? > > Thanks again, > Hal > > > + > > /// XCore tool chain > > XCoreToolChain::XCoreToolChain(const Driver &D, const llvm::Triple > > &Triple, > > const ArgList &Args) > > > > Modified: cfe/trunk/lib/Driver/ToolChains.h > > URL: > > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=288448&r1=288447&r2=288448&view=diff > > > == > > --- cfe/trunk/lib/Driver/ToolChains.h (original) > > +++ cfe/trunk/lib/Driver/ToolChains.h Thu Dec 1 19:42:54 2016 > > @@ -912,6 +912,8 @@ public: > >void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, > > llvm::opt::ArgStringList &CC1Args) const > > override; > > > > + SanitizerMask getSupportedSanitizers() const override; > > + > >const ToolChain &HostTC; > >CudaInstallationDetector CudaInstallation; > > > > > > Modified: cfe/trunk/test/Driver/cuda-no-sanitizers.cu > > URL: > > > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288448&r1=288447&r2=288448&view=diff > > > == > > --- cfe/trunk/test/Driver/cuda-no-sanitizers.cu (original) > > +++ cfe/trunk/test/Driver/cuda-no-sanitizers.cu Thu Dec 1 19:42:54 > > 2016 > > @@ -6,6 +6,7 @@ > > // RUN: %clang -### -target x86_64-linux-gnu -c > > --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \ > > // RUN: FileCheck %s > > > > +// CHECK-NOT: error: > > // CHECK-DAG: "-fcuda-is-device" > > // CHECK-NOT: "-fsanitize=address" > > // CHECK-DAG: "-triple" "x86_64--linux-gnu" > > > > > > __
[PATCH] D27332: With LTO and profile-use, enable hotness info in opt remarks
mehdi_amini accepted this revision. mehdi_amini added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D27332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27332: With LTO and profile-use, enable hotness info in opt remarks
mehdi_amini added a comment. (You have a typo in the decription, you may want to fix it before commit) https://reviews.llvm.org/D27332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Fix some misc-move-forwarding-reference warnings
Hello, The attached patch fixes a couple of incorrect uses of std::move as revealed by clang-tidy. Best regards, Michael Sharpe diff --git lib/AST/Type.cpp lib/AST/Type.cpp index d98d8d7..0d0cd2e 100644 --- lib/AST/Type.cpp +++ lib/AST/Type.cpp @@ -1050,24 +1050,24 @@ template QualType simpleTransform(ASTContext &ctx, QualType type, F &&f) { // Transform the type. If it changed, return the transformed result. QualType transformed = f(type); if (transformed.getAsOpaquePtr() != type.getAsOpaquePtr()) return transformed; // Split out the qualifiers from the type. SplitQualType splitType = type.split(); // Visit the type itself. - SimpleTransformVisitor visitor(ctx, std::move(f)); + SimpleTransformVisitor visitor(ctx, std::forward(f)); QualType result = visitor.Visit(splitType.Ty); if (result.isNull()) return result; // Reconstruct the transformed type by applying the local qualifiers // from the split type. return ctx.getQualifiedType(result, splitType.Quals); } } // end anonymous namespace /// Substitute the given type arguments for Objective-C type /// parameters within the given type, recursively. diff --git lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBlocks.cpp index 09911d4..50a6d61 100644 --- lib/CodeGen/CGBlocks.cpp +++ lib/CodeGen/CGBlocks.cpp @@ -1931,21 +1931,21 @@ template static T *buildByrefHelpers(CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, T &&generator) { llvm::FoldingSetNodeID id; generator.Profile(id); void *insertPos; BlockByrefHelpers *node = CGM.ByrefHelpersCache.FindNodeOrInsertPos(id, insertPos); if (node) return static_cast(node); generator.CopyHelper = buildByrefCopyHelper(CGM, byrefInfo, generator); generator.DisposeHelper = buildByrefDisposeHelper(CGM, byrefInfo, generator); - T *copy = new (CGM.getContext()) T(std::move(generator)); + T *copy = new (CGM.getContext()) T(std::forward(generator)); CGM.ByrefHelpersCache.InsertNode(copy, insertPos); return copy; } /// Build the copy and dispose helpers for the given __block variable /// emission. Places the helpers in the global cache. Returns null /// if no helpers are required. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27332: With LTO and profile-use, enable hotness info in opt remarks
anemet added a comment. In https://reviews.llvm.org/D27332#611769, @mehdi_amini wrote: > (You have a typo in the decription, you may want to fix it before commit) Got it. Thanks for the reviews! https://reviews.llvm.org/D27332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27350: CFGBuilder: Fix crash when visiting delete expression on dependent type
mboehme created this revision. mboehme added a reviewer: klimek. mboehme added a subscriber: cfe-commits. CXXDeleteExpr::getDestroyedType() can return a null QualType if the destroyed type is a dependent type. This patch protects against this. https://reviews.llvm.org/D27350 Files: lib/Analysis/CFG.cpp unittests/Analysis/CFGTest.cpp Index: unittests/Analysis/CFGTest.cpp === --- unittests/Analysis/CFGTest.cpp +++ unittests/Analysis/CFGTest.cpp @@ -18,6 +18,41 @@ namespace analysis { namespace { +enum BuildResult { + ToolFailed, + ToolRan, + SawFunctionBody, + BuiltCFG, +}; + +class CFGCallback : public ast_matchers::MatchFinder::MatchCallback { +public: + BuildResult TheBuildResult = ToolRan; + + void run(const ast_matchers::MatchFinder::MatchResult &Result) override { +const auto *Func = Result.Nodes.getNodeAs("func"); +Stmt *Body = Func->getBody(); +if (!Body) + return; +TheBuildResult = SawFunctionBody; +if (CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions())) +TheBuildResult = BuiltCFG; + } +}; + +BuildResult BuildCFG(const char *Code) { + CFGCallback Callback; + + ast_matchers::MatchFinder Finder; + Finder.addMatcher(ast_matchers::functionDecl().bind("func"), &Callback); + std::unique_ptr Factory( + tooling::newFrontendActionFactory(&Finder)); + std::vector Args = {"-std=c++11", "-fno-delayed-template-parsing"}; + if (!tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args)) +return ToolFailed; + return Callback.TheBuildResult; +} + // Constructing a CFG for a range-based for over a dependent type fails (but // should not crash). TEST(CFG, RangeBasedForOverDependentType) { @@ -27,30 +62,17 @@ " for (const Foo *TheFoo : Range) {\n" " }\n" "}\n"; + EXPECT_EQ(SawFunctionBody, BuildCFG(Code)); +} - class CFGCallback : public ast_matchers::MatchFinder::MatchCallback { - public: -bool SawFunctionBody = false; - -void run(const ast_matchers::MatchFinder::MatchResult &Result) override { - const auto *Func = Result.Nodes.getNodeAs("func"); - Stmt *Body = Func->getBody(); - if (!Body) -return; - SawFunctionBody = true; - std::unique_ptr cfg = - CFG::buildCFG(nullptr, Body, Result.Context, CFG::BuildOptions()); - EXPECT_EQ(nullptr, cfg); -} - } Callback; - - ast_matchers::MatchFinder Finder; - Finder.addMatcher(ast_matchers::functionDecl().bind("func"), &Callback); - std::unique_ptr Factory( - tooling::newFrontendActionFactory(&Finder)); - std::vector Args = {"-std=c++11", "-fno-delayed-template-parsing"}; - ASSERT_TRUE(tooling::runToolOnCodeWithArgs(Factory->create(), Code, Args)); - EXPECT_TRUE(Callback.SawFunctionBody); +// Constructing a CFG containing a delete expression on a dependent type should +// not crash. +TEST(CFG, DeleteExpressionOnDependentType) { + const char *Code = "template\n" + "void f(T t) {\n" + " delete t;\n" + "}\n"; + EXPECT_EQ(BuiltCFG, BuildCFG(Code)); } } // namespace Index: lib/Analysis/CFG.cpp === --- lib/Analysis/CFG.cpp +++ lib/Analysis/CFG.cpp @@ -3581,11 +3581,13 @@ autoCreateBlock(); appendStmt(Block, DE); QualType DTy = DE->getDestroyedType(); - DTy = DTy.getNonReferenceType(); - CXXRecordDecl *RD = Context->getBaseElementType(DTy)->getAsCXXRecordDecl(); - if (RD) { -if (RD->isCompleteDefinition() && !RD->hasTrivialDestructor()) - appendDeleteDtor(Block, RD, DE); + if (!DTy.isNull()) { +DTy = DTy.getNonReferenceType(); +CXXRecordDecl *RD = Context->getBaseElementType(DTy)->getAsCXXRecordDecl(); +if (RD) { + if (RD->isCompleteDefinition() && !RD->hasTrivialDestructor()) +appendDeleteDtor(Block, RD, DE); +} } return VisitChildren(DE); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23325: [WIP] Binding of references to packed fields
rogfer01 updated this revision to Diff 80081. rogfer01 added a comment. Drop attribute packed of a class when one of its fields is a non-packed non-pod for compatibility with GCC. https://reviews.llvm.org/D23325 Files: include/clang/AST/Decl.h include/clang/AST/Expr.h include/clang/AST/Stmt.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/Specifiers.h lib/AST/ASTDumper.cpp lib/AST/Decl.cpp lib/Sema/SemaCast.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprMember.cpp lib/Sema/SemaFixItUtils.cpp lib/Sema/SemaInit.cpp test/CodeGenCXX/pod-member-memcpys.cpp test/SemaCXX/bind-packed-member.cpp Index: test/SemaCXX/bind-packed-member.cpp === --- test/SemaCXX/bind-packed-member.cpp +++ test/SemaCXX/bind-packed-member.cpp @@ -0,0 +1,107 @@ +// RUN: %clang_cc1 -verify %s + +struct __attribute__((packed)) A { + char x; + float y; + char z; +} a; + +char &rax = a.x; // no-error +float &ray = a.y; // expected-error {{reference cannot bind to packed field}} +char &raz = a.z; // no-error + +struct __attribute__((packed, aligned(2))) B { + // Regardless of aligned(2) the fields are aligned(1) because of packed. + // The whole struct is aligned(2), though. + short x; + float y; + short z; + char w; +} b; + +const short &crbx = b.x; // no-error +short &rbx = b.x; // expected-error {{reference cannot bind to packed field}} +float &rby = b.y; // expected-error {{reference cannot bind to packed field}} +short &rbz = b.z; // expected-error {{reference cannot bind to packed field}} +char &rbw = b.w; // no-error + +struct __attribute__((packed)) B2 { + short x __attribute__((aligned(2))); + float y; + short z __attribute__((aligned(4))); + char w; +} b2; + +short &rb2x = b2.x; // no-error +short &rb2z = b2.z; // no-error + +struct C { + int c; +}; + +struct __attribute__((packed)) D { + char x; + int y; + C z; +} d; + +C &rcz = d.z; // expected-error {{reference cannot bind to packed field}} +int &rczc = d.z.c; // expected-error {{reference cannot bind to packed field}} + +struct E { +int x __attribute__((packed)); +C y __attribute__((packed)); +C z; +} e; + +int& rex = e.x; // expected-error {{reference cannot bind to packed field}} +C& rey = e.y; // expected-error {{reference cannot bind to packed field}} +C& rez = e.z; // no-error + +struct NonTrivialCopy +{ +int w; +NonTrivialCopy(); +NonTrivialCopy(const NonTrivialCopy&); +}; + +struct F +{ +char c; +NonTrivialCopy x __attribute__((packed)); +int w __attribute__((packed)); +} f; + + +void fun1(int &); +void fun2(const int &); + +void bar() +{ +const NonTrivialCopy& rx = f.x; // expected-error {{reference cannot bind to packed field}} +const int &w = f.w; // no-error + +fun1(f.w); // expected-error {{reference cannot bind to packed field}} + // expected-note@76 {{passing argument to parameter here}} +fun2(f.w); // no-error +} + +struct __attribute__((packed)) IgnorePacked { + int c; + NonTrivialCopy x; // expected-warning {{ignoring packed attribute because of unpacked non-POD field}} +} nopacked1; + +int &ok1 = nopacked1.c; // no-error + +template +struct __attribute__((packed)) IgnorePackedTpl { + int c; + T x; +}; + +IgnorePackedTpl nopacked2; // expected-warning@99 {{ignoring packed attribute because of unpacked non-POD field}} + // expected-note@102 {{in instantiation of template class}} +int &ok2 = nopacked2.c; // no-error + +IgnorePackedTpl packed3; +int &error3 = packed3.c; // expected-error {{reference cannot bind to packed field}} Index: test/CodeGenCXX/pod-member-memcpys.cpp === --- test/CodeGenCXX/pod-member-memcpys.cpp +++ test/CodeGenCXX/pod-member-memcpys.cpp @@ -168,7 +168,7 @@ // PackedMembers copy-assignment: // CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.PackedMembers* @_ZN13PackedMembersaSERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}})) // CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_ -// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}}) +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}}) // CHECK: ret %struct.PackedMembers* // COPY-CONSTRUCTORS: @@ -183,7 +183,7 @@ // PackedMembers copy-assignment: // CHECK-LABEL: define linkonce_odr void @_ZN13PackedMembersC2ERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}})) // CHECK: call void @_ZN6NonPODC1ERKS_ -// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}}) +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}}) // CHECK: ret void CALL_CC(BitfieldMember2) Index: lib/Sema/SemaInit.cpp === --- lib/Sema/S
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
jhen created this revision. jhen added a reviewer: jlebar. jhen added subscribers: cfe-commits, hfinkel. This is an improvement on https://reviews.llvm.org/rL288448 where address sanitization was listed as supported for the CudaToolChain. Since the intent is for the CudaToolChain not to reject any flags supported by the host compiler, this patch switches to forwarding the CudaToolChain sanitizer support to the host toolchain rather than explicitly whitelisting address sanitization. Thanks to hfinkel for this suggestion. https://reviews.llvm.org/D27351 Files: clang/lib/Driver/ToolChains.cpp Index: clang/lib/Driver/ToolChains.cpp === --- clang/lib/Driver/ToolChains.cpp +++ clang/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain Index: clang/lib/Driver/ToolChains.cpp === --- clang/lib/Driver/ToolChains.cpp +++ clang/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
jlebar accepted this revision. jlebar added a comment. This revision is now accepted and ready to land. I like it! https://reviews.llvm.org/D27351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
hfinkel accepted this revision. hfinkel added a reviewer: hfinkel. hfinkel added a comment. LGTM https://reviews.llvm.org/D27351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288512 - [CUDA] Forward sanitizer support to host toolchain
Author: jhen Date: Fri Dec 2 11:32:18 2016 New Revision: 288512 URL: http://llvm.org/viewvc/llvm-project?rev=288512&view=rev Log: [CUDA] Forward sanitizer support to host toolchain Summary: This is an improvement on rL288448 where address sanitization was listed as supported for the CudaToolChain. Since the intent is for the CudaToolChain not to reject any flags supported by the host compiler, this patch switches to forwarding the CudaToolChain sanitizer support to the host toolchain rather than explicitly whitelisting address sanitization. Thanks to hfinkel for this suggestion. Reviewers: jlebar Subscribers: hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D27351 Modified: cfe/trunk/lib/Driver/ToolChains.cpp Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288512&r1=288511&r2=288512&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Dec 2 11:32:18 2016 @@ -4974,12 +4974,16 @@ void CudaToolChain::AddIAMCUIncludeArgs( } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27351: [CUDA] Forward sanitizer support to host toolchain
This revision was automatically updated to reflect the committed changes. Closed by commit rL288512: [CUDA] Forward sanitizer support to host toolchain (authored by jhen). Changed prior to commit: https://reviews.llvm.org/D27351?vs=80082&id=80084#toc Repository: rL LLVM https://reviews.llvm.org/D27351 Files: cfe/trunk/lib/Driver/ToolChains.cpp Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain Index: cfe/trunk/lib/Driver/ToolChains.cpp === --- cfe/trunk/lib/Driver/ToolChains.cpp +++ cfe/trunk/lib/Driver/ToolChains.cpp @@ -4974,12 +4974,16 @@ } SanitizerMask CudaToolChain::getSupportedSanitizers() const { - // The CudaToolChain only supports address sanitization in the sense that it - // allows ASAN arguments on the command line. It must not error out on these - // command line arguments because the host code compilation supports them. - // However, it doesn't actually do any address sanitization for device code; - // instead, it just ignores any ASAN command line arguments it sees. - return SanitizerKind::Address; + // The CudaToolChain only supports sanitizers in the sense that it allows + // sanitizer arguments on the command line if they are supported by the host + // toolchain. The CudaToolChain will actually ignore any command line + // arguments for any of these "supported" sanitizers. That means that no + // sanitization of device code is actually supported at this time. + // + // This behavior is necessary because the host and device toolchains + // invocations often share the command line, so the device toolchain must + // tolerate flags meant only for the host toolchain. + return HostTC.getSupportedSanitizers(); } /// XCore tool chain ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16533: Bug 20796 - GCC's -Wstrict-prototypes warning not implemented in Clang
bruno added a comment. Hi Alex, thanks for following up with this! Comment at: lib/Sema/SemaDecl.cpp:11819 + // Warn if K&R function is defined without previous declaration + // declaration. This warning is issued only if the difinition itself + // does not provide a prototype. Only K&R definitions do not There's an extra 'declaration' here Comment at: lib/Sema/SemaType.cpp:4189 + if (D.getFunctionDefinitionKind() == FDK_Declaration && + FTI.NumParams == 0 && !LangOpts.CPlusPlus) { +S.Diag(DeclType.Loc, diag::warn_strict_prototypes) No need for the curly braces here! Repository: rL LLVM https://reviews.llvm.org/D16533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288520 - With LTO and profile-use, enable hotness info in opt remarks
Author: anemet Date: Fri Dec 2 11:54:34 2016 New Revision: 288520 URL: http://llvm.org/viewvc/llvm-project?rev=288520&view=rev Log: With LTO and profile-use, enable hotness info in opt remarks This is to match the behavior of non-LTO; when -fsave-optimization-record is passed and PGO is available we enable the generation of hotness information in the optimization records. Differential Revision: https://reviews.llvm.org/D27332 Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/darwin-ld.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288520&r1=288519&r2=288520&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Dec 2 11:54:34 2016 @@ -3644,6 +3644,19 @@ VersionTuple visualstudio::getMSVCVersio return VersionTuple(); } +static Arg *getLastProfileUseArg(const ArgList &Args) { + auto *ProfileUseArg = Args.getLastArg( + options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, + options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, + options::OPT_fno_profile_instr_use); + + if (ProfileUseArg && + ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) +ProfileUseArg = nullptr; + + return ProfileUseArg; +} + static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, const InputInfo &Output, const ArgList &Args, ArgStringList &CmdArgs) { @@ -3668,13 +3681,7 @@ static void addPGOAndCoverageFlags(Compi D.Diag(diag::err_drv_argument_not_allowed_with) << PGOGenerateArg->getSpelling() << ProfileGenerateArg->getSpelling(); - auto *ProfileUseArg = Args.getLastArg( - options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, - options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, - options::OPT_fno_profile_instr_use); - if (ProfileUseArg && - ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) -ProfileUseArg = nullptr; + auto *ProfileUseArg = getLastProfileUseArg(Args); if (PGOGenerateArg && ProfileUseArg) D.Diag(diag::err_drv_argument_not_allowed_with) @@ -8436,6 +8443,11 @@ void darwin::Linker::ConstructJob(Compil F = Output.getFilename(); F += ".opt.yaml"; CmdArgs.push_back(Args.MakeArgString(F)); + +if (getLastProfileUseArg(Args)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-lto-pass-remarks-with-hotness"); +} } // It seems that the 'e' option is completely ignored for dynamic executables Modified: cfe/trunk/test/Driver/darwin-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=288520&r1=288519&r2=288520&view=diff == --- cfe/trunk/test/Driver/darwin-ld.c (original) +++ cfe/trunk/test/Driver/darwin-ld.c Fri Dec 2 11:54:34 2016 @@ -332,7 +332,12 @@ // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### -o foo/bar.out 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log // PASS_REMARKS_OUTPUT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" +// PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks-with-hotness // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log // PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "a.out.opt.yaml" + +// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log +// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log +// PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27332: With LTO and profile-use, enable hotness info in opt remarks
This revision was automatically updated to reflect the committed changes. Closed by commit rL288520: With LTO and profile-use, enable hotness info in opt remarks (authored by anemet). Changed prior to commit: https://reviews.llvm.org/D27332?vs=80026&id=80088#toc Repository: rL LLVM https://reviews.llvm.org/D27332 Files: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/darwin-ld.c Index: cfe/trunk/test/Driver/darwin-ld.c === --- cfe/trunk/test/Driver/darwin-ld.c +++ cfe/trunk/test/Driver/darwin-ld.c @@ -332,7 +332,12 @@ // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### -o foo/bar.out 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log // PASS_REMARKS_OUTPUT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" +// PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks-with-hotness // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log // PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "a.out.opt.yaml" + +// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log +// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log +// PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness" Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -3644,6 +3644,19 @@ return VersionTuple(); } +static Arg *getLastProfileUseArg(const ArgList &Args) { + auto *ProfileUseArg = Args.getLastArg( + options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, + options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, + options::OPT_fno_profile_instr_use); + + if (ProfileUseArg && + ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) +ProfileUseArg = nullptr; + + return ProfileUseArg; +} + static void addPGOAndCoverageFlags(Compilation &C, const Driver &D, const InputInfo &Output, const ArgList &Args, ArgStringList &CmdArgs) { @@ -3668,13 +3681,7 @@ D.Diag(diag::err_drv_argument_not_allowed_with) << PGOGenerateArg->getSpelling() << ProfileGenerateArg->getSpelling(); - auto *ProfileUseArg = Args.getLastArg( - options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_EQ, - options::OPT_fprofile_use, options::OPT_fprofile_use_EQ, - options::OPT_fno_profile_instr_use); - if (ProfileUseArg && - ProfileUseArg->getOption().matches(options::OPT_fno_profile_instr_use)) -ProfileUseArg = nullptr; + auto *ProfileUseArg = getLastProfileUseArg(Args); if (PGOGenerateArg && ProfileUseArg) D.Diag(diag::err_drv_argument_not_allowed_with) @@ -8436,6 +8443,11 @@ F = Output.getFilename(); F += ".opt.yaml"; CmdArgs.push_back(Args.MakeArgString(F)); + +if (getLastProfileUseArg(Args)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-lto-pass-remarks-with-hotness"); +} } // It seems that the 'e' option is completely ignored for dynamic executables Index: cfe/trunk/test/Driver/darwin-ld.c === --- cfe/trunk/test/Driver/darwin-ld.c +++ cfe/trunk/test/Driver/darwin-ld.c @@ -332,7 +332,12 @@ // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### -o foo/bar.out 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log // PASS_REMARKS_OUTPUT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" +// PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks-with-hotness // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -### 2> %t.log // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT_NO_O %s < %t.log // PASS_REMARKS_OUTPUT_NO_O: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "a.out.opt.yaml" + +// RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record -fprofile-instr-use=blah -### -o foo/bar.out 2> %t.log +// RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_HOTNESS %s < %t.log +// PASS_REMARKS_WITH_HOTNESS: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-with-hotness" Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -3644,6 +3644,19 @@ return VersionTuple(); } +static Arg *getLastProfileUseArg(const ArgList &Args) { + auto *ProfileUseArg = Args.getLastArg( + options::OPT_fprofile_instr_use, options::OPT_fprofile_instr_use_E
[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC
bruno added a comment. > The right thing to do would be to track the set of headers whose #import / > #include-with-#pragma-once is > visible, and only skip inclusions if there is a *visible* #import / > #include-with-#pragma-once of that header. This makes sense, but the situation is a bit more weird with the builtins: at the time clang skips entering /Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h because there's already a #import associated with it, clang tries to get the module, in this case it finds "libc++.stddef", but `makeModuleVisible` does not export the contents of /Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h: // If we don't need to enter the file, stop now. if (!ShouldEnter) { // If this is a module import, make it visible if needed. if (auto *M = SuggestedModule.getModule()) { makeModuleVisible(M, HashLoc); ... } return; } (lldb) p M->dump() module stddef [system] { header "/Users/bruno/Dev/srcs/llvm/debug/bin/../lib/clang/4.0.0/include/stddef.h" textual header "stddef.h" export * } Is this what it's supposed to happen with a (textual) builtin header? It seems to me that since the first #import was done after collecting the headers to build the module, the content should already been present/available in the AST for the module. https://reviews.llvm.org/D26267 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27068: Improve string::find
hiraditya updated this revision to Diff 80090. hiraditya added a comment. Addressed Tim's comments. https://reviews.llvm.org/D27068 Files: libcxx/benchmarks/string.bench.cpp libcxx/include/__string Index: libcxx/include/__string === --- libcxx/include/__string +++ libcxx/include/__string @@ -538,25 +538,60 @@ return static_cast<_SizeT>(__r - __p); } +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 +const _CharT * +__search_substring(const _CharT *__first1, const _CharT *__last1, + const _CharT * __first2, const _CharT * __last2) +{ +// Take advantage of knowing source and pattern lengths. +// Stop short when source is smaller than pattern. +ptrdiff_t __len2 = __last2 - __first2; +if (__len2 == 0) +return __first1; +ptrdiff_t __len1 = __last1 - __first1; +if (__len1 < __len2) +return __last1; + +// First element of __first2 is loop invariant. +_CharT __f2 = *__first2; +while (true) +{ + __len1 = __last1 - __first1; + if (__len1 < __len2) + return __last1; + + __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); + if (__first1 == 0) +return __last1; + + // Comparing __first2 as well because the first pointer will be aligned + // and we dont know if __first1+1 is going to be aligned. + if (_Traits::compare(__first1, __first2, __len2) == 0) +return __first1; + +++__first1; +} +} + template inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY __str_find(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { -if (__pos > __sz || __sz - __pos < __n) +if (__pos > __sz) return __npos; -if (__n == 0) + +if (__n == 0) // There is nothing to search, just return __pos return __pos; -const _CharT* __r = -_VSTD::__search(__p + __pos, __p + __sz, -__s, __s + __n, _Traits::eq, -random_access_iterator_tag(), random_access_iterator_tag()).first; + +const _CharT* __r = __search_substring<_CharT, _Traits>(__p + __pos, __p + __sz, +__s, __s + __n); if (__r == __p + __sz) return __npos; return static_cast<_SizeT>(__r - __p); } - // __str_rfind template Index: libcxx/benchmarks/string.bench.cpp === --- /dev/null +++ libcxx/benchmarks/string.bench.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +#include "benchmark/benchmark_api.h" +#include "GenerateInput.hpp" + +constexpr std::size_t MAX_STRING_LEN = 8<<14; + +// Benchmark when there is no match. +static void BM_StringFindNoMatch(benchmark::State& state) { + std::string s1(state.range(0), '-'); + std::string s2(8, '*'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindNoMatch)->Range(10,MAX_STRING_LEN); + +// Benchmark when the string matches first time. +static void BM_StringFindAllMatch(benchmark::State& state) { + std::string s1(MAX_STRING_LEN, '-'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindAllMatch)->Range(1,MAX_STRING_LEN); + +// Benchmark when the string matches somewhere in the end. +static void BM_StringFindMatch1(benchmark::State& state) { + std::string s1(MAX_STRING_LEN/2, '*'); + s1 += std::string(state.range(0), '-'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindMatch1)->Range(1,MAX_STRING_LEN/4); + +// Benchmark when the string matches somewhere from middle to the end. +static void BM_StringFindMatch2(benchmark::State& state) { + std::string s1(MAX_STRING_LEN/2, '*'); + s1 += std::string(state.range(0), '-'); + s1 += std::string(state.range(0), '*'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindMatch2)->Range(1,MAX_STRING_LEN/4); + +BENCHMARK_MAIN() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27068: Improve string::find
mclow.lists added a comment. This is starting to look good. Comment at: libcxx/include/__string:549 +// Stop short when source is smaller than pattern. +ptrdiff_t __len2 = __last2 - __first2; +if (__len2 == 0) Is there a reason that you calculate the end pointer(s) from `first + len` in the calling function, then recover the length here? Also, `__len1` and `__len2` should be const. https://reviews.llvm.org/D27068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27226: [MS ABI] Implement more of the Itanium mangling rules
majnemer updated this revision to Diff 80096. majnemer added a comment. - Simplify the mangling a little bit https://reviews.llvm.org/D27226 Files: lib/AST/MicrosoftMangle.cpp test/CodeGenCXX/mangle-ms-cxx11.cpp Index: test/CodeGenCXX/mangle-ms-cxx11.cpp === --- test/CodeGenCXX/mangle-ms-cxx11.cpp +++ test/CodeGenCXX/mangle-ms-cxx11.cpp @@ -318,3 +318,28 @@ // CHECK-DAG: @"\01?unaligned_foo8@unaligned_foo8_S@@QFCEXXZ" +namespace PR31197 { +struct A { + // CHECK-DAG: define linkonce_odr x86_thiscallcc i32* @"\01??R@x@A@PR31197@@QBE@XZ"( + int *x = []() { +static int white; +// CHECK-DAG: @"\01?white@?1???R@x@A@PR31197@@QBE@XZ@4HA" +return &white; + }(); + // CHECK-DAG: define linkonce_odr x86_thiscallcc i32* @"\01??R@y@A@PR31197@@QBE@XZ"( + int *y = []() { +static int black; +// CHECK-DAG: @"\01?black@?1???R@y@A@PR31197@@QBE@XZ@4HA" +return &black; + }(); + using FPtrTy = void(void); + static void default_args(FPtrTy x = [] {}, FPtrTy y = [] {}, int z = [] { return 1; }() + [] { return 2; }()) {} + // CHECK-DAG: @"\01??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( + // CHECK-DAG: @"\01??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( + // CHECK-DAG: @"\01??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( + // CHECK-DAG: @"\01??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( +}; +A a; + +int call_it = (A::default_args(), 1); +} Index: lib/AST/MicrosoftMangle.cpp === --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -66,6 +66,16 @@ } }; +static const DeclContext * +getLambdaDefaultArgumentDeclContext(const Decl *D) { + if (const auto *RD = dyn_cast(D)) +if (RD->isLambda()) + if (const auto *Parm = + dyn_cast_or_null(RD->getLambdaContextDecl())) +return Parm->getDeclContext(); + return nullptr; +} + /// \brief Retrieve the declaration context that should be used when mangling /// the given declaration. static const DeclContext *getEffectiveDeclContext(const Decl *D) { @@ -75,12 +85,8 @@ // not the case: the lambda closure type ends up living in the context // where the function itself resides, because the function declaration itself // had not yet been created. Fix the context here. - if (const CXXRecordDecl *RD = dyn_cast(D)) { -if (RD->isLambda()) - if (ParmVarDecl *ContextParam = - dyn_cast_or_null(RD->getLambdaContextDecl())) -return ContextParam->getDeclContext(); - } + if (const auto *LDADC = getLambdaDefaultArgumentDeclContext(D)) +return LDADC; // Perform the same check for block literals. if (const BlockDecl *BD = dyn_cast(D)) { @@ -112,14 +118,6 @@ return FD; } -static bool isLambda(const NamedDecl *ND) { - const CXXRecordDecl *Record = dyn_cast(ND); - if (!Record) -return false; - - return Record->isLambda(); -} - /// MicrosoftMangleContextImpl - Overrides the default MangleContext for the /// Microsoft Visual C++ ABI. class MicrosoftMangleContextImpl : public MicrosoftMangleContext { @@ -200,9 +198,11 @@ // Lambda closure types are already numbered, give out a phony number so // that they demangle nicely. -if (isLambda(ND)) { - disc = 1; - return true; +if (const auto *RD = dyn_cast(ND)) { + if (RD->isLambda()) { +disc = 1; +return true; + } } // Use the canonical number for externally visible decls. @@ -824,16 +824,41 @@ if (const CXXRecordDecl *Record = dyn_cast(TD)) { if (Record->isLambda()) { llvm::SmallString<10> Name("getLambdaContextDecl(); + unsigned LambdaManglingNumber = Record->getLambdaManglingNumber(); unsigned LambdaId; - if (Record->getLambdaManglingNumber()) -LambdaId = Record->getLambdaManglingNumber(); + const ParmVarDecl *Parm = + dyn_cast_or_null(LambdaContextDecl); + const FunctionDecl *Func = + Parm ? dyn_cast(Parm->getDeclContext()) : nullptr; + + if (Func) { +unsigned DefaultArgNo = +Func->getNumParams() - Parm->getFunctionScopeIndex(); +Name += llvm::utostr(DefaultArgNo); +Name += "_"; + } + + if (LambdaManglingNumber) +LambdaId = LambdaManglingNumber; else LambdaId = Context.getLambdaId(Record); Name += llvm::utostr(LambdaId); Name += ">"; mangleSourceName(Name); + + // If the context of a closure type is an initializer for a class + // member (static or nonstatic), it is encoded in a qualified name. + if (LambdaManglingNumber && LambdaContextDecl) { +if ((isa(LambdaContextDecl) || + isa(LambdaContextDecl)) && +LambdaContextDecl->getDeclContext()->isRecord(
[PATCH] D27358: V-base dtor called more than needed when throw happens in v-base ctor in window. Need add "complete object flag" check in eh cleanup code.
jyu2 created this revision. jyu2 added reviewers: cfe-commits, erichkeane, majnemer, rnk. jyu2 set the repository for this revision to rL LLVM. jyu2 added a project: clang-c. The problem only happen on window ( A MSVC compatibility issues) The nature of the problem is virtual base dtor called more than it is needed after exception throw in inheriting base class(with virtual bases) ctor. The root problem is when throw happen, not all virtual base classes have been contructed, so not all virtual base dtors are need to call for ehcleanup. clang has code to handle vbase initialization: basically add check for "complete object flag" before call to v-base ctor. But that part is missing for cleanup code. To fix this add similar code as v-base init to cleanup code, same algorithm. 1> Add new routine: EmitDtorCompleteObjectHandler With corresponding to EmitCtorCompleteObjectHandler 2> In the EmitDestructorCal Call EmitDtorCompleteObjectHandler when generate ehcleanup inside ctor. Just add check for "complete object flag" before call to v-base dtor. Please let me know you need more info. Repository: rL LLVM https://reviews.llvm.org/D27358 Files: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Index: lib/CodeGen/MicrosoftCXXABI.cpp === --- lib/CodeGen/MicrosoftCXXABI.cpp +++ lib/CodeGen/MicrosoftCXXABI.cpp @@ -164,6 +164,9 @@ llvm::BasicBlock * EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, const CXXRecordDecl *RD) override; + + llvm::BasicBlock * + EmitDtorCompleteObjectHandler(CodeGenFunction &CGF); void initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF, const CXXRecordDecl *RD) override; @@ -1127,6 +1130,25 @@ return SkipVbaseCtorsBB; } +llvm::BasicBlock * +MicrosoftCXXABI::EmitDtorCompleteObjectHandler(CodeGenFunction &CGF) { + llvm::Value *IsMostDerivedClass = getStructorImplicitParamValue(CGF); + assert(IsMostDerivedClass && + "ctor for a class with virtual bases must have an implicit parameter"); + llvm::Value *IsCompleteObject = + CGF.Builder.CreateIsNotNull(IsMostDerivedClass, "is_complete_object"); + + llvm::BasicBlock *CallVbaseDtorsBB = CGF.createBasicBlock("Dtor.dtor_vbases"); + llvm::BasicBlock *SkipVbaseDtorsBB = CGF.createBasicBlock("Dtor.skip_vbases"); + CGF.Builder.CreateCondBr(IsCompleteObject, + CallVbaseDtorsBB, SkipVbaseDtorsBB); + + CGF.EmitBlock(CallVbaseDtorsBB); + // CGF will put the base dtor calls in this basic block for us later. + + return SkipVbaseDtorsBB; +} + void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers( CodeGenFunction &CGF, const CXXRecordDecl *RD) { // In most cases, an override for a vbase virtual method can adjust @@ -1502,11 +1524,24 @@ This = adjustThisArgumentForVirtualFunctionCall(CGF, GlobalDecl(DD, Type), This, false); } + + llvm::BasicBlock *BaseDtorEndBB = nullptr; + if (ForVirtualBase && isa(CGF.CurCodeDecl)) { +const CXXRecordDecl *ClassDecl = + cast(CGF.CurCodeDecl)->getParent(); +if (ClassDecl != nullptr && ClassDecl->getNumVBases()) + BaseDtorEndBB = EmitDtorCompleteObjectHandler(CGF); + } CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(), /*ImplicitParam=*/nullptr, /*ImplicitParamTy=*/QualType(), nullptr, getFromDtorType(Type)); + if (BaseDtorEndBB) { +// Complete object handler should continue to be the remaining +CGF.Builder.CreateBr(BaseDtorEndBB); +CGF.EmitBlock(BaseDtorEndBB); + } } void MicrosoftCXXABI::emitVTableTypeMetadata(const VPtrInfo &Info, Index: test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp === --- test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp +++ test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp @@ -278,3 +278,41 @@ // WIN32-LIFETIME: %[[bc2:.*]] = bitcast %"struct.lifetime_marker::C"* %[[c]] to i8* // WIN32-LIFETIME: call void @llvm.lifetime.end(i64 1, i8* %[[bc2]]) } + + +struct class_2 { + int var_0; + class_2() {}; + virtual ~class_2() { + } +}; + +struct class_1 : virtual class_2 { + class_1() {throw "Unhandled exception";} + virtual ~class_1() {} +}; +struct class_0 : class_1 { + class_0() ; + virtual ~class_0() {} +}; + +class_0::class_0() { + // WIN32: define x86_thiscallcc %struct.class_0* @"\01??0class_0@@QAE@XZ"(%struct.class_0* returned %this, i32 %is_most_derived) + // WIN32: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4 + // WIN32: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]] + // WIN32: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0 + // WIN32: br i1 %[[SHOULD_CALL_VB
[PATCH] D27068: Improve string::find
hiraditya added inline comments. Comment at: libcxx/include/__string:549 +// Stop short when source is smaller than pattern. +ptrdiff_t __len2 = __last2 - __first2; +if (__len2 == 0) mclow.lists wrote: > Is there a reason that you calculate the end pointer(s) from `first + len` in > the calling function, then recover the length here? > > Also, `__len1` and `__len2` should be const. Recovering length here is only making the interface uniform, I don't have any specific reason for that. This function is going to be inlined anyways. It started this way because I copied the interface from std::__search in the header file algorithm. len2 can be a const, since len1 changes in the loop, for this to make const I would have to introduce another variable. I'll update the patch. https://reviews.llvm.org/D27068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27360: Fix D26214: Move error handling out of MC and to the callers.
mgrang created this revision. mgrang added reviewers: dgross, echristo, t.p.northover, rengolin, compnerd. mgrang added subscribers: llvm-commits, cfe-commits. mgrang added a project: clang-c. Herald added a subscriber: mehdi_amini. Related llvm patch: https://reviews.llvm.org/D27359 https://reviews.llvm.org/D27360 Files: include/clang/Basic/DiagnosticDriverKinds.td test/Driver/defsym.s tools/driver/cc1as_main.cpp Index: tools/driver/cc1as_main.cpp === --- tools/driver/cc1as_main.cpp +++ tools/driver/cc1as_main.cpp @@ -426,10 +426,23 @@ // Set values for symbols, if any. for (auto &S : Opts.SymbolDefs) { -if (Ctx.setSymbolValue(Parser->getStreamer(), S)) { +auto Pair = StringRef(S).split('='); +auto Sym = Pair.first; +auto Val = Pair.second; + +if (Sym.empty() || Val.empty()) { + Diags.Report(diag::err_drv_defsym_invalid_format) << S; Failed = true; break; } +int64_t Value; +if (Val.getAsInteger(0, Value)) { + Diags.Report(diag::err_drv_defsym_invalid_symval) << Val; + Failed = true; + break; +} + +Ctx.setSymbolValue(Parser->getStreamer(), Sym, Value); } if (!Failed) { Index: test/Driver/defsym.s === --- test/Driver/defsym.s +++ test/Driver/defsym.s @@ -17,6 +17,11 @@ // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc= // RUN: not %clang -c -integrated-as -o /dev/null %s \ -// RUN: -Wa,-defsym,abc=1a2b3c \ +// RUN: -Wa,-defsym,=123 \ // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2 -// CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c +// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: =123 + +// RUN: not %clang -c -integrated-as -o /dev/null %s \ +// RUN: -Wa,-defsym,abc=1a2b3c \ +// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3 +// CHECK-DEFSYM-ERR3: error: Value is not an integer: 1a2b3c Index: include/clang/Basic/DiagnosticDriverKinds.td === --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -277,4 +277,6 @@ InGroup; def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker option">; +def err_drv_defsym_invalid_format : Error<"defsym must be of the form: sym=value: %0">; +def err_drv_defsym_invalid_symval : Error<"Value is not an integer: %0">; } Index: tools/driver/cc1as_main.cpp === --- tools/driver/cc1as_main.cpp +++ tools/driver/cc1as_main.cpp @@ -426,10 +426,23 @@ // Set values for symbols, if any. for (auto &S : Opts.SymbolDefs) { -if (Ctx.setSymbolValue(Parser->getStreamer(), S)) { +auto Pair = StringRef(S).split('='); +auto Sym = Pair.first; +auto Val = Pair.second; + +if (Sym.empty() || Val.empty()) { + Diags.Report(diag::err_drv_defsym_invalid_format) << S; Failed = true; break; } +int64_t Value; +if (Val.getAsInteger(0, Value)) { + Diags.Report(diag::err_drv_defsym_invalid_symval) << Val; + Failed = true; + break; +} + +Ctx.setSymbolValue(Parser->getStreamer(), Sym, Value); } if (!Failed) { Index: test/Driver/defsym.s === --- test/Driver/defsym.s +++ test/Driver/defsym.s @@ -17,6 +17,11 @@ // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc= // RUN: not %clang -c -integrated-as -o /dev/null %s \ -// RUN: -Wa,-defsym,abc=1a2b3c \ +// RUN: -Wa,-defsym,=123 \ // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2 -// CHECK-DEFSYM-ERR2: error: Value is not an integer: 1a2b3c +// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: =123 + +// RUN: not %clang -c -integrated-as -o /dev/null %s \ +// RUN: -Wa,-defsym,abc=1a2b3c \ +// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3 +// CHECK-DEFSYM-ERR3: error: Value is not an integer: 1a2b3c Index: include/clang/Basic/DiagnosticDriverKinds.td === --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -277,4 +277,6 @@ InGroup; def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker option">; +def err_drv_defsym_invalid_format : Error<"defsym must be of the form: sym=value: %0">; +def err_drv_defsym_invalid_symval : Error<"Value is not an integer: %0">; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
mgorny retitled this revision from "[Driver] Support "hardfloat" vendor triples used by Gentoo" to "[Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples". mgorny updated the summary for this revision. mgorny added a reviewer: atanasyan. mgorny updated this revision to Diff 80118. https://reviews.llvm.org/D25686 Files: lib/Driver/ToolChains.cpp test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/armv7a-hardfloat-linux-gnueabi/lib/.keep test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/include/.keep test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o test/Driver/Inputs/gentoo_linux_gcc_armhf_tree/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/include/g++-v4.9.3/.keep test/Driver/linux-ld.c Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -1002,6 +1002,32 @@ // CHECK-DEBIAN-SPARC64: "[[SYSROOT]]/usr/lib/gcc/sparc64-linux-gnu/4.9{{/|}}crtend.o" // CHECK-DEBIAN-SPARC64: "[[SYSROOT]]/usr/lib/gcc/sparc64-linux-gnu/4.9/../../../sparc64-linux-gnu{{/|}}crtn.o" // +// Check Gentoo Linux with GCC installed using arm*-hardfloat-linux-gnu* triples. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7a-hardfloat-linux-gnueabi --rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_armhf_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-ARMHF %s +// CHECK-LD-GENTOO-ARMHF-NOT: warning: +// CHECK-LD-GENTOO-ARMHF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-LD-GENTOO-ARMHF: "--eh-frame-hdr" +// CHECK-LD-GENTOO-ARMHF: "-m" "armelf_linux_eabi" +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/../../../../armv7a-hardfloat-linux-gnueabi/lib" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/../../.." +// CHECK-LD-GENTOO-ARMHF: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// CHECK-LD-GENTOO-ARMHF: "-lc" +// CHECK-LD-GENTOO-ARMHF: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" +// +// Check whether the standard ARM triples can find Gentoo gcc. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7a-unknown-linux-gnueabihf --rtlib=platform \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_armhf_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-ARMHF %s +// // Test linker invocation on Android. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=arm-linux-androideabi -rtlib=platform \ Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -1557,14 +1557,21 @@ static const char *const ARMLibDirs[] = {"/lib"}; static const char *const ARMTriples[] = {"arm-linux-gnueabi", "arm-linux-androideabi"}; + // arm*-hardfloat-* triples are used by Gentoo static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", + "armv6j-hardfloat-linux-gnueabi", + "armv7a-hardfloat-linux-gnueabi", "armv7hl-redhat-linux-gnueabi"}; static const char *const ARMebLibDirs[] = {"/lib"}; static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", "armeb-linux-androideabi"}; static const char *const ARMebHFTriples[] = { "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"}; + static const char *const ARMHFMuslTriples[] = { + "armv6j-hardfloat-linux-musleabi", + "armv7a-hardfloat-linux-musleabi"}; + static const char *const X86_64LibDirs[] = {"/lib64", "/lib"}; static const char *const X86_64Triples[] = { "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", @@ -1664,6 +1671,8 @@ LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); +} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples)); } else { TripleAliases.append(begin(ARMTriples), end(ARMTriples)); } Index: test/Driver/linux-ld.c === --- test/Driver/linux-ld.c +++ test/Driver/linux-ld.c @@ -1002,6 +1002,32 @@ // CHECK-DEBIA
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
rengolin added a reviewer: compnerd. rengolin added inline comments. Comment at: lib/Driver/ToolChains.cpp:1674 TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); +} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples)); You're not testing this... Comment at: test/Driver/linux-ld.c:1016 +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" where is 4.9.3 coming from? https://reviews.llvm.org/D25686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27279: Store decls in prototypes on the declarator instead of in the AST
thakis added a comment. (Unrelated, but if you're looking at memory: When I was looking at it a while ago, IIRC a surprising amount of memory was taken up by CXXBasePaths objects, and just reordering fields to pack it better made that object several bytes smaller. IIRC I accidentally reverted my local patch for this, but if you're in the mood it's probably not too hard to recreate) https://reviews.llvm.org/D27279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288534 - [Sema] Reset a BumpPtrAllocator on clear(). NFC.
Author: gbiv Date: Fri Dec 2 15:00:12 2016 New Revision: 288534 URL: http://llvm.org/viewvc/llvm-project?rev=288534&view=rev Log: [Sema] Reset a BumpPtrAllocator on clear(). NFC. Looks like the reset() call was omitted by accident. Modified: cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=288534&r1=288533&r2=288534&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Dec 2 15:00:12 2016 @@ -817,6 +817,7 @@ void OverloadCandidateSet::destroyCandid void OverloadCandidateSet::clear() { destroyCandidates(); + ConversionSequenceAllocator.Reset(); NumInlineSequences = 0; Candidates.clear(); Functions.clear(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
mgorny added inline comments. Comment at: lib/Driver/ToolChains.cpp:1674 TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); +} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples)); rengolin wrote: > You're not testing this... Well, I presumed I don't have to test every single possible triple. But sure, I can add a test for that. Comment at: test/Driver/linux-ld.c:1016 +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" rengolin wrote: > where is 4.9.3 coming from? It's the version used in the input tree, i.e. the two added files above. https://reviews.llvm.org/D25686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
rengolin added inline comments. Comment at: lib/Driver/ToolChains.cpp:1674 TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); +} else if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples)); mgorny wrote: > rengolin wrote: > > You're not testing this... > Well, I presumed I don't have to test every single possible triple. But sure, > I can add a test for that. You should test every new thing that you add. Comment at: test/Driver/linux-ld.c:1016 +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" mgorny wrote: > rengolin wrote: > > where is 4.9.3 coming from? > It's the version used in the input tree, i.e. the two added files above. Right, I mean is this "4.9.3" there because the driver "found" it there, or is it generated by the compiler version you have on your machine, and that's why you created the directory with "4.9.3" in it? I'm worried that if it's the latter, the test will fail on any machine that doesn't have that compiler version. But I really don't know how it works, so it was an honest question. :) https://reviews.llvm.org/D25686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288536 - Add tests for libc++'s constexpr variant copy/move extension
Author: ericwf Date: Fri Dec 2 15:17:51 2016 New Revision: 288536 URL: http://llvm.org/viewvc/llvm-project?rev=288536&view=rev Log: Add tests for libc++'s constexpr variant copy/move extension Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=288536&r1=288535&r2=288536&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Fri Dec 2 15:17:51 2016 @@ -385,6 +385,29 @@ void test_copy_assignment_different_inde #endif } +template +constexpr bool test_constexpr_assign_extension_imp( +std::variant&& v, ValueType&& new_value) +{ + const std::variant cp( + std::forward(new_value)); + v = cp; + return v.index() == NewIdx && +std::get(v) == std::get(cp); +} + +void test_constexpr_move_ctor_extension() { +#ifdef _LIBCPP_VERSION + using V = std::variant; + static_assert(std::is_trivially_copyable::value, ""); + static_assert(std::is_trivially_copy_assignable::value, ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(42l), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(nullptr), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<1>(V(42l), nullptr), ""); + static_assert(test_constexpr_assign_extension_imp<2>(V(42l), 101), ""); +#endif +} + int main() { test_copy_assignment_empty_empty(); test_copy_assignment_non_empty_empty(); @@ -393,4 +416,5 @@ int main() { test_copy_assignment_different_index(); test_copy_assignment_sfinae(); test_copy_assignment_not_noexcept(); + test_constexpr_copy_assignment_extension(); } Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=288536&r1=288535&r2=288536&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp Fri Dec 2 15:17:51 2016 @@ -308,6 +308,29 @@ void test_move_assignment_different_inde #endif } +template +constexpr bool test_constexpr_assign_extension_imp( +std::variant&& v, ValueType&& new_value) +{ + std::variant v2( + std::forward(new_value)); + const auto cp = v2; + v = std::move(v2); + return v.index() == NewIdx && +std::get(v) == std::get(cp); +} + +void test_constexpr_move_ctor_extension() { +#ifdef _LIBCPP_VERSION + using V = std::variant; + static_assert(std::is_trivially_copyable::value, ""); + static_assert(std::is_trivially_move_assignable::value, ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(42l), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(nullptr), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<1>(V(42l), nullptr), ""); + static_assert(test_constexpr_assign_extension_imp<2>(V(42l), 101), ""); +#endif +} int main() { test_move_assignment_empty_empty(); test_move_assignment_non_empty_empty(); @@ -316,4 +339,5 @@ int main() { test_move_assignment_different_index(); test_move_assignment_sfinae(); test_move_assignment_noexcept(); + test_constexpr_move_assignment_extension(); } Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp?rev=288536&r1=288535&r2=288536&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp Fri Dec 2 15:17:51 2016 @@ -130,8 +130,30 @@ void test_copy_ctor_valueless_by_excepti #endif } +template +constexpr bool test_constexpr_copy_ctor_extension_imp( +std::variant const& v) +{ + auto v2 = v; + return v2.index() == v.index() && + v2.index() == Idx && +std::get(v2) == std::get(v); +} + +void test_constexpr_copy_ctor_extension() { +#ifdef _LIBCPP_VERSION + using V = std::variant; +
[libcxx] r288538 - Fix copy/paste errors in new variant tests
Author: ericwf Date: Fri Dec 2 15:32:35 2016 New Revision: 288538 URL: http://llvm.org/viewvc/llvm-project?rev=288538&view=rev Log: Fix copy/paste errors in new variant tests Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=288538&r1=288537&r2=288538&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Fri Dec 2 15:32:35 2016 @@ -387,16 +387,16 @@ void test_copy_assignment_different_inde template constexpr bool test_constexpr_assign_extension_imp( -std::variant&& v, ValueType&& new_value) +std::variant&& v, ValueType&& new_value) { - const std::variant cp( + const std::variant cp( std::forward(new_value)); v = cp; return v.index() == NewIdx && std::get(v) == std::get(cp); } -void test_constexpr_move_ctor_extension() { +void test_constexpr_copy_assignment_extension() { #ifdef _LIBCPP_VERSION using V = std::variant; static_assert(std::is_trivially_copyable::value, ""); Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=288538&r1=288537&r2=288538&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp Fri Dec 2 15:32:35 2016 @@ -310,9 +310,9 @@ void test_move_assignment_different_inde template constexpr bool test_constexpr_assign_extension_imp( -std::variant&& v, ValueType&& new_value) +std::variant&& v, ValueType&& new_value) { - std::variant v2( + std::variant v2( std::forward(new_value)); const auto cp = v2; v = std::move(v2); @@ -320,7 +320,7 @@ constexpr bool test_constexpr_assign_ext std::get(v) == std::get(cp); } -void test_constexpr_move_ctor_extension() { +void test_constexpr_move_assignment_extension() { #ifdef _LIBCPP_VERSION using V = std::variant; static_assert(std::is_trivially_copyable::value, ""); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxxabi] r288457 - Update implementation of ABI support for throwing noexcept function pointers
It's been a while, and new patches are coming. Should we just revert this for now? --renato On 2 December 2016 at 10:13, Renato Golin wrote: > On 2 December 2016 at 02:06, Richard Smith via cfe-commits > wrote: >> Author: rsmith >> Date: Thu Dec 1 20:06:53 2016 >> New Revision: 288457 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=288457&view=rev >> Log: >> Update implementation of ABI support for throwing noexcept function pointers >> and catching as non-noexcept to match the final design per discusson on >> cxx-abi-dev. > > Hi Richard, > > I hope you've seen this: > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/4 > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions/builds/6 > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/97 > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/109 > > error: exception specifications are not allowed in type aliases > template using FnType = void() noexcept(Noexcept); > > error: exception specifications are not allowed in type aliases > template using FnType = void (X::*)() noexcept(Noexcept); > > cheers, > --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26691: [analyzer] Run clang-format and fix style
ddcc updated this revision to Diff 80128. ddcc added a comment. Un-change comments, misc. changes https://reviews.llvm.org/D26691 Files: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.h === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.h +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.h @@ -24,78 +24,74 @@ class SimpleConstraintManager : public ConstraintManager { SubEngine *SU; SValBuilder &SVB; + public: - SimpleConstraintManager(SubEngine *subengine, SValBuilder &SB) -: SU(subengine), SVB(SB) {} + SimpleConstraintManager(SubEngine *SE, SValBuilder &SB) : SU(SE), SVB(SB) {} ~SimpleConstraintManager() override; //===--===// // Common implementation for the interface provided by ConstraintManager. //===--===// - ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, -bool Assumption) override; + ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond, + bool Assumption) override; - ProgramStateRef assume(ProgramStateRef state, NonLoc Cond, bool Assumption); + ProgramStateRef assume(ProgramStateRef State, NonLoc Cond, bool Assumption); - ProgramStateRef assumeInclusiveRange(ProgramStateRef State, - NonLoc Value, - const llvm::APSInt &From, - const llvm::APSInt &To, - bool InRange) override; + ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, + const llvm::APSInt &From, + const llvm::APSInt &To, + bool InRange) override; - ProgramStateRef assumeSymRel(ProgramStateRef state, - const SymExpr *LHS, - BinaryOperator::Opcode op, - const llvm::APSInt& Int); + ProgramStateRef assumeSymRel(ProgramStateRef State, const SymExpr *LHS, + BinaryOperator::Opcode Op, + const llvm::APSInt &Int); ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange); - protected: - //===--===// // Interface that subclasses must implement. //===--===// - // Each of these is of the form "$sym+Adj <> V", where "<>" is the comparison + // Each of these is of the form "$Sym+Adj <> V", where "<>" is the comparison // operation for the method being invoked. - virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, + const llvm::APSInt &Adjustment) = 0; - virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym, - const llvm::APSInt& V, - const llvm::APSInt& Adjustment) = 0; + virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym, + const llvm::APSInt &V, +
[PATCH] D26691: [analyzer] Run clang-format and fix style
ddcc added inline comments. Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:459 // Notice that the lower bound is greater than the upper bound. - RangeSet New = GetRange(St, Sym).Intersect(getBasicVals(), F, Upper, Lower); + RangeSet New = getRange(St, Sym).Intersect(getBasicVals(), F, Upper, Lower); return New.isEmpty() ? nullptr : St->set(Sym, New); zaks.anna wrote: > We should use lower case function names. Are you saying more functions should be changed to lowercase (e.g. intersect)? Or that `getRange` should be `getrange`? https://reviews.llvm.org/D26691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager
ddcc updated this revision to Diff 80129. ddcc added a comment. Rebase, move `assumeSymRel()` to RangedConstraintManager, make `assumeSymUnsupported` pure virtual in SimpleConstraintManager. https://reviews.llvm.org/D26061 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h lib/StaticAnalyzer/Core/CMakeLists.txt lib/StaticAnalyzer/Core/ConstraintManager.cpp lib/StaticAnalyzer/Core/RangeConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.cpp lib/StaticAnalyzer/Core/RangedConstraintManager.h lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp lib/StaticAnalyzer/Core/SimpleConstraintManager.h Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp === --- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp +++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp @@ -7,12 +7,12 @@ // //===--===// // -// This file defines SimpleConstraintManager, a class that holds code shared -// between BasicConstraintManager and RangeConstraintManager. +// This file defines SimpleConstraintManager, a class that provides a +// simplified constraint manager interface, compared to ConstraintManager. // //===--===// -#include "SimpleConstraintManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" @@ -23,48 +23,6 @@ SimpleConstraintManager::~SimpleConstraintManager() {} -bool SimpleConstraintManager::canReasonAbout(SVal X) const { - Optional SymVal = X.getAs(); - if (SymVal && SymVal->isExpression()) { -const SymExpr *SE = SymVal->getSymbol(); - -if (const SymIntExpr *SIE = dyn_cast(SE)) { - switch (SIE->getOpcode()) { - // We don't reason yet about bitwise-constraints on symbolic values. - case BO_And: - case BO_Or: - case BO_Xor: -return false; - // We don't reason yet about these arithmetic constraints on - // symbolic values. - case BO_Mul: - case BO_Div: - case BO_Rem: - case BO_Shl: - case BO_Shr: -return false; - // All other cases. - default: -return true; - } -} - -if (const SymSymExpr *SSE = dyn_cast(SE)) { - if (BinaryOperator::isComparisonOp(SSE->getOpcode())) { -// We handle Loc <> Loc comparisons, but not (yet) NonLoc <> NonLoc. -if (Loc::isLocType(SSE->getLHS()->getType())) { - assert(Loc::isLocType(SSE->getRHS()->getType())); - return true; -} - } -} - -return false; - } - - return true; -} - ProgramStateRef SimpleConstraintManager::assume(ProgramStateRef State, DefinedSVal Cond, bool Assumption) { @@ -92,23 +50,6 @@ return State; } -ProgramStateRef -SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State, -SymbolRef Sym, bool Assumption) { - BasicValueFactory &BVF = getBasicVals(); - QualType T = Sym->getType(); - - // None of the constraint solvers currently support non-integer types. - if (!T->isIntegralOrEnumerationType()) -return State; - - const llvm::APSInt &zero = BVF.getValue(0, T); - if (Assumption) -return assumeSymNE(State, Sym, zero, zero); - else -return assumeSymEQ(State, Sym, zero, zero); -} - ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State, NonLoc Cond, bool Assumption) { @@ -118,7 +59,8 @@ if (!canReasonAbout(Cond)) { // Just add the constraint to the expression without trying to simplify. SymbolRef Sym = Cond.getAsSymExpr(); -return assumeAuxForSymbol(State, Sym, Assumption); +assert(Sym); +return assumeSymUnsupported(State, Sym, Assumption); } switch (Cond.getSubKind()) { @@ -129,51 +71,7 @@ nonloc::SymbolVal SV = Cond.castAs(); SymbolRef Sym = SV.getSymbol(); assert(Sym); - -// Handle SymbolData. -if (!SV.isExpression()) { - return assumeAuxForSymbol(State, Sym, Assumption); - - // Handle symbolic expression. -} else if (const SymIntExpr *SE = dyn_cast(Sym)) { - // We can only simplify expressions whose RHS is an integer. - - BinaryOperator::Opcode Op = SE->getOpcode(); - if (BinaryOperator::isComparisonOp(Op)) { -if (!Assumption) - Op = BinaryOperator::negateComparisonOp(Op); - -return assumeSymRel(State, SE->getLHS(), Op, SE->get
Re: [libcxxabi] r288457 - Update implementation of ABI support for throwing noexcept function pointers
Looks like we need to wrap more of the test in the feature test macro. On 2 December 2016 at 13:42, Renato Golin via cfe-commits < cfe-commits@lists.llvm.org> wrote: > It's been a while, and new patches are coming. Should we just revert > this for now? > > --renato > > On 2 December 2016 at 10:13, Renato Golin wrote: > > On 2 December 2016 at 02:06, Richard Smith via cfe-commits > > wrote: > >> Author: rsmith > >> Date: Thu Dec 1 20:06:53 2016 > >> New Revision: 288457 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=288457&view=rev > >> Log: > >> Update implementation of ABI support for throwing noexcept function > pointers > >> and catching as non-noexcept to match the final design per discusson on > >> cxx-abi-dev. > > > > Hi Richard, > > > > I hope you've seen this: > > > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi- > libunwind-aarch64-linux/builds/4 > > > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi- > libunwind-aarch64-linux-noexceptions/builds/6 > > > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi- > libunwind-arm-linux/builds/97 > > > > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux- > noexceptions/builds/109 > > > > error: exception specifications are not allowed in type aliases > > template using FnType = void() noexcept(Noexcept); > > > > error: exception specifications are not allowed in type aliases > > template using FnType = void (X::*)() noexcept(Noexcept); > > > > cheers, > > --renato > ___ > 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
[libcxxabi] r288539 - Fix up r288457 for compilers that don't support noexcept function types:
Author: rsmith Date: Fri Dec 2 15:43:36 2016 New Revision: 288539 URL: http://llvm.org/viewvc/llvm-project?rev=288539&view=rev Log: Fix up r288457 for compilers that don't support noexcept function types: disable the test entirely for those cases. This is a quick patch, I'll look at a proper feature flag next. Modified: libcxxabi/trunk/test/catch_function_03.pass.cpp libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp Modified: libcxxabi/trunk/test/catch_function_03.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_function_03.pass.cpp?rev=288539&r1=288538&r2=288539&view=diff == --- libcxxabi/trunk/test/catch_function_03.pass.cpp (original) +++ libcxxabi/trunk/test/catch_function_03.pass.cpp Fri Dec 2 15:43:36 2016 @@ -13,6 +13,7 @@ #include +#ifdef __cpp_noexcept_function_type template void f() noexcept(Noexcept) {} template using FnType = void() noexcept(Noexcept); @@ -57,11 +58,12 @@ void check_deep() { int main() { -#ifdef __cpp_noexcept_function_type check(); check(); check(); check(); check_deep(); -#endif } +#else +int main() {} +#endif Modified: libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp?rev=288539&r1=288538&r2=288539&view=diff == --- libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp (original) +++ libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp Fri Dec 2 15:43:36 2016 @@ -14,6 +14,7 @@ #include +#ifdef __cpp_noexcept_function_type struct X { template void f() noexcept(Noexcept) {} }; @@ -60,11 +61,12 @@ void check_deep() { int main() { -#ifdef __cpp_noexcept_function_type check(); check(); check(); check(); check_deep(); -#endif } +#else +int main() {} +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxxabi] r288457 - Update implementation of ABI support for throwing noexcept function pointers
Should be fixed in r288539. On 2 December 2016 at 13:51, Richard Smith wrote: > Looks like we need to wrap more of the test in the feature test macro. > > On 2 December 2016 at 13:42, Renato Golin via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> It's been a while, and new patches are coming. Should we just revert >> this for now? >> >> --renato >> >> On 2 December 2016 at 10:13, Renato Golin >> wrote: >> > On 2 December 2016 at 02:06, Richard Smith via cfe-commits >> > wrote: >> >> Author: rsmith >> >> Date: Thu Dec 1 20:06:53 2016 >> >> New Revision: 288457 >> >> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=288457&view=rev >> >> Log: >> >> Update implementation of ABI support for throwing noexcept function >> pointers >> >> and catching as non-noexcept to match the final design per discusson on >> >> cxx-abi-dev. >> > >> > Hi Richard, >> > >> > I hope you've seen this: >> > >> > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind >> -aarch64-linux/builds/4 >> > >> > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind >> -aarch64-linux-noexceptions/builds/6 >> > >> > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind >> -arm-linux/builds/97 >> > >> > http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind >> -arm-linux-noexceptions/builds/109 >> > >> > error: exception specifications are not allowed in type aliases >> > template using FnType = void() noexcept(Noexcept); >> > >> > error: exception specifications are not allowed in type aliases >> > template using FnType = void (X::*)() noexcept(Noexcept); >> > >> > cheers, >> > --renato >> ___ >> 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: Upgrade and fix clang-format-vs
I've attached a patch that works as discussed. When running CMake with -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON, it will look for nuget.exe in PATH, or you can pass in DNUGET_EXE_PATH=C:\nuget, for e.g. On Mon, 28 Nov 2016 at 14:31 Antonio Maiorano wrote: > Great, I'll get this working soon and attach a new patch :) > > On Mon, 28 Nov 2016 at 14:27 Hans Wennborg wrote: > > On Mon, Nov 28, 2016 at 11:11 AM, Antonio Maiorano > wrote: > >> It's built with the script in utils/release/build_llvm_package.bat > > which I run manually on my machine once every few weeks. > > > > Okay, that's good news. So the simplest path to success would be to > require > > the user to either pass the path to CMake via an arg like > -DNUGET_EXE_PATH, > > or if it's not defined, to assume it's already in PATH. This is the most > > future-proof solution as it will work with future versions of VS (2017 RC > > just came out). > > > > I can still look into whether a vsix built with VS 2015 references will > > continue to work in older versions of VS, but even if this works, I feel > > like it's a temporary solution at best. There are other advantages to > using > > NuGet here: it would allow us to more easily pin/upgrade which > assemblies we > > want to use over time. > > > > If you're okay with it, I'll make the changes necessary to use > > -DNUGET_EXE_PATH, if defined, otherwise assume it's on PATH. This should > be > > a simple change at this point. > > That sounds good to me. There are already a bunch of prerequisites for > building the plugin, so adding this one doesn't seem unreasonable. > Especially since it seems it will simplify things to the point that > they might even work elsewhere than my own machine :-) > > > > On Mon, 28 Nov 2016 at 13:59 Hans Wennborg wrote: > >> > >> On Mon, Nov 28, 2016 at 10:46 AM, Antonio Maiorano > > >> wrote: > >> > Okay, I'll see if upgrading to the 2015 assemblies would allow the > VSIX > >> > to > >> > keep working in older versions of VS. > >> > > >> > Still waiting on an answer to this question: > >> > > >> >> In either case, though, I must ask: how is the offical vsix that's > >> >> available on http://llvm.org/builds/ get built? Is it part of an > >> >> automated > >> >> Clang build, or is it built and uploaded manually? If it's automated, > >> >> then > >> >> having to download and point to nuget.exe won't work. > >> > >> It's built with the script in utils/release/build_llvm_package.bat > >> which I run manually on my machine once every few weeks. > >> > >> > >> > On Mon, 28 Nov 2016 at 13:04 Hans Wennborg wrote: > >> >> > >> >> On Fri, Nov 25, 2016 at 6:58 PM, Antonio Maiorano < > amaior...@gmail.com> > >> >> wrote: > >> >> > Ah, no, that's not what I meant. The required referenced assemblies > >> >> > are > >> >> > versions that are normally installed with VS 2010. > >> >> > > >> >> > The first time I worked on this, I had upgraded the referenced > >> >> > assemblies to > >> >> > the ones that ship with VS 2015, but then there was question of > >> >> > whether > >> >> > or > >> >> > not the VSIX would continue to work with VS 2010/2012/2013. I'm not > >> >> > sure > >> >> > if > >> >> > it would work, but I guess I can try to figure that out. > >> >> > >> >> Let me know if you figure this one out. It sounds like it would > >> >> simplify things a lot. > >> >> > >> >> > In any case, what I discovered is that the "right" way to do things > >> >> > to > >> >> > make > >> >> > sure your extension compiles in future versions of VS is to use > NuGet > >> >> > to > >> >> > automatically pull in the required assemblies, or to check them in > >> >> > and > >> >> > reference them directly. The former would be better except for the > >> >> > problem > >> >> > of CLI builds as I described in my earlier email. > >> >> > > >> >> > > >> >> > > >> >> > On Fri, 25 Nov 2016 at 21:47 Zachary Turner > >> >> > wrote: > >> >> >> > >> >> >> Sorry, i think I misunderstood the original option 1. I > interpreted > >> >> >> it > >> >> >> as > >> >> >> just committing changes to the vsix manifest to reference a > specific > >> >> >> version > >> >> >> of the assembly which we assume to be present since it should be > >> >> >> automatically installed with vs 2015. Is this not possible? Can't > we > >> >> >> just > >> >> >> point the manifest to the version installed with vs? > >> >> >> On Fri, Nov 25, 2016 at 6:20 PM Antonio Maiorano > >> >> >> > >> >> >> wrote: > >> >> >>> > >> >> >>> Hi again, > >> >> >>> > >> >> >>> I've made the changes so that the required assemblies are > >> >> >>> committed, > >> >> >>> so > >> >> >>> now we can build the clang-format-vsix with just VS 2015. Since > the > >> >> >>> patch > >> >> >>> set is around 9 mb, I'm providing a link to it on my Dropbox (if > >> >> >>> you'd > >> >> >>> rather I attach it, let me know): > >> >> >>> > >> >> >>> > >> >> >>> > >> >> >>> > >> >> >>> > https://dl.dropboxusercontent.com/u/10504225/llvm-patches/0001-Fix-VS2015-build-of-clang-format-vsi
r288327 - Fix crash with unsupported architectures in Linux/Gnu target triples.
Author: fhahn Date: Thu Dec 1 05:02:59 2016 New Revision: 288327 URL: http://llvm.org/viewvc/llvm-project?rev=288327&view=rev Log: Fix crash with unsupported architectures in Linux/Gnu target triples. Summary: This patch adds a check and an error message to gnutools::Linker::ConstructJob in case the architecture is not supported. For most other operating systems, the error message is created in lib/Basic/Targets.cpp:AllocateTarget, but when construction the linker arguments for the gnutools linker a supported architecture is required. Reviewers: rafael, joerg, echristo Subscribers: mehdi_amini, joerg, dschuff, cfe-commits Differential Revision: https://reviews.llvm.org/D27066 Added: cfe/trunk/test/Driver/unsupported-target-arch.c Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=288327&r1=288326&r2=288327&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec 1 05:02:59 2016 @@ -9941,7 +9941,7 @@ static const char *getLDMOption(const ll return "elf32_x86_64"; return "elf_x86_64"; default: -llvm_unreachable("Unexpected arch"); +return nullptr; } } @@ -10014,8 +10014,13 @@ void gnutools::Linker::ConstructJob(Comp CmdArgs.push_back("--eh-frame-hdr"); } - CmdArgs.push_back("-m"); - CmdArgs.push_back(getLDMOption(ToolChain.getTriple(), Args)); + if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) { +CmdArgs.push_back("-m"); +CmdArgs.push_back(LDMOption); + } else { +D.Diag(diag::err_target_unknown_triple) << Triple.str(); +return; + } if (Args.hasArg(options::OPT_static)) { if (Arch == llvm::Triple::arm || Arch == llvm::Triple::armeb || Added: cfe/trunk/test/Driver/unsupported-target-arch.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/unsupported-target-arch.c?rev=288327&view=auto == --- cfe/trunk/test/Driver/unsupported-target-arch.c (added) +++ cfe/trunk/test/Driver/unsupported-target-arch.c Thu Dec 1 05:02:59 2016 @@ -0,0 +1,25 @@ +// Tests that clang does not crash with invalid architectures in target triples. +// +// RUN: not %clang --target=noarch-unknown-linux -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-LINUX %s +// CHECK-NOARCH-LINUX: error: unknown target triple 'noarch-unknown-linux', please use -triple or -arch +// +// RUN: not %clang --target=noarch-unknown-darwin -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-DARWIN %s +// CHECK-NOARCH-DARWIN: error: unknown target triple 'unknown-unknown-macosx{{.+}}', please use -triple or -arch +// +// RUN: not %clang --target=noarch-unknown-windows -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-WINDOWS %s +// CHECK-NOARCH-WINDOWS: error: unknown target triple 'noarch-unknown-windows-{{.+}}', please use -triple or -arch +// +// RUN: not %clang --target=noarch-unknown-freebsd -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-FREEBSD %s +// CHECK-NOARCH-FREEBSD: error: unknown target triple 'noarch-unknown-freebsd', please use -triple or -arch +// +// RUN: not %clang --target=noarch-unknown-netbsd -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NETBSD %s +// CHECK-NOARCH-NETBSD: error: unknown target triple 'noarch-unknown-netbsd', please use -triple or -arch +// +// RUN: not %clang --target=noarch-unknown-nacl -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NACL %s +// CHECK-NOARCH-NACL: error: the target architecture 'noarch' is not supported by the target 'Native Client' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Upgrade and fix clang-format-vs
On Tue, 29 Nov 2016 at 13:42 Hans Wennborg wrote: > Very nice! I've tried this out and confirmed that the built plugin > also works with older Visual Studio versions. > > Some comments below: > > > --- /dev/null > > +++ b/tools/clang-format-vs/.gitignore > > @@ -0,0 +1,11 @@ > > +# Visual Studio files > > +.vs/ > > +/packages/ > > +/ClangFormat/obj/ > > +/ClangFormat/bin/ > > Should there really be a leading slash in these paths? Same below. > Without the leading slash, then it would match "ClangFormat/obj" anywhere in the tree, rather than explicitly the one and only folder from the root. In this case, it wouldn't matter much. If you prefer, I could just ignore "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk, license.txt, etc. > > > + > > +# Generated and copied files > > +/ClangFormat/Key.snk > > +/ClangFormat/license.txt > > +/ClangFormat/clang-format.exe > > +/ClangFormat/source.extension.vsixmanifest > > diff --git a/tools/clang-format-vs/CMakeLists.txt > b/tools/clang-format-vs/CMakeLists.txt > > index fd0d6b0..90f89d8 100644 > > --- a/tools/clang-format-vs/CMakeLists.txt > > +++ b/tools/clang-format-vs/CMakeLists.txt > > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN) > >configure_file("source.extension.vsixmanifest.in" > > > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest") > > > > - add_custom_target(clang_format_vsix ALL > > - devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build > Release > > + find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH}) > > + if (NOT NUGET_EXE) > > + message(FATAL_ERROR "Could not find nuget.exe. Download from > https://www.nuget.org/nuget.exe and add to PATH or pass path via > NUGET_EXE_PATH var") > > Can you break this string over multiple lines? I know there are pretty > long lines in this file already, but it would be good to not make it > worse. > Sure thing, I'll see what I can do :) > > Maybe it could be clarified that NUGET_EXE_PATH is the path to a > directory containing nuget.exe, not to the file itself (I ran into > this). Maybe NUGET_EXE_DIR would be a better name? > That would be a better name, will make that change. > > > + endif() > > + > > + add_custom_target(clang_format_vsix ALL > > + ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" & > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release > > Is '&' a CMake thing, or should that be '&&'? Also, any chance of > breaking these long lines? > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only runs the 2nd command if the first succeeds, while using '&' always runs both. I'll make the change, and will try to shorten this line as well. > > >DEPENDS clang_format_exe_for_vsix > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest" > >COMMAND ${CMAKE_COMMAND} -E copy_if_different > > > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix" > > diff --git a/tools/clang-format-vs/README.txt > b/tools/clang-format-vs/README.txt > > index b23355d..44a071b 100644 > > --- a/tools/clang-format-vs/README.txt > > +++ b/tools/clang-format-vs/README.txt > > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to > generate a Visual Studio extensio > > for clang-format. > > > > Build prerequisites are: > > -- Visual Studio 2013 Professional > > -- Visual Studio 2013 SDK > > -- Visual Studio 2010 Professional (?) > > -- Visual Studio 2010 SDK (?) > > +- Visual Studio 2015 > > +- Extensions SDK (you'll be prompted to install it if you open > ClangFormat.sln) > > A very nice simplification :-) > Thanks :) > > > > > -The extension is built using CMake by setting > BUILD_CLANG_FORMAT_VS_PLUGIN=ON > > -when configuring a Clang build, and building the clang_format_vsix > target. > > +The extension is built using CMake to generate the usual LLLVM.sln by > setting > > An L too much in LLLVM.sln? > You know, that extra L in 'L'egendary LLVM? ;) Will remove! Will update patch soon! > > On Mon, Nov 28, 2016 at 8:00 PM, Antonio Maiorano > wrote: > > I've attached a patch that works as discussed. When running CMake with > > -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON, it will look for nuget.exe in PATH, or > > you can pass in DNUGET_EXE_PATH=C:\nuget, for e.g. > > > > > > On Mon, 28 Nov 2016 at 14:31 Antonio Maiorano > wrote: > >> > >> Great, I'll get this working soon and attach a new patch :) > >> > >> On Mon, 28 Nov 2016 at 14:27 Hans Wennborg wrote: > >>> > >>> On Mon, Nov 28, 2016 at 11:11 AM, Antonio Maiorano < > amaior...@gmail.com> > >>> wrote: > >>> >> It's built with the script in utils/release/build_llvm_package.bat > >>> > which I run manually on my machine once every few weeks. > >>> > > >>> > Okay, that's good news. So the simplest path to success would be to > >>> > require > >>> > the user to either pass the path to CMake via an arg like > >>> > -DNUGET_EXE_PATH, > >>> > or if it's not defined, to assume it's already in PATH. Th
Re: Upgrade and fix clang-format-vs
Updated version of patch attached with the changes you suggested. Let me know if there's anything else you'd like. On Tue, 29 Nov 2016 at 15:38 Hans Wennborg wrote: > On Tue, Nov 29, 2016 at 12:01 PM, Antonio Maiorano > wrote: > > On Tue, 29 Nov 2016 at 13:42 Hans Wennborg wrote: > >> > >> Very nice! I've tried this out and confirmed that the built plugin > >> also works with older Visual Studio versions. > >> > >> Some comments below: > >> > >> > --- /dev/null > >> > +++ b/tools/clang-format-vs/.gitignore > >> > @@ -0,0 +1,11 @@ > >> > +# Visual Studio files > >> > +.vs/ > >> > +/packages/ > >> > +/ClangFormat/obj/ > >> > +/ClangFormat/bin/ > >> > >> Should there really be a leading slash in these paths? Same below. > > > > > > Without the leading slash, then it would match "ClangFormat/obj" > anywhere in > > the tree, rather than explicitly the one and only folder from the root. > In > > this case, it wouldn't matter much. If you prefer, I could just ignore > > "obj/" and "bin/", etc, although I'd rather be explicit for Key.snk, > > license.txt, etc. > > Interesting. I was just comparing with LLVM's root .gitignore, which > doesn't have leading slashes for many dirs. Checking the gitignore > doc, it sounds like you've got it right :-) > > > >> > +# Generated and copied files > >> > +/ClangFormat/Key.snk > >> > +/ClangFormat/license.txt > >> > +/ClangFormat/clang-format.exe > >> > +/ClangFormat/source.extension.vsixmanifest > >> > diff --git a/tools/clang-format-vs/CMakeLists.txt > >> > b/tools/clang-format-vs/CMakeLists.txt > >> > index fd0d6b0..90f89d8 100644 > >> > --- a/tools/clang-format-vs/CMakeLists.txt > >> > +++ b/tools/clang-format-vs/CMakeLists.txt > >> > @@ -18,8 +18,13 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN) > >> >configure_file("source.extension.vsixmanifest.in" > >> > > >> > > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest") > >> > > >> > - add_custom_target(clang_format_vsix ALL > >> > - devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build > >> > Release > >> > + find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_PATH}) > >> > + if (NOT NUGET_EXE) > >> > + message(FATAL_ERROR "Could not find nuget.exe. Download from > >> > https://www.nuget.org/nuget.exe and add to PATH or pass path via > >> > NUGET_EXE_PATH var") > >> > >> Can you break this string over multiple lines? I know there are pretty > >> long lines in this file already, but it would be good to not make it > >> worse. > > > > > > Sure thing, I'll see what I can do :) > > > >> > >> > >> Maybe it could be clarified that NUGET_EXE_PATH is the path to a > >> directory containing nuget.exe, not to the file itself (I ran into > >> this). Maybe NUGET_EXE_DIR would be a better name? > > > > > > That would be a better name, will make that change. > > > >> > >> > >> > + endif() > >> > + > >> > + add_custom_target(clang_format_vsix ALL > >> > + ${NUGET_EXE} restore "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" > & > >> > devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build Release > >> > >> Is '&' a CMake thing, or should that be '&&'? Also, any chance of > >> breaking these long lines? > > > > > > '&' is a cmd.exe thing, but I can use '&&' - in fact, the latter only > runs > > the 2nd command if the first succeeds, while using '&' always runs both. > > I'll make the change, and will try to shorten this line as well. > > > >> > >> > >> >DEPENDS clang_format_exe_for_vsix > >> > > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest" > >> >COMMAND ${CMAKE_COMMAND} -E copy_if_different > >> > > >> > "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix" > >> > diff --git a/tools/clang-format-vs/README.txt > >> > b/tools/clang-format-vs/README.txt > >> > index b23355d..44a071b 100644 > >> > --- a/tools/clang-format-vs/README.txt > >> > +++ b/tools/clang-format-vs/README.txt > >> > @@ -2,13 +2,23 @@ This directory contains a VSPackage project to > >> > generate a Visual Studio extensio > >> > for clang-format. > >> > > >> > Build prerequisites are: > >> > -- Visual Studio 2013 Professional > >> > -- Visual Studio 2013 SDK > >> > -- Visual Studio 2010 Professional (?) > >> > -- Visual Studio 2010 SDK (?) > >> > +- Visual Studio 2015 > >> > +- Extensions SDK (you'll be prompted to install it if you open > >> > ClangFormat.sln) > >> > >> A very nice simplification :-) > > > > > > Thanks :) > > > >> > >> > >> > > >> > -The extension is built using CMake by setting > >> > BUILD_CLANG_FORMAT_VS_PLUGIN=ON > >> > -when configuring a Clang build, and building the clang_format_vsix > >> > target. > >> > +The extension is built using CMake to generate the usual LLLVM.sln by > >> > setting > >> > >> An L too much in LLLVM.sln? > > > > > > You know, that extra L in 'L'egendary LLVM? ;) Will remove! > > > > Will update patch soon! > > > >> > >> > >> On Mon, Nov 28, 2016 at 8:00 PM, Antonio Maiorano > >> wrote: > >> > I've attached a patch that works as disc
[PATCH] D27364: Use SD-6 feature test macro to determine whether to enable P0012 ABI tests
rsmith created this revision. rsmith added a reviewer: EricWF. rsmith added a subscriber: cfe-commits. rsmith set the repository for this revision to rL LLVM. Repository: rL LLVM https://reviews.llvm.org/D27364 Files: test/catch_function_03.pass.cpp test/catch_member_function_pointer_02.pass.cpp test/libcxxabi/test/config.py Index: test/libcxxabi/test/config.py === --- test/libcxxabi/test/config.py +++ test/libcxxabi/test/config.py @@ -33,10 +33,15 @@ self.libcxxabi_obj_root = self.get_lit_conf('libcxxabi_obj_root') super(Configuration, self).configure_obj_root() +def has_cpp_feature(self, feature, required_value): +return self.cxx.dumpMacros().get(feature, 0) >= required_value + def configure_features(self): super(Configuration, self).configure_features() if not self.get_lit_bool('enable_exceptions', True): self.config.available_features.add('libcxxabi-no-exceptions') +if not self.has_cpp_feature('noexcept_function_type', 201510): + self.config.available_features.add('libcxxabi-no-noexcept-function-type') def configure_compile_flags(self): self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER'] Index: test/catch_member_function_pointer_02.pass.cpp === --- test/catch_member_function_pointer_02.pass.cpp +++ test/catch_member_function_pointer_02.pass.cpp @@ -9,12 +9,10 @@ // Can a noexcept member function pointer be caught by a non-noexcept catch // clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type struct X { template void f() noexcept(Noexcept) {} }; @@ -67,6 +65,3 @@ check(); check_deep(); } -#else -int main() {} -#endif Index: test/catch_function_03.pass.cpp === --- test/catch_function_03.pass.cpp +++ test/catch_function_03.pass.cpp @@ -8,12 +8,10 @@ //===--===// // Can a noexcept function pointer be caught by a non-noexcept catch clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type template void f() noexcept(Noexcept) {} template using FnType = void() noexcept(Noexcept); @@ -64,6 +62,3 @@ check(); check_deep(); } -#else -int main() {} -#endif Index: test/libcxxabi/test/config.py === --- test/libcxxabi/test/config.py +++ test/libcxxabi/test/config.py @@ -33,10 +33,15 @@ self.libcxxabi_obj_root = self.get_lit_conf('libcxxabi_obj_root') super(Configuration, self).configure_obj_root() +def has_cpp_feature(self, feature, required_value): +return self.cxx.dumpMacros().get(feature, 0) >= required_value + def configure_features(self): super(Configuration, self).configure_features() if not self.get_lit_bool('enable_exceptions', True): self.config.available_features.add('libcxxabi-no-exceptions') +if not self.has_cpp_feature('noexcept_function_type', 201510): +self.config.available_features.add('libcxxabi-no-noexcept-function-type') def configure_compile_flags(self): self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER'] Index: test/catch_member_function_pointer_02.pass.cpp === --- test/catch_member_function_pointer_02.pass.cpp +++ test/catch_member_function_pointer_02.pass.cpp @@ -9,12 +9,10 @@ // Can a noexcept member function pointer be caught by a non-noexcept catch // clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type struct X { template void f() noexcept(Noexcept) {} }; @@ -67,6 +65,3 @@ check(); check_deep(); } -#else -int main() {} -#endif Index: test/catch_function_03.pass.cpp === --- test/catch_function_03.pass.cpp +++ test/catch_function_03.pass.cpp @@ -8,12 +8,10 @@ //===--===// // Can a noexcept function pointer be caught by a non-noexcept catch clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type template void f() noexcept(Noexcept) {} template
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
mgorny added inline comments. Comment at: test/Driver/linux-ld.c:1016 +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" rengolin wrote: > mgorny wrote: > > rengolin wrote: > > > where is 4.9.3 coming from? > > It's the version used in the input tree, i.e. the two added files above. > Right, I mean is this "4.9.3" there because the driver "found" it there, or > is it generated by the compiler version you have on your machine, and that's > why you created the directory with "4.9.3" in it? > > I'm worried that if it's the latter, the test will fail on any machine that > doesn't have that compiler version. But I really don't know how it works, so > it was an honest question. :) It's there because Driver founds it in Input directory structure. I don't have that version installed locally, if that's what worries you. You could say it's intentionally different from my install but I've simply copied the version used by other Gentoo tests. https://reviews.llvm.org/D25686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25686: [Driver] Improve support for Gentoo arm*-hardfloat-*-*eabi triples
rengolin added inline comments. Comment at: test/Driver/linux-ld.c:1016 +// CHECK-LD-GENTOO-ARMHF: "-dynamic-linker" "/lib/ld-linux-armhf.so.3" +// CHECK-LD-GENTOO-ARMHF: "{{.*}}/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3/crtbegin.o" +// CHECK-LD-GENTOO-ARMHF: "-L[[SYSROOT]]/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.3" mgorny wrote: > rengolin wrote: > > mgorny wrote: > > > rengolin wrote: > > > > where is 4.9.3 coming from? > > > It's the version used in the input tree, i.e. the two added files above. > > Right, I mean is this "4.9.3" there because the driver "found" it there, or > > is it generated by the compiler version you have on your machine, and > > that's why you created the directory with "4.9.3" in it? > > > > I'm worried that if it's the latter, the test will fail on any machine that > > doesn't have that compiler version. But I really don't know how it works, > > so it was an honest question. :) > It's there because Driver founds it in Input directory structure. I don't > have that version installed locally, if that's what worries you. You could > say it's intentionally different from my install but I've simply copied the > version used by other Gentoo tests. That answers my question, thanks! :) https://reviews.llvm.org/D25686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r288543 - Check for SD-6 feature test macro when determining which tests should be
Author: rsmith Date: Fri Dec 2 16:14:59 2016 New Revision: 288543 URL: http://llvm.org/viewvc/llvm-project?rev=288543&view=rev Log: Check for SD-6 feature test macro when determining which tests should be available, rather than #ifdef'ing away the relevant tests if it's unavailable. Modified: libcxxabi/trunk/test/catch_function_03.pass.cpp libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp libcxxabi/trunk/test/libcxxabi/test/config.py Modified: libcxxabi/trunk/test/catch_function_03.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_function_03.pass.cpp?rev=288543&r1=288542&r2=288543&view=diff == --- libcxxabi/trunk/test/catch_function_03.pass.cpp (original) +++ libcxxabi/trunk/test/catch_function_03.pass.cpp Fri Dec 2 16:14:59 2016 @@ -8,12 +8,10 @@ //===--===// // Can a noexcept function pointer be caught by a non-noexcept catch clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type template void f() noexcept(Noexcept) {} template using FnType = void() noexcept(Noexcept); @@ -64,6 +62,3 @@ int main() check(); check_deep(); } -#else -int main() {} -#endif Modified: libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp?rev=288543&r1=288542&r2=288543&view=diff == --- libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp (original) +++ libcxxabi/trunk/test/catch_member_function_pointer_02.pass.cpp Fri Dec 2 16:14:59 2016 @@ -9,12 +9,10 @@ // Can a noexcept member function pointer be caught by a non-noexcept catch // clause? -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// UNSUPPORTED: libcxxabi-no-exceptions +// UNSUPPORTED: libcxxabi-no-exceptions, libcxxabi-no-noexcept-function-type #include -#ifdef __cpp_noexcept_function_type struct X { template void f() noexcept(Noexcept) {} }; @@ -67,6 +65,3 @@ int main() check(); check_deep(); } -#else -int main() {} -#endif Modified: libcxxabi/trunk/test/libcxxabi/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=288543&r1=288542&r2=288543&view=diff == --- libcxxabi/trunk/test/libcxxabi/test/config.py (original) +++ libcxxabi/trunk/test/libcxxabi/test/config.py Fri Dec 2 16:14:59 2016 @@ -33,10 +33,15 @@ class Configuration(LibcxxConfiguration) self.libcxxabi_obj_root = self.get_lit_conf('libcxxabi_obj_root') super(Configuration, self).configure_obj_root() +def has_cpp_feature(self, feature, required_value): +return int(self.cxx.dumpMacros().get('__cpp_' + feature, 0)) >= required_value + def configure_features(self): super(Configuration, self).configure_features() if not self.get_lit_bool('enable_exceptions', True): self.config.available_features.add('libcxxabi-no-exceptions') +if not self.has_cpp_feature('noexcept_function_type', 201510): + self.config.available_features.add('libcxxabi-no-noexcept-function-type') def configure_compile_flags(self): self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER'] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27068: Improve string::find
hiraditya updated this revision to Diff 80134. hiraditya added a comment. Addressed Marshall's comments. https://reviews.llvm.org/D27068 Files: libcxx/benchmarks/string.bench.cpp libcxx/include/__string Index: libcxx/include/__string === --- libcxx/include/__string +++ libcxx/include/__string @@ -538,25 +538,60 @@ return static_cast<_SizeT>(__r - __p); } +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 +const _CharT * +__search_substring(const _CharT *__first1, const _CharT *__last1, + const _CharT * __first2, const _CharT * __last2) +{ +// Take advantage of knowing source and pattern lengths. +// Stop short when source is smaller than pattern. +const ptrdiff_t __len2 = __last2 - __first2; +if (__len2 == 0) +return __first1; +ptrdiff_t __len1 = __last1 - __first1; +if (__len1 < __len2) +return __last1; + +// First element of __first2 is loop invariant. +_CharT __f2 = *__first2; +while (true) +{ + __len1 = __last1 - __first1; + if (__len1 < __len2) + return __last1; + + __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); + if (__first1 == 0) +return __last1; + + // Comparing __first2 as well because the first pointer will be aligned + // and we dont know if __first1+1 is going to be aligned. + if (_Traits::compare(__first1, __first2, __len2) == 0) +return __first1; + +++__first1; +} +} + template inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY __str_find(const _CharT *__p, _SizeT __sz, const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT { -if (__pos > __sz || __sz - __pos < __n) +if (__pos > __sz) return __npos; -if (__n == 0) + +if (__n == 0) // There is nothing to search, just return __pos return __pos; -const _CharT* __r = -_VSTD::__search(__p + __pos, __p + __sz, -__s, __s + __n, _Traits::eq, -random_access_iterator_tag(), random_access_iterator_tag()).first; + +const _CharT* __r = __search_substring<_CharT, _Traits>(__p + __pos, __p + __sz, +__s, __s + __n); if (__r == __p + __sz) return __npos; return static_cast<_SizeT>(__r - __p); } - // __str_rfind template Index: libcxx/benchmarks/string.bench.cpp === --- /dev/null +++ libcxx/benchmarks/string.bench.cpp @@ -0,0 +1,49 @@ +#include +#include +#include + +#include "benchmark/benchmark_api.h" +#include "GenerateInput.hpp" + +constexpr std::size_t MAX_STRING_LEN = 8<<14; + +// Benchmark when there is no match. +static void BM_StringFindNoMatch(benchmark::State& state) { + std::string s1(state.range(0), '-'); + std::string s2(8, '*'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindNoMatch)->Range(10,MAX_STRING_LEN); + +// Benchmark when the string matches first time. +static void BM_StringFindAllMatch(benchmark::State& state) { + std::string s1(MAX_STRING_LEN, '-'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindAllMatch)->Range(1,MAX_STRING_LEN); + +// Benchmark when the string matches somewhere in the end. +static void BM_StringFindMatch1(benchmark::State& state) { + std::string s1(MAX_STRING_LEN/2, '*'); + s1 += std::string(state.range(0), '-'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindMatch1)->Range(1,MAX_STRING_LEN/4); + +// Benchmark when the string matches somewhere from middle to the end. +static void BM_StringFindMatch2(benchmark::State& state) { + std::string s1(MAX_STRING_LEN/2, '*'); + s1 += std::string(state.range(0), '-'); + s1 += std::string(state.range(0), '*'); + std::string s2(state.range(0), '-'); + while (state.KeepRunning()) +benchmark::DoNotOptimize(s1.find(s2)); +} +BENCHMARK(BM_StringFindMatch2)->Range(1,MAX_STRING_LEN/4); + +BENCHMARK_MAIN() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27365: [analyzer] Print type for SymbolRegionValues when dumping to stream
ddcc created this revision. ddcc added reviewers: NoQ, dcoughlin, zaks.anna. ddcc added a subscriber: cfe-commits. https://reviews.llvm.org/D27365 Files: lib/StaticAnalyzer/Core/SymbolManager.cpp test/Analysis/expr-inspection.c Index: test/Analysis/expr-inspection.c === --- test/Analysis/expr-inspection.c +++ test/Analysis/expr-inspection.c @@ -7,7 +7,7 @@ void clang_analyzer_numTimesReached(); void foo(int x) { - clang_analyzer_dump(x); // expected-warning{{reg_$0}} + clang_analyzer_dump(x); // expected-warning{{reg_$0}} int y = 1; clang_analyzer_printState(); for (; y < 3; ++y) Index: lib/StaticAnalyzer/Core/SymbolManager.cpp === --- lib/StaticAnalyzer/Core/SymbolManager.cpp +++ lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -85,7 +85,8 @@ void SymbolData::anchor() { } void SymbolRegionValue::dumpToStream(raw_ostream &os) const { - os << "reg_$" << getSymbolID() << "<" << R << ">"; + os << "reg_$" << getSymbolID() + << "<" << getType().getAsString() << " " << R << ">"; } bool SymExpr::symbol_iterator::operator==(const symbol_iterator &X) const { Index: test/Analysis/expr-inspection.c === --- test/Analysis/expr-inspection.c +++ test/Analysis/expr-inspection.c @@ -7,7 +7,7 @@ void clang_analyzer_numTimesReached(); void foo(int x) { - clang_analyzer_dump(x); // expected-warning{{reg_$0}} + clang_analyzer_dump(x); // expected-warning{{reg_$0}} int y = 1; clang_analyzer_printState(); for (; y < 3; ++y) Index: lib/StaticAnalyzer/Core/SymbolManager.cpp === --- lib/StaticAnalyzer/Core/SymbolManager.cpp +++ lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -85,7 +85,8 @@ void SymbolData::anchor() { } void SymbolRegionValue::dumpToStream(raw_ostream &os) const { - os << "reg_$" << getSymbolID() << "<" << R << ">"; + os << "reg_$" << getSymbolID() + << "<" << getType().getAsString() << " " << R << ">"; } bool SymExpr::symbol_iterator::operator==(const symbol_iterator &X) const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288544 - Work around a bug in Clang's implementation of noexcept function types
Author: ericwf Date: Fri Dec 2 16:30:52 2016 New Revision: 288544 URL: http://llvm.org/viewvc/llvm-project?rev=288544&view=rev Log: Work around a bug in Clang's implementation of noexcept function types Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp?rev=288544&r1=288543&r2=288544&view=diff == --- libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp Fri Dec 2 16:30:52 2016 @@ -54,7 +54,11 @@ constexpr bool throws_callable() { void test_noexcept_function_pointers() { struct Dummy { void foo() noexcept {} static void bar() noexcept {} }; -#if !defined(__cpp_noexcept_function_type) + +// FIXME(EricWF): Remove the __clang__ workaround. As of 2/12/2016 Clang has +// a bug where calling a noexcept function pointer is not noexcept. +// See https://llvm.org/bugs/show_bug.cgi?id=31244 +#if !defined(__cpp_noexcept_function_type) || defined(__clang__) { // Check that PMF's and function pointers *work*. is_nothrow_callable will always // return false because 'noexcept' is not part of the function type. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21453: Add support for attribute "overallocated"
rsmith added inline comments. Comment at: include/clang/AST/Decl.h:3250 + /// This is true if this struct ends with an array marked 'flexible_array'. + bool HasFlexibleArrayAttr : 1; + How is this different from `HasFlexibleArrayMember`? Do we really need both? Comment at: include/clang/Basic/AttrDocs.td:2078-2079 +Structs or classes that have an array member marked ``flexible_array`` cannot be nested or subclassed. +This attribute is useful when you want __builtin_object_size to be conservative +when computing the size of an over-allocated array. For example: + Instead of "This attribute is useful when you want", I would suggest "This attribute causes", since that is far from the only effect. It should also disable the sanitizer checks for array bounds violations, for example. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2173 +def err_flexible_array_nested : Error< + "struct with a member marked 'flexible_array' cannot be nested">; def err_aligned_attribute_argument_not_int : Error< I don't think it's very clear what "nested" means here. I assume you mean that a struct with a `flexible_array` member can't be used as the type of a field. If so, why not? C allows that for other kinds of flexible array members. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2520 + "variables, functions, methods, types, enumerations, enumerators, labels, and non-static data members|" + "fields}1">, InGroup; aaron.ballman wrote: > non-static data members instead of fields. Again, this will be confusing in C. Our diagnostics generally use the word "field" to refer to fields in C or non-static data members in C++. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2170 + "'flexible_array' attribute only applies to %select{" + "the last member of a struct|members of structs or classes|" + "fixed sized array members|array members that have at least one element}0">; ahatanak wrote: > aaron.ballman wrote: > > I think "members of structs or classes" and "the last member of a struct" > > could be combined into "the last member of a non-union class", instead of > > using separate diagnostic text. What do you think? > I agree, I think these two diagnostics should be combined. We shouldn't talk about classes when targeting C. Comment at: lib/AST/ExprConstant.cpp:287 Entries.back().ArrayIndex += N; if (Entries.back().ArrayIndex > MostDerivedArraySize) { diagnosePointerArithmetic(Info, E, Entries.back().ArrayIndex); Pointer arithmetic that leaves the initial portion of a member with the `flexible_array` attribute will lose its designator here. Is that what you want? Comment at: lib/AST/ExprConstant.cpp:5200 +} else Result.Designator.setInvalid(); return true; Should we also set `HasFlexibleArrayAttr` on *real* flexible array members (which will be fields with `IncompleteArrayType`) rather than invalidating the designator? Comment at: lib/CodeGen/CGExpr.cpp:695-696 if (const auto *FD = dyn_cast(ME->getMemberDecl())) { - RecordDecl::field_iterator FI( - DeclContext::decl_iterator(const_cast(FD))); - return ++FI == FD->getParent()->field_end(); + if (FD->getParent()->hasFlexibleArrayMemberOrAttr()) +return true; + // For compatibility with existing code, we treat arrays of length 0 or This is wrong. We shouldn't disable all bounds checking for all array members in a class just because it ends in a flexible array member: only that member should have its checks disabled. You can reverse the sense of this as a fast-path for the common case of a class without a flexible array member, though. https://reviews.llvm.org/D21453 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288545 - Mass-rename the handful of error_* diagnostics to err_*.
Author: rsmith Date: Fri Dec 2 16:38:31 2016 New Revision: 288545 URL: http://llvm.org/viewvc/llvm-project?rev=288545&view=rev Log: Mass-rename the handful of error_* diagnostics to err_*. Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaCast.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaExprObjC.cpp cfe/trunk/lib/Sema/SemaObjCProperty.cpp cfe/trunk/lib/Sema/SemaPseudoObject.cpp cfe/trunk/lib/Sema/SemaStmt.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=288545&r1=288544&r2=288545&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Dec 2 16:38:31 2016 @@ -63,7 +63,7 @@ def ext_nullability : Extension< "type nullability specifier %0 is a Clang extension">, InGroup>; -def error_empty_enum : Error<"use of empty enum">; +def err_empty_enum : Error<"use of empty enum">; def ext_ident_list_in_param : Extension< "type-less parameter names in function declaration">; @@ -421,7 +421,7 @@ def err_unexpected_protocol_qualifier : "@implementation declaration cannot be protocol qualified">; def err_objc_unexpected_atend : Error< "'@end' appears where closing brace '}' is expected">; -def error_property_ivar_decl : Error< +def err_property_ivar_decl : Error< "property synthesize requires specification of an ivar">; def err_synthesized_property_name : Error< "expected a property name in @synthesize">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=288545&r1=288544&r2=288545&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 2 16:38:31 2016 @@ -922,7 +922,7 @@ def warn_objc_cdirective_format_string : InGroup, DefaultIgnore; def err_objc_var_decl_inclass : Error<"cannot declare variable inside @interface or @protocol">; -def error_missing_method_context : Error< +def err_missing_method_context : Error< "missing context for method declaration">; def err_objc_property_attr_mutually_exclusive : Error< "property attributes '%0' and '%1' are mutually exclusive">; @@ -1013,7 +1013,7 @@ def warn_property_getter_owning_mismatch def warn_property_redecl_getter_mismatch : Warning< "getter name mismatch between property redeclaration (%1) and its original " "declaration (%0)">, InGroup; -def error_property_setter_ambiguous_use : Error< +def err_property_setter_ambiguous_use : Error< "synthesized properties %0 and %1 both claim setter %2 -" " use of this setter will cause unexpected behavior">; def warn_default_atomic_custom_getter_setter : Warning< @@ -1032,12 +1032,12 @@ def err_use_continuation_class_redeclara "'readonly' public property?)">; def err_continuation_class : Error<"class extension has no primary class">; def err_property_type : Error<"property cannot have array or function type %0">; -def error_missing_property_context : Error< +def err_missing_property_context : Error< "missing context for property implementation declaration">; -def error_bad_property_decl : Error< +def err_bad_property_decl : Error< "property implementation must have its declaration in interface %0 or one of " "its extensions">; -def error_category_property : Error< +def err_category_property : Error< "property declared in category %0 cannot be implemented in " "class implementation">; def note_property_declare : Note< @@ -1046,19 +1046,19 @@ def note_protocol_property_declare : Not "it could also be property of type %0 declared here">; def note_property_synthesize : Note< "property synthesized here">; -def error_synthesize_category_decl : Error< +def err_synthesize_category_decl : Error< "@synthesize not allowed in a category's implementation">; -def error_synthesize_on_class_property : Error< +def err_synthesize_on_class_property : Error< "@synthesize not allowed on a class property %0">; -def error_reference_property : Error< +def err_reference_property : Error< "property of reference type is not supported">; -def error_missing_property_interface : Error< +def err_missing_property_interface : Error< "property implementation in a category with no category declaration">; -def error_bad_category_property_decl : Error< +def err_bad_category_property_decl : Error< "property implementation must have its declaration in the category
Re: [libcxx] r288544 - Work around a bug in Clang's implementation of noexcept function types
- Original Message - > From: "Eric Fiselier via cfe-commits" > To: cfe-commits@lists.llvm.org > Sent: Friday, December 2, 2016 4:30:53 PM > Subject: [libcxx] r288544 - Work around a bug in Clang's implementation of > noexcept function types > > Author: ericwf > Date: Fri Dec 2 16:30:52 2016 > New Revision: 288544 > > URL: http://llvm.org/viewvc/llvm-project?rev=288544&view=rev > Log: > Work around a bug in Clang's implementation of noexcept function > types > > Modified: > libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp > > Modified: > libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp?rev=288544&r1=288543&r2=288544&view=diff > == > --- > libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp > (original) > +++ > libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp > Fri Dec 2 16:30:52 2016 > @@ -54,7 +54,11 @@ constexpr bool throws_callable() { > void test_noexcept_function_pointers() > { > struct Dummy { void foo() noexcept {} static void bar() noexcept > {} }; > -#if !defined(__cpp_noexcept_function_type) > + > +// FIXME(EricWF): Remove the __clang__ workaround. As of 2/12/2016 As a general note, it is confusing to write dates this way. Most people in the US will read this as Feb. 12th, 2016. Others will read it as Dec. 2nd, 2016. I recommend using 2016-12-02 to avoid confusion. -Hal > Clang has > +// a bug where calling a noexcept function pointer is not noexcept. > +// See https://llvm.org/bugs/show_bug.cgi?id=31244 > +#if !defined(__cpp_noexcept_function_type) || defined(__clang__) > { > // Check that PMF's and function pointers *work*. > is_nothrow_callable will always > // return false because 'noexcept' is not part of the > function type. > > > ___ > 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
r288546 - CodeGen: export typeinfo and typeinfo name on itanium
Author: compnerd Date: Fri Dec 2 16:46:18 2016 New Revision: 288546 URL: http://llvm.org/viewvc/llvm-project?rev=288546&view=rev Log: CodeGen: export typeinfo and typeinfo name on itanium When a C++ record is marked with dllexport mark both the typeinfo and the typeinfo name as being exported. Handle dllimport as the inverse. This applies to the itanium environment and not the MinGW environment. Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=288546&r1=288545&r2=288546&view=diff == --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Dec 2 16:46:18 2016 @@ -2911,16 +2911,18 @@ static llvm::GlobalVariable::LinkageType case VisibleNoLinkage: case ExternalLinkage: -if (!CGM.getLangOpts().RTTI) { - // RTTI is not enabled, which means that this type info struct is going - // to be used for exception handling. Give it linkonce_odr linkage. +// RTTI is not enabled, which means that this type info struct is going +// to be used for exception handling. Give it linkonce_odr linkage. +if (!CGM.getLangOpts().RTTI) return llvm::GlobalValue::LinkOnceODRLinkage; -} if (const RecordType *Record = dyn_cast(Ty)) { const CXXRecordDecl *RD = cast(Record->getDecl()); if (RD->hasAttr()) return llvm::GlobalValue::WeakODRLinkage; + if (CGM.getTriple().isWindowsItaniumEnvironment()) +if (RD->hasAttr()) + return llvm::GlobalValue::ExternalLinkage; if (RD->isDynamicClass()) { llvm::GlobalValue::LinkageTypes LT = CGM.getVTableLinkage(RD); // MinGW won't export the RTTI information when there is a key function. @@ -3122,10 +3124,26 @@ llvm::Constant *ItaniumRTTIBuilder::Buil llvmVisibility = llvm::GlobalValue::HiddenVisibility; else llvmVisibility = CodeGenModule::GetLLVMVisibility(Ty->getVisibility()); + TypeName->setVisibility(llvmVisibility); GV->setVisibility(llvmVisibility); - if (DLLExport) -GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); + + if (CGM.getTriple().isWindowsItaniumEnvironment()) { +auto RD = Ty->getAsCXXRecordDecl(); +if (DLLExport || (RD && RD->hasAttr())) { + TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); + GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); +} else if (RD && RD->hasAttr()) { + TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); + + // Because the typename and the typeinfo are DLL import, convert them to + // declarations rather than definitions. The initializers still need to + // be constructed to calculate the type for the declarations. + TypeName->setInitializer(nullptr); + GV->setInitializer(nullptr); +} + } return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy); } Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp?rev=288546&r1=288545&r2=288546&view=diff == --- cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp (original) +++ cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Fri Dec 2 16:46:18 2016 @@ -9,5 +9,24 @@ public: __fundamental_type_info::~__fundamental_type_info() {} } -// CHECK: @_ZTIi = dllexport constant +struct __declspec(dllimport) base { + virtual void method(); +}; +struct __declspec(dllexport) derived : base { + virtual ~derived(); +}; +derived::~derived() { + method(); +} + +// CHECK-DAG: @_ZTIi = dllexport constant +// CHECK-DAG: @_ZTSi = dllexport constant + +// CHECK-DAG: @_ZTI7derived = dllexport constant +// CHECK-DAG: @_ZTS7derived = dllexport constant +// CHECK-DAG: @_ZTV7derived = dllexport unnamed_addr constant + +// CHECK-DAG: @_ZTI4base = external dllimport constant +// CHECK-DAG: @_ZTS4base = external dllimport constant +// CHECK-NOT: @_ZTV4base = external dllimport constant ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288548 - More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_.
Author: rsmith Date: Fri Dec 2 17:00:28 2016 New Revision: 288548 URL: http://llvm.org/viewvc/llvm-project?rev=288548&view=rev Log: More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_. In passing, add a warning group for "ignored qualifier in inline assembly" warnings. Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Parse/ParseStmtAsm.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprObjC.cpp cfe/trunk/lib/Sema/SemaPseudoObject.cpp cfe/trunk/test/Misc/warning-flags.c Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=288548&r1=288547&r2=288548&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Dec 2 17:00:28 2016 @@ -846,8 +846,9 @@ def ObjCLiteralComparison : DiagGroup<"o // Inline ASM warnings. def ASMOperandWidths : DiagGroup<"asm-operand-widths">; +def ASMIgnoredQualifier : DiagGroup<"asm-ignored-qualifier">; def ASM : DiagGroup<"asm", [ -ASMOperandWidths +ASMOperandWidths, ASMIgnoredQualifier ]>; // OpenMP warnings. Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=288548&r1=288547&r2=288548&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Dec 2 17:00:28 2016 @@ -13,10 +13,11 @@ let Component = "Parse" in { -def w_asm_qualifier_ignored : Warning<"ignored %0 qualifier on asm">, - CatInlineAsm; +def warn_asm_qualifier_ignored : Warning< + "ignored %0 qualifier on asm">, CatInlineAsm, InGroup; def warn_file_asm_volatile : Warning< - "meaningless 'volatile' on asm outside function">, CatInlineAsm; + "meaningless 'volatile' on asm outside function">, CatInlineAsm, + InGroup; let CategoryName = "Inline Assembly Issue" in { def err_asm_empty : Error<"__asm used with no assembly instructions">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=288548&r1=288547&r2=288548&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 2 17:00:28 2016 @@ -906,7 +906,7 @@ def warn_strict_multiple_method_decl : W "multiple methods named %0 found">, InGroup, DefaultIgnore; def warn_accessor_property_type_mismatch : Warning< "type of property %0 does not match type of accessor %1">; -def not_conv_function_declared_at : Note<"type conversion function declared here">; +def note_conv_function_declared_at : Note<"type conversion function declared here">; def note_method_declared_at : Note<"method %0 declared here">; def note_property_attribute : Note<"property %0 is declared " "%select{deprecated|unavailable|partial}1 here">; @@ -1134,7 +1134,7 @@ def warn_unimplemented_selector: Warnin InGroup, DefaultIgnore; def warn_unimplemented_protocol_method : Warning< "method %0 in protocol %1 not implemented">, InGroup; -def warning_multiple_selectors: Warning< +def warn_multiple_selectors: Warning< "several methods with selector %0 of mismatched types are found " "for the @selector expression">, InGroup, DefaultIgnore; @@ -6409,7 +6409,7 @@ def err_typecheck_missing_return_type_in "return type must match previous return type}0,1 when %select{block " "literal|lambda expression}2 has unspecified explicit return type">; -def not_incomplete_class_and_qualified_id : Note< +def note_incomplete_class_and_qualified_id : Note< "conformance of forward class %0 to protocol %1 can not be confirmed">; def warn_incompatible_qualified_id : Warning< "%select{%diff{assigning to $ from incompatible type $|" @@ -8555,7 +8555,7 @@ def err_omp_expected_int_param : Error< "expected a reference to an integer-typed parameter">; def err_omp_at_least_one_motion_clause_required : Error< "expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'">; -def err_omp_usedeviceptr_not_a_pointer : Error< +def err_omp_usedeviceptr_not_a_pointer : Error< "expected pointer or reference to pointer in 'use_device_ptr' clause">; def err_omp_argument_type_isdeviceptr : Error < "expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'">; Modified: cfe/trunk/lib/
[libcxx] r288550 - Update ABI lists for
Author: ericwf Date: Fri Dec 2 17:11:28 2016 New Revision: 288550 URL: http://llvm.org/viewvc/llvm-project?rev=288550&view=rev Log: Update ABI lists for Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=288550&r1=288549&r2=288550&view=diff == --- libcxx/trunk/lib/abi/CHANGELOG.TXT (original) +++ libcxx/trunk/lib/abi/CHANGELOG.TXT Fri Dec 2 17:11:28 2016 @@ -16,6 +16,15 @@ New entries should be added directly bel Version 4.0 --- +* r288547 - Implement C++17 + + All Platforms + - + Symbol added: _ZTVSt18bad_variant_access + Symbol added: _ZTISt18bad_variant_access + Symbol added: _ZTSSt18bad_variant_access + Symbol added: _ZNKSt18bad_variant_access4whatEv + * rTBD - Remove std::string::append template methods which should be inline These functions should never have had visible definitions in the dylib but Modified: libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist?rev=288550&r1=288549&r2=288550&view=diff == --- libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist (original) +++ libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.abilist Fri Dec 2 17:11:28 2016 @@ -3,6 +3,7 @@ {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt12experimental15fundamentals_v112bad_any_cast4whatEv'} {'is_defined': False, 'type': 'FUNC', 'name': '_ZNKSt13runtime_error4whatEv'} {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt16nested_exception14rethrow_nestedEv'} +{'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt18bad_variant_access4whatEv'} {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__110__time_put8__do_putEPcRS1_PK2tmcc'} {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__110__time_put8__do_putEPwRS1_PK2tmcc'} {'is_defined': True, 'type': 'FUNC', 'name': '_ZNKSt3__110error_code7messageEv'} @@ -1600,6 +1601,7 @@ {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTISt14overflow_error', 'size': 0} {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTISt16invalid_argument', 'size': 0} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTISt16nested_exception', 'size': 16} +{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTISt18bad_variant_access', 'size': 24} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTISt19bad_optional_access', 'size': 24} {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTISt8bad_cast', 'size': 0} {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTISt9bad_alloc', 'size': 0} @@ -1718,6 +1720,7 @@ {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSNSt3__19time_baseE', 'size': 19} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSSt12bad_any_cast', 'size': 17} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSSt16nested_exception', 'size': 21} +{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSSt18bad_variant_access', 'size': 23} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTSSt19bad_optional_access', 'size': 24} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTTNSt3__110istrstreamE', 'size': 32} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTTNSt3__110ostrstreamE', 'size': 32} @@ -1829,6 +1832,7 @@ {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTVSt14overflow_error', 'size': 0} {'is_defined': False, 'type': 'OBJECT', 'name': '_ZTVSt16invalid_argument', 'size': 0} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVSt16nested_exception', 'size': 32} +{'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVSt18bad_variant_access', 'size': 40} {'is_defined': True, 'type': 'OBJECT', 'name': '_ZTVSt19bad_optional_access', 'size': 40} {'is_defined': True, 'type': 'FUNC', 'name': '_ZThn16_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED0Ev'} {'is_defined': True, 'type': 'FUNC', 'name': '_ZThn16_NSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev'} @@ -1885,4 +1889,3 @@ {'is_defined': False, 'type': 'FUNC', 'name': '__cxa_rethrow_primary_exception'} {'is_defined': False, 'type': 'FUNC', 'name': '__cxa_throw'} {'is_defined': False, 'type': 'FUNC', 'name': '__cxa_uncaught_exception'} -{'is_defined': False, 'type': 'FUNC', 'name': '__gxx_personality_v0'} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288551 - Update darwin ABI list for
Author: ericwf Date: Fri Dec 2 17:14:18 2016 New Revision: 288551 URL: http://llvm.org/viewvc/llvm-project?rev=288551&view=rev Log: Update darwin ABI list for Modified: libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist Modified: libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist?rev=288551&r1=288550&r2=288551&view=diff == --- libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist (original) +++ libcxx/trunk/lib/abi/x86_64-apple-darwin16.0.0.abilist Fri Dec 2 17:14:18 2016 @@ -11,6 +11,7 @@ {'type': 'U', 'is_defined': False, 'name': '__ZNKSt16bad_array_length4whatEv'} {'type': 'I', 'is_defined': True, 'name': '__ZNKSt16bad_array_length4whatEv'} {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt16nested_exception14rethrow_nestedEv'} +{'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt18bad_variant_access4whatEv'} {'type': 'U', 'is_defined': False, 'name': '__ZNKSt20bad_array_new_length4whatEv'} {'type': 'I', 'is_defined': True, 'name': '__ZNKSt20bad_array_new_length4whatEv'} {'type': 'FUNC', 'is_defined': True, 'name': '__ZNKSt3__110__time_put8__do_putEPcRS1_PK2tmcc'} @@ -1792,6 +1793,7 @@ {'type': 'U', 'is_defined': False, 'name': '__ZTISt16invalid_argument'} {'type': 'I', 'is_defined': True, 'name': '__ZTISt16invalid_argument'} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTISt16nested_exception', 'size': 0} +{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTISt18bad_variant_access', 'size': 0} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTISt19bad_optional_access', 'size': 0} {'type': 'U', 'is_defined': False, 'name': '__ZTISt20bad_array_new_length'} {'type': 'I', 'is_defined': True, 'name': '__ZTISt20bad_array_new_length'} @@ -2046,6 +2048,7 @@ {'type': 'U', 'is_defined': False, 'name': '__ZTSSt16invalid_argument'} {'type': 'I', 'is_defined': True, 'name': '__ZTSSt16invalid_argument'} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSSt16nested_exception', 'size': 0} +{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSSt18bad_variant_access', 'size': 0} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTSSt19bad_optional_access', 'size': 0} {'type': 'U', 'is_defined': False, 'name': '__ZTSSt20bad_array_new_length'} {'type': 'I', 'is_defined': True, 'name': '__ZTSSt20bad_array_new_length'} @@ -2236,6 +2239,7 @@ {'type': 'U', 'is_defined': False, 'name': '__ZTVSt16invalid_argument'} {'type': 'I', 'is_defined': True, 'name': '__ZTVSt16invalid_argument'} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVSt16nested_exception', 'size': 0} +{'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVSt18bad_variant_access', 'size': 0} {'type': 'OBJECT', 'is_defined': True, 'name': '__ZTVSt19bad_optional_access', 'size': 0} {'type': 'U', 'is_defined': False, 'name': '__ZTVSt20bad_array_new_length'} {'type': 'I', 'is_defined': True, 'name': '__ZTVSt20bad_array_new_length'} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288552 - Fix generated warnings in
Author: ericwf Date: Fri Dec 2 17:17:33 2016 New Revision: 288552 URL: http://llvm.org/viewvc/llvm-project?rev=288552&view=rev Log: Fix generated warnings in Modified: libcxx/trunk/include/variant Modified: libcxx/trunk/include/variant URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=288552&r1=288551&r2=288552&view=diff == --- libcxx/trunk/include/variant (original) +++ libcxx/trunk/include/variant Fri Dec 2 17:17:33 2016 @@ -453,7 +453,7 @@ private: static constexpr auto __make_farray(_Fs&&... __fs) { __std_visit_visitor_return_type_check...>(); using __result = array...>, sizeof...(_Fs)>; -return __result{_VSTD::forward<_Fs>(__fs)...}; +return __result{{_VSTD::forward<_Fs>(__fs)...}}; } template @@ -645,13 +645,14 @@ class _LIBCPP_TYPE_VIS_ONLY __base { public: inline _LIBCPP_INLINE_VISIBILITY explicit constexpr __base(__valueless_t tag) noexcept - : __index(__variant_npos), __data(tag) {} + : __data(tag), __index(__variant_npos) {} template inline _LIBCPP_INLINE_VISIBILITY explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args) - : __index(_Ip), -__data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {} + : +__data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...), +__index(_Ip) {} inline _LIBCPP_INLINE_VISIBILITY constexpr bool valueless_by_exception() const noexcept { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288554 - Make variant's index part of the hash value
Author: ericwf Date: Fri Dec 2 17:38:31 2016 New Revision: 288554 URL: http://llvm.org/viewvc/llvm-project?rev=288554&view=rev Log: Make variant's index part of the hash value Modified: libcxx/trunk/include/memory libcxx/trunk/include/variant libcxx/trunk/src/experimental/filesystem/path.cpp libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=288554&r1=288553&r2=288554&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Fri Dec 2 17:38:31 2016 @@ -3345,6 +3345,17 @@ struct __scalar_hash<_Tp, 4> } }; +_LIBCPP_INLINE_VISIBILITY +inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { +struct _PairT { + size_t first; + size_t second; +}; +typedef __scalar_hash<_PairT> _HashT; +const _PairT __p{__lhs, __rhs}; +return _HashT()(__p); +} + template struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> : public unary_function<_Tp*, size_t> Modified: libcxx/trunk/include/variant URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=288554&r1=288553&r2=288554&view=diff == --- libcxx/trunk/include/variant (original) +++ libcxx/trunk/include/variant Fri Dec 2 17:38:31 2016 @@ -1526,7 +1526,8 @@ struct _LIBCPP_TYPE_VIS_ONLY hash{}(__alt.__value); }, __v); +return __hash_combine(__res, hash{}(__v.index())); } }; Modified: libcxx/trunk/src/experimental/filesystem/path.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/path.cpp?rev=288554&r1=288553&r2=288554&view=diff == --- libcxx/trunk/src/experimental/filesystem/path.cpp (original) +++ libcxx/trunk/src/experimental/filesystem/path.cpp Fri Dec 2 17:38:31 2016 @@ -6,6 +6,7 @@ // Source Licenses. See LICENSE.TXT for details. // //===--===// +#undef NDEBUG #include "experimental/filesystem" #include "string_view" #include "utility" @@ -390,19 +391,13 @@ int path::__compare(string_view_t __s) c // path.nonmembers size_t hash_value(const path& __p) noexcept { auto PP = PathParser::CreateBegin(__p.native()); - struct HashPairT { -size_t first; -size_t second; - }; - HashPairT hp = {0, 0}; + size_t hash_value = 0; std::hash hasher; - std::__scalar_hash pair_hasher; while (PP) { -hp.second = hasher(*PP); -hp.first = pair_hasher(hp); +hash_value = __hash_combine(hash_value, hasher(*PP)); ++PP; } - return hp.first; + return hash_value; } Modified: libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp?rev=288554&r1=288553&r2=288554&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.hash/hash.pass.cpp Fri Dec 2 17:38:31 2016 @@ -105,7 +105,20 @@ void test_hash_monostate() { } } +void test_hash_variant_duplicate_elements() { +// Test that the index of the alternative participates in the hash value. +using V = std::variant; +using H = std::hash; +H h{}; +const V v1(std::in_place_index<0>); +const V v2(std::in_place_index<1>); +assert(h(v1) == h(v1)); +assert(h(v2) == h(v2)); +LIBCPP_ASSERT(h(v1) != h(v2)); +} + int main() { test_hash_variant(); + test_hash_variant_duplicate_elements(); test_hash_monostate(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288555 - Fix C++03 build
Author: ericwf Date: Fri Dec 2 17:41:18 2016 New Revision: 288555 URL: http://llvm.org/viewvc/llvm-project?rev=288555&view=rev Log: Fix C++03 build Modified: libcxx/trunk/include/memory libcxx/trunk/include/variant Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=288555&r1=288554&r2=288555&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Fri Dec 2 17:41:18 2016 @@ -3352,7 +3352,7 @@ inline size_t __hash_combine(size_t __lh size_t second; }; typedef __scalar_hash<_PairT> _HashT; -const _PairT __p{__lhs, __rhs}; +const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); } Modified: libcxx/trunk/include/variant URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=288555&r1=288554&r2=288555&view=diff == --- libcxx/trunk/include/variant (original) +++ libcxx/trunk/include/variant Fri Dec 2 17:41:18 2016 @@ -216,7 +216,7 @@ namespace std { // explicitly not using class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception { public: - _LIBCPP_FUNC_VIS virtual const char* what() const noexcept; + _LIBCPP_FUNC_VIS virtual const char* what() const _NOEXCEPT; }; } // namespace std ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288556 - Work around Clang 3.8 bugs
Author: ericwf Date: Fri Dec 2 18:13:33 2016 New Revision: 288556 URL: http://llvm.org/viewvc/llvm-project?rev=288556&view=rev Log: Work around Clang 3.8 bugs Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=288556&r1=288555&r2=288556&view=diff == --- libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Fri Dec 2 18:13:33 2016 @@ -10,6 +10,9 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 +// Clang 3.8 doesn't generate constexpr special members correctly. +// XFAIL: clang-3.8 + // // template class variant; @@ -174,8 +177,32 @@ void test_copy_assignment_different_inde } } +template +constexpr bool test_constexpr_assign_extension_imp( +std::variant&& v, ValueType&& new_value) +{ + const std::variant cp( + std::forward(new_value)); + v = cp; + return v.index() == NewIdx && +std::get(v) == std::get(cp); +} + +void test_constexpr_copy_assignment_extension() { +#ifdef _LIBCPP_VERSION + using V = std::variant; + static_assert(std::is_trivially_copyable::value, ""); + static_assert(std::is_trivially_copy_assignable::value, ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(42l), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(nullptr), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<1>(V(42l), nullptr), ""); + static_assert(test_constexpr_assign_extension_imp<2>(V(42l), 101), ""); +#endif +} + int main() { test_copy_assignment_same_index(); test_copy_assignment_different_index(); test_copy_assignment_sfinae(); + test_constexpr_copy_assignment_extension(); } Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=288556&r1=288555&r2=288556&view=diff == --- libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp (original) +++ libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp Fri Dec 2 18:13:33 2016 @@ -10,6 +10,9 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 +// Clang 3.8 doesn't generate constexpr special members correctly. +// XFAIL: clang-3.8 + // // template class variant; @@ -160,8 +163,34 @@ void test_move_assignment_different_inde } } + +template +constexpr bool test_constexpr_assign_extension_imp( +std::variant&& v, ValueType&& new_value) +{ + std::variant v2( + std::forward(new_value)); + const auto cp = v2; + v = std::move(v2); + return v.index() == NewIdx && +std::get(v) == std::get(cp); +} + +void test_constexpr_move_assignment_extension() { +#ifdef _LIBCPP_VERSION + using V = std::variant; + static_assert(std::is_trivially_copyable::value, ""); + static_assert(std::is_trivially_move_assignable::value, ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(42l), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<0>(V(nullptr), 101l), ""); + static_assert(test_constexpr_assign_extension_imp<1>(V(42l), nullptr), ""); + static_assert(test_constexpr_assign_extension_imp<2>(V(42l), 101), ""); +#endif +} + int main() { test_move_assignment_same_index(); test_move_assignment_different_index(); test_move_assignment_sfinae(); + test_constexpr_move_assignment_extension(); } Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=288556&r1=288555&r2=288556&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Fri Dec 2 18:13:33 2016 @@ -385,28 +385,6 @@ voi
[libcxx] r288557 - Enable warnings by default for C++ >= 11 and fix -Wshadow occurances
Author: ericwf Date: Fri Dec 2 18:27:13 2016 New Revision: 288557 URL: http://llvm.org/viewvc/llvm-project?rev=288557&view=rev Log: Enable warnings by default for C++ >= 11 and fix -Wshadow occurances Modified: libcxx/trunk/test/libcxx/test/config.py libcxx/trunk/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.native.obs/c_str.pass.cpp libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.native.obs/native.pass.cpp libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.native.obs/operator_string.pass.cpp libcxx/trunk/test/std/experimental/filesystem/class.rec.dir.itr/rec.dir.itr.members/ctor.pass.cpp libcxx/trunk/test/std/experimental/memory/memory.resource/memory.resource.public/allocate.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=288557&r1=288556&r2=288557&view=diff == --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Fri Dec 2 18:27:13 2016 @@ -640,8 +640,7 @@ class Configuration(object): '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror' ] -# FIXME turn this back on after fixing potential breakage. -#self.cxx.addWarningFlagIfSupported('-Wshadow') +self.cxx.addWarningFlagIfSupported('-Wshadow') self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument') self.cxx.addWarningFlagIfSupported('-Wno-attributes') self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move') @@ -649,10 +648,10 @@ class Configuration(object): self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals') # TODO(EricWF) Remove the unused warnings once the test suite # compiles clean with them. +self.cxx.addWarningFlagIfSupported('-Wno-sign-compare') self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') self.cxx.addWarningFlagIfSupported('-Wno-unused-variable') self.cxx.addWarningFlagIfSupported('-Wno-unused-parameter') -self.cxx.addWarningFlagIfSupported('-Wno-sign-compare') std = self.get_lit_conf('std', None) if std in ['c++98', 'c++03']: # The '#define static_assert' provided by libc++ in C++03 mode Modified: libcxx/trunk/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp?rev=288557&r1=288556&r2=288557&view=diff == --- libcxx/trunk/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/filesystem/class.directory_iterator/directory_iterator.members/ctor.pass.cpp Fri Dec 2 18:27:13 2016 @@ -87,9 +87,10 @@ TEST_CASE(access_denied_test_case) env.create_file(testFile, 42); // Test that we can iterator over the directory before changing the perms -directory_iterator it(testDir); -TEST_REQUIRE(it != directory_iterator{}); - +{ +directory_iterator it(testDir); +TEST_REQUIRE(it != directory_iterator{}); +} // Change the permissions so we can no longer iterate permissions(testDir, perms::none); Modified: libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp?rev=288557&r1=288556&r2=288557&view=diff == --- libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/filesystem/class.path/path.member/path.modifiers/clear.pass.cpp Fri Dec 2 18:27:13 2016 @@ -28,7 +28,6 @@ namespace fs = std::experimental::filesy int main() { using namespace fs; - const path p("/foo/bar/baz"); { path p; ASSERT_NOEXCEPT(p.clear()); @@ -37,6 +36,7 @@ int main() { assert(p.empty()); } {
r288558 - PR31244: Use the exception specification from the callee's type directly to
Author: rsmith Date: Fri Dec 2 18:29:06 2016 New Revision: 288558 URL: http://llvm.org/viewvc/llvm-project?rev=288558&view=rev Log: PR31244: Use the exception specification from the callee's type directly to compute whether a call is noexcept, even if we can't map the callee expression to a called declaration. Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=288558&r1=288557&r2=288558&view=diff == --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original) +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri Dec 2 18:29:06 2016 @@ -944,24 +944,37 @@ static CanThrowResult canSubExprsThrow(S } static CanThrowResult canCalleeThrow(Sema &S, const Expr *E, const Decl *D) { - assert(D && "Expected decl"); - - // See if we can get a function type from the decl somehow. - const ValueDecl *VD = dyn_cast(D); - if (!VD) { -// In C++17, we may have a canonical exception specification. If so, use it. -if (auto *FT = E->getType().getCanonicalType()->getAs()) - return FT->isNothrow(S.Context) ? CT_Cannot : CT_Can; -// If we have no clue what we're calling, assume the worst. -return CT_Can; - } - // As an extension, we assume that __attribute__((nothrow)) functions don't // throw. - if (isa(D) && D->hasAttr()) + if (D && isa(D) && D->hasAttr()) return CT_Cannot; - QualType T = VD->getType(); + QualType T; + + // In C++1z, just look at the function type of the callee. + if (S.getLangOpts().CPlusPlus1z && isa(E)) { +E = cast(E)->getCallee(); +T = E->getType(); +if (T->isSpecificPlaceholderType(BuiltinType::BoundMember)) { + // Sadly we don't preserve the actual type as part of the "bound member" + // placeholder, so we need to reconstruct it. + E = E->IgnoreParenImpCasts(); + + // Could be a call to a pointer-to-member or a plain member access. + if (auto *Op = dyn_cast(E)) { +assert(Op->getOpcode() == BO_PtrMemD || Op->getOpcode() == BO_PtrMemI); +T = Op->getRHS()->getType() + ->castAs()->getPointeeType(); + } else { +T = cast(E)->getMemberDecl()->getType(); + } +} + } else if (const ValueDecl *VD = dyn_cast_or_null(D)) +T = VD->getType(); + else +// If we have no clue what we're calling, assume the worst. +return CT_Can; + const FunctionProtoType *FT; if ((FT = T->getAs())) { } else if (const PointerType *PT = T->getAs()) @@ -1053,10 +1066,8 @@ CanThrowResult Sema::canThrow(const Expr CT = CT_Dependent; else if (isa(CE->getCallee()->IgnoreParens())) CT = CT_Cannot; -else if (CE->getCalleeDecl()) - CT = canCalleeThrow(*this, E, CE->getCalleeDecl()); else - CT = CT_Can; + CT = canCalleeThrow(*this, E, CE->getCalleeDecl()); if (CT == CT_Can) return CT; return mergeCanThrow(CT, canSubExprsThrow(*this, E)); Modified: cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp?rev=288558&r1=288557&r2=288558&view=diff == --- cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Fri Dec 2 18:29:06 2016 @@ -30,6 +30,21 @@ auto deduce_auto_from_noexcept_function_ using DeducedType_b = decltype(deduce_auto_from_noexcept_function_ptr_b); using DeducedType_b = void (*)(int); +static_assert(noexcept(init_with_exact_type_a(0))); +static_assert(noexcept((+init_with_exact_type_a)(0))); +static_assert(!noexcept(init_with_exact_type_b(0))); +static_assert(!noexcept((+init_with_exact_type_b)(0))); + +// Don't look through casts, use the direct type of the expression. +// FIXME: static_cast here would be reasonable, but is not currently permitted. +static_assert(noexcept(static_cast(init_with_exact_type_b)(0))); // expected-error {{is not allowed}} +static_assert(noexcept(reinterpret_cast(init_with_exact_type_b)(0))); +static_assert(!noexcept(static_cast(init_with_exact_type_a)(0))); + +template auto get_fn() noexcept -> void (*)() noexcept(B) {} +static_assert(noexcept(get_fn()())); +static_assert(!noexcept(get_fn()())); + namespace DependentDefaultCtorExceptionSpec { template struct T { static const bool value = true; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288559 - XFAIL variant tests for apple-clang
Author: ericwf Date: Fri Dec 2 18:33:03 2016 New Revision: 288559 URL: http://llvm.org/viewvc/llvm-project?rev=288559&view=rev Log: XFAIL variant tests for apple-clang Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=288559&r1=288558&r2=288559&view=diff == --- libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original) +++ libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Fri Dec 2 18:33:03 2016 @@ -11,7 +11,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // Clang 3.8 doesn't generate constexpr special members correctly. -// XFAIL: clang-3.8 +// XFAIL: clang-3.8, apple-clang-7 // Modified: libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp?rev=288559&r1=288558&r2=288559&view=diff == --- libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp (original) +++ libcxx/trunk/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp Fri Dec 2 18:33:03 2016 @@ -11,7 +11,8 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // Clang 3.8 doesn't generate constexpr special members correctly. -// XFAIL: clang-3.8 +// XFAIL: clang-3.8, apple-clang-7 + // Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp?rev=288559&r1=288558&r2=288559&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/index.pass.cpp Fri Dec 2 18:33:03 2016 @@ -11,7 +11,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // Clang 3.8 doesn't allow constexpr variables of non-literal type -// XFAIL: clang-3.8 +// XFAIL: clang-3.8, apple-clang-7 // Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp?rev=288559&r1=288558&r2=288559&view=diff == --- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.status/valueless_by_exception.pass.cpp Fri Dec 2 18:33:03 2016 @@ -11,7 +11,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // Clang 3.8 doesn't allow constexpr variables of non-literal type -// XFAIL: clang-3.8 +// XFAIL: clang-3.8, apple-clang-7 // ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27377: clang-format: Support the Java 8 'default' method modifier
lhchavez created this revision. lhchavez added a reviewer: djasper. lhchavez added subscribers: srhines, cfe-commits. Herald added a subscriber: klimek. Java 8 introduced the use of using the 'default' keyword as modifier in interface method declarations[1]. Previously it was being parsed as being part of a label, which put the parser into a very weird state it could not get out of. This change adds support for 'default' by treating it as a normal identifier in Java when the parser is expecting a declaration. 1: http://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html https://reviews.llvm.org/D27377 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJava.cpp Index: unittests/Format/FormatTestJava.cpp === --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -515,5 +515,20 @@ " void f() {}")); } +TEST_F(FormatTestJava, UnderstandsDefaultModifier) { + verifyFormat("class SomeClass {\n" + " default void f() {}\n" + " int g() {\n" + "switch (0) {\n" + " case 0:\n" + "break;\n" + " default:\n" + "break;\n" + "}\n" + " }\n" + "}", + getGoogleStyle(FormatStyle::LK_Java)); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -294,6 +294,15 @@ addUnwrappedLine(); break; case tok::kw_default: + if (Style.Language != FormatStyle::LK_Java || !Line->MustBeDeclaration) { +if (!SwitchLabelEncountered && +(Style.IndentCaseLabels || + (Line->InPPDirective && Line->Level == 1))) + ++Line->Level; +SwitchLabelEncountered = true; + } + parseStructuralElement(); + break; case tok::kw_case: if (!SwitchLabelEncountered && (Style.IndentCaseLabels || (Line->InPPDirective && Line->Level == 1))) @@ -853,9 +862,13 @@ parseSwitch(); return; case tok::kw_default: -nextToken(); -parseLabel(); -return; +if (Style.Language != FormatStyle::LK_Java || !Line->MustBeDeclaration) { + nextToken(); + parseLabel(); + return; +} +// 'default' can appear in a Java 8 declaration. Parse it as such. +break; case tok::kw_case: parseCaseLabel(); return; Index: unittests/Format/FormatTestJava.cpp === --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -515,5 +515,20 @@ " void f() {}")); } +TEST_F(FormatTestJava, UnderstandsDefaultModifier) { + verifyFormat("class SomeClass {\n" + " default void f() {}\n" + " int g() {\n" + "switch (0) {\n" + " case 0:\n" + "break;\n" + " default:\n" + "break;\n" + "}\n" + " }\n" + "}", + getGoogleStyle(FormatStyle::LK_Java)); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -294,6 +294,15 @@ addUnwrappedLine(); break; case tok::kw_default: + if (Style.Language != FormatStyle::LK_Java || !Line->MustBeDeclaration) { +if (!SwitchLabelEncountered && +(Style.IndentCaseLabels || + (Line->InPPDirective && Line->Level == 1))) + ++Line->Level; +SwitchLabelEncountered = true; + } + parseStructuralElement(); + break; case tok::kw_case: if (!SwitchLabelEncountered && (Style.IndentCaseLabels || (Line->InPPDirective && Line->Level == 1))) @@ -853,9 +862,13 @@ parseSwitch(); return; case tok::kw_default: -nextToken(); -parseLabel(); -return; +if (Style.Language != FormatStyle::LK_Java || !Line->MustBeDeclaration) { + nextToken(); + parseLabel(); + return; +} +// 'default' can appear in a Java 8 declaration. Parse it as such. +break; case tok::kw_case: parseCaseLabel(); return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27377: clang-format: Support the Java 8 'default' method modifier
srhines added a comment. Looks good, but I I want to make sure that someone else more familiar with this is ok with it too. Thanks. https://reviews.llvm.org/D27377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288563 - DR616, and part of P0135R1: member access (or pointer-to-member access) on a
Author: rsmith Date: Fri Dec 2 19:14:32 2016 New Revision: 288563 URL: http://llvm.org/viewvc/llvm-project?rev=288563&view=rev Log: DR616, and part of P0135R1: member access (or pointer-to-member access) on a temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Analysis/ThreadSafety.cpp cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp cfe/trunk/test/CXX/drs/dr4xx.cpp cfe/trunk/test/CXX/drs/dr6xx.cpp cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp cfe/trunk/test/CodeGenCXX/compound-literals.cpp cfe/trunk/test/SemaCXX/constexpr-value-init.cpp cfe/trunk/test/SemaCXX/expression-traits.cpp cfe/trunk/test/SemaObjC/assign-rvalue-message.m cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp cfe/trunk/www/cxx_dr_status.html Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288563&r1=288562&r2=288563&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Fri Dec 2 19:14:32 2016 @@ -839,6 +839,11 @@ public: const Expr *skipRValueSubobjectAdjustments( SmallVectorImpl &CommaLHS, SmallVectorImpl &Adjustments) const; + const Expr *skipRValueSubobjectAdjustments() const { +SmallVector CommaLHSs; +SmallVector Adjustments; +return skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + } static bool classof(const Stmt *T) { return T->getStmtClass() >= firstExprConstant && Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=288563&r1=288562&r2=288563&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec 2 19:14:32 2016 @@ -8715,6 +8715,11 @@ public: // argument, and arguments that have type float are promoted to double. ExprResult DefaultArgumentPromotion(Expr *E); + /// If \p E is a prvalue denoting an unmaterialized temporary, materialize + /// it as an xvalue. In C++98, the result will still be a prvalue, because + /// we don't have xvalues there. + ExprResult TemporaryMaterializationConversion(Expr *E); + // Used for emitting the right warning by DefaultVariadicArgumentPromotion enum VariadicCallType { VariadicFunction, Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=288563&r1=288562&r2=288563&view=diff == --- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original) +++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Fri Dec 2 19:14:32 2016 @@ -1583,7 +1583,7 @@ void BuildLockset::warnIfMutexHeld(const /// a pointer marked with pt_guarded_by. void BuildLockset::checkAccess(const Expr *Exp, AccessKind AK, ProtectedOperationKind POK) { - Exp = Exp->IgnoreParenCasts(); + Exp = Exp->IgnoreImplicit()->IgnoreParenCasts(); SourceLocation Loc = Exp->getExprLoc(); Modified: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp?rev=288563&r1=288562&r2=288563&view=diff == --- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp (original) +++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp Fri Dec 2 19:14:32 2016 @@ -233,6 +233,9 @@ til::SExpr *SExprBuilder::translate(cons return translate(cast(S)->getSubExpr(), Ctx); case Stmt::CXXBindTemporaryExprClass: return translate(cast(S)->getSubExpr(), Ctx); + case Stmt::MaterializeTemporaryExprClass: +return translate(cast(S)->GetTemporaryExpr(), + Ctx); // Collect all literals case Stmt::CharacterLiteralClass: Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=288563&r1=288562&r2=288563&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec 2 19:14:32 2016 @@ -9810,8 +9810,8 @@ static bool IsReadonlyMessage(Expr *E, S const MemberExpr *ME = dyn_cast(E); if (!ME) return false; if (!isa(ME->getMemberDecl())) return false; - ObjCMessageExpr *Base = -dyn_cast(ME->getBase()->IgnoreParenImpCasts()); + ObjCMes
[libcxx] r288564 - Fix -Wshadow warnings and enable warnings by default for C++ >= 11
Author: ericwf Date: Fri Dec 2 19:21:40 2016 New Revision: 288564 URL: http://llvm.org/viewvc/llvm-project?rev=288564&view=rev Log: Fix -Wshadow warnings and enable warnings by default for C++ >= 11 Modified: libcxx/trunk/include/forward_list libcxx/trunk/test/libcxx/test/config.py Modified: libcxx/trunk/include/forward_list URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/forward_list?rev=288564&r1=288563&r2=288564&view=diff == --- libcxx/trunk/include/forward_list (original) +++ libcxx/trunk/include/forward_list Fri Dec 2 19:21:40 2016 @@ -876,8 +876,9 @@ forward_list<_Tp, _Alloc>::forward_list( #if _LIBCPP_STD_VER > 11 template -forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) -: base ( __a ) +forward_list<_Tp, _Alloc>::forward_list(size_type __n, +const allocator_type& __base_alloc) +: base ( __base_alloc ) { if (__n > 0) { Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=288564&r1=288563&r2=288564&view=diff == --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Fri Dec 2 19:21:40 2016 @@ -634,7 +634,11 @@ class Configuration(object): self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level] def configure_warnings(self): -enable_warnings = self.get_lit_bool('enable_warnings', False) +default_enable_warnings = len( +self.config.available_features.intersection( +['c++11', 'c++14', 'c++1z'])) != 0 +enable_warnings = self.get_lit_bool('enable_warnings', +default_enable_warnings) if enable_warnings: self.cxx.warning_flags += [ '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288565 - [Sema] Don't perform aggregate initialization for types with explicit constructors
Author: ericwf Date: Fri Dec 2 19:26:47 2016 New Revision: 288565 URL: http://llvm.org/viewvc/llvm-project?rev=288565&view=rev Log: [Sema] Don't perform aggregate initialization for types with explicit constructors Summary: The C++17 rules for aggregate initialization changed to disallow types with explicit constructors [dcl.init.aggr]p1. This patch implements that new rule. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25654 Modified: cfe/trunk/lib/AST/DeclCXX.cpp cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp cfe/trunk/test/CXX/dcl.decl/dcl.init/p7.cpp cfe/trunk/test/CXX/drs/dr15xx.cpp Modified: cfe/trunk/lib/AST/DeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=288565&r1=288564&r2=288565&view=diff == --- cfe/trunk/lib/AST/DeclCXX.cpp (original) +++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Dec 2 19:26:47 2016 @@ -533,6 +533,17 @@ void CXXRecordDecl::addedMember(Decl *D) } else if (Constructor->isMoveConstructor()) SMKind |= SMF_MoveConstructor; } + +// C++ [dcl.init.aggr]p1: +// An aggregate is an array or a class with no user-declared +// constructors [...]. +// C++11 [dcl.init.aggr]p1: DR1518 +// An aggregate is an array or a class with no user-provided, explicit, or +// inherited constructors +if (getASTContext().getLangOpts().CPlusPlus11 +? (Constructor->isUserProvided() || Constructor->isExplicit()) +: !Constructor->isImplicit()) + data().Aggregate = false; } // Handle constructors, including those inherited from base classes. @@ -546,20 +557,6 @@ void CXXRecordDecl::addedMember(Decl *D) // constructor [...] if (Constructor->isConstexpr() && !Constructor->isCopyOrMoveConstructor()) data().HasConstexprNonCopyMoveConstructor = true; - -// C++ [dcl.init.aggr]p1: -// An aggregate is an array or a class with no user-declared -// constructors [...]. -// C++11 [dcl.init.aggr]p1: -// An aggregate is an array or a class with no user-provided -// constructors [...]. -// C++11 [dcl.init.aggr]p1: -// An aggregate is an array or a class with no user-provided -// constructors (including those inherited from a base class) [...]. -if (getASTContext().getLangOpts().CPlusPlus11 -? Constructor->isUserProvided() -: !Constructor->isImplicit()) - data().Aggregate = false; } // Handle destructors. @@ -989,8 +986,12 @@ void CXXRecordDecl::addedMember(Decl *D) if (UsingDecl *Using = dyn_cast(D)) { if (Using->getDeclName().getNameKind() == -DeclarationName::CXXConstructorName) +DeclarationName::CXXConstructorName) { data().HasInheritedConstructor = true; + // C++1z [dcl.init.aggr]p1: + // An aggregate is [...] a class [...] with no inherited constructors + data().Aggregate = false; +} if (Using->getDeclName().getCXXOverloadedOperator() == OO_Equal) data().HasInheritedAssignment = true; Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp?rev=288565&r1=288564&r2=288565&view=diff == --- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp (original) +++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp Fri Dec 2 19:26:47 2016 @@ -122,3 +122,39 @@ struct DefaultedAggr { ~DefaultedAggr() = default; }; DefaultedAggr da = { 42 } ; + +struct ExplicitDefaultedAggr { + int n; + explicit ExplicitDefaultedAggr() = default; // expected-note {{candidate}} + ExplicitDefaultedAggr(const ExplicitDefaultedAggr &) = default; // expected-note {{candidate}} + ExplicitDefaultedAggr(ExplicitDefaultedAggr &&) = default; // expected-note {{candidate}} +}; +ExplicitDefaultedAggr eda = { 42 }; // expected-error {{no matching constructor}} +ExplicitDefaultedAggr eda2{}; + +struct DefaultedBase { + int n; + DefaultedBase() = default; // expected-note 0+ {{candidate}} + DefaultedBase(DefaultedBase const&) = default; // expected-note 0+ {{candidate}} + DefaultedBase(DefaultedBase &&) = default; // expected-note 0+ {{candidate}} +}; + +struct InheritingConstructors : DefaultedBase { // expected-note 3 {{candidate}} + using DefaultedBase::DefaultedBase; // expected-note 2 {{inherited here}} +}; +InheritingConstructors ic = { 42 }; // expected-error {{no matching constructor}} + +struct NonInheritingConstructors : DefaultedBase {}; // expected-note 0+ {{candidate}} +NonInheritingConstructors nic = { 42 }; +#if __cplusplus <= 201402L +// expected-error@-2 {{no matching constructor}} +#endif + +struct NonAggrBase { + NonAggrBase(int) {} +}; +struct HasNonAggrBase : NonAggrBase {}; //
[libcxx] r288566 - Revert workaround for Clang bug. Thanks to Richard for the quick fix
Author: ericwf Date: Fri Dec 2 19:28:01 2016 New Revision: 288566 URL: http://llvm.org/viewvc/llvm-project?rev=288566&view=rev Log: Revert workaround for Clang bug. Thanks to Richard for the quick fix Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp Modified: libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp?rev=288566&r1=288565&r2=288566&view=diff == --- libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.rel/is_nothrow_callable.pass.cpp Fri Dec 2 19:28:01 2016 @@ -54,11 +54,7 @@ constexpr bool throws_callable() { void test_noexcept_function_pointers() { struct Dummy { void foo() noexcept {} static void bar() noexcept {} }; - -// FIXME(EricWF): Remove the __clang__ workaround. As of 2/12/2016 Clang has -// a bug where calling a noexcept function pointer is not noexcept. -// See https://llvm.org/bugs/show_bug.cgi?id=31244 -#if !defined(__cpp_noexcept_function_type) || defined(__clang__) +#if !defined(__cpp_noexcept_function_type) { // Check that PMF's and function pointers *work*. is_nothrow_callable will always // return false because 'noexcept' is not part of the function type. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27360: [clang] Fix D26214: Move error handling out of MC and to the callers.
compnerd added a comment. I think that the argument parsing should really be hoisted into the driver rather than pushed down into the assembler. The driver can parse and validate the options before passing them down, so when cc1as gets it, it will simply set the value. The newly introduced diagnostics, especially right now, are not driver related. Nor are they common. I would say that we would need a DiagnosticAssemblerKind.td for these. https://reviews.llvm.org/D27360 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r288571 - Fix w/o exception support
Author: ericwf Date: Fri Dec 2 19:58:07 2016 New Revision: 288571 URL: http://llvm.org/viewvc/llvm-project?rev=288571&view=rev Log: Fix w/o exception support Modified: libcxx/trunk/include/variant Modified: libcxx/trunk/include/variant URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/variant?rev=288571&r1=288570&r2=288571&view=diff == --- libcxx/trunk/include/variant (original) +++ libcxx/trunk/include/variant Fri Dec 2 19:58:07 2016 @@ -225,6 +225,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 +_LIBCPP_NORETURN +inline _LIBCPP_INLINE_VISIBILITY +void __throw_bad_variant_access() { +#ifndef _LIBCPP_NO_EXCEPTIONS +throw bad_variant_access(); +#else +_VSTD::abort(); +#endif +} + template class _LIBCPP_TYPE_VIS_ONLY variant; @@ -1291,7 +1301,7 @@ inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __generic_get(_Vp&& __v) { using __variant_detail::__access::__variant; if (!__holds_alternative<_Ip>(__v)) { -throw bad_variant_access{}; +__throw_bad_variant_access(); } return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value; } @@ -1483,7 +1493,7 @@ constexpr decltype(auto) visit(_Visitor& bool __results[] = {__vs.valueless_by_exception()...}; for (bool __result : __results) { if (__result) { - throw bad_variant_access{}; + __throw_bad_variant_access(); } } return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits