[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values
materi added a comment. In https://reviews.llvm.org/D38101#901733, @lebedev.ri wrote: > In https://reviews.llvm.org/D38101#901709, @materi wrote: > > > Hi! > > > Hi. > > > After this patch I started to see warnings: > > Thank you for the report! > > > e.c:8:23: warning: integer constant not in range of enumerated type 'enum > > E' [-Wassign-enum] > > enum E {a = 7,} e = 1000; > > ^ > > e.c:10:12: warning: comparison 'enum E' > 7 is always false > > [-Wtautological-constant-compare] > > return e > 7; > > > > > > Isn't the the "always false" message misleading? It's only "always false" > > if e was initialized with an in-range value. Maybe the tautology check > > should be on the enum's underlying type instead? > > I agree, please open a bug, i'll look into this. Here it is: https://bugs.llvm.org/show_bug.cgi?id=35009 Thanks! Repository: rL LLVM https://reviews.llvm.org/D38101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39114: [XRay] Initial XRay in Darwin Support
dberris created this revision. Herald added a subscriber: mgorny. This is a work-in-progress change that attempts to allow us to build and use the XRay runtime in Darwin. Current state: - Assembler files are broken due to assumptions about ELFisms. - Test infrastructure is laid out, but we aren't able to test yet. We also: - Use a better preprocessor check for preinint array support. - Only build for osx. - Enable the use of -fxray-instrument (and other flags) in clang. This patch uses the monorepo layout for the chnage. https://reviews.llvm.org/D39114 Files: clang/lib/Driver/XRayArgs.cpp compiler-rt/cmake/config-ix.cmake compiler-rt/lib/xray/CMakeLists.txt compiler-rt/lib/xray/tests/CMakeLists.txt compiler-rt/lib/xray/xray_init.cc compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg compiler-rt/test/xray/TestCases/Linux/lit.local.cfg compiler-rt/test/xray/lit.cfg Index: compiler-rt/test/xray/lit.cfg === --- compiler-rt/test/xray/lit.cfg +++ compiler-rt/test/xray/lit.cfg @@ -40,7 +40,7 @@ # Default test suffixes. config.suffixes = ['.c', '.cc', '.cpp'] -if config.host_os not in ['Linux']: +if config.host_os not in ['Linux', 'Darwin']: config.unsupported = True elif '64' not in config.host_arch: if 'arm' in config.host_arch: Index: compiler-rt/test/xray/TestCases/Linux/lit.local.cfg === --- /dev/null +++ compiler-rt/test/xray/TestCases/Linux/lit.local.cfg @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: +return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Linux']: + config.unsupported = True Index: compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg === --- /dev/null +++ compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg @@ -0,0 +1,9 @@ +def getRoot(config): + if not config.parent: +return config + return getRoot(config.parent) + +root = getRoot(config) + +if root.host_os not in ['Darwin']: + config.unsupported = True Index: compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc === --- /dev/null +++ compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc @@ -0,0 +1,23 @@ +// Test that the always/never instrument lists apply. +// RUN: echo "fun:main" > %tmp-always.txt +// RUN: echo "fun:__xray*" > %tmp-never.txt +// RUN: %clangxx_xray \ +// RUN: -fxray-never-instrument=%tmp-never.txt \ +// RUN: -fxray-always-instrument=%tmp-always.txt \ +// RUN: %s -o %t +// RUN: %llvm_xray extract -symbolize %t | \ +// RUN:FileCheck %s --check-prefix NOINSTR +// RUN: %llvm_xray extract -symbolize %t | \ +// RUN:FileCheck %s --check-prefix ALWAYSINSTR +// REQUIRES: x86_64-linux +// REQUIRES: built-in-llvm-tree + +// NOINSTR-NOT: {{.*__xray_NeverInstrumented.*}} +int __xray_NeverInstrumented() { + return 0; +} + +// ALWAYSINSTR: {{.*function-name:.*main.*}} +int main(int argc, char *argv[]) { + return __xray_NeverInstrumented(); +} Index: compiler-rt/lib/xray/xray_init.cc === --- compiler-rt/lib/xray/xray_init.cc +++ compiler-rt/lib/xray/xray_init.cc @@ -88,7 +88,8 @@ #endif } -#ifndef XRAY_NO_PREINIT +// Only add the preinit array initialization if the sanitizers can. +#if !defined(XRAY_NO_PREINIT) && SANITIZER_CAN_USE_PREINIT_ARRAY __attribute__((section(".preinit_array"), used)) void (*__local_xray_preinit)(void) = __xray_init; #endif Index: compiler-rt/lib/xray/tests/CMakeLists.txt === --- compiler-rt/lib/xray/tests/CMakeLists.txt +++ compiler-rt/lib/xray/tests/CMakeLists.txt @@ -12,9 +12,19 @@ -I${COMPILER_RT_SOURCE_DIR}/lib) set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH}) +set(XRAY_LINK_FLAGS) +append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_LINK_FLAGS) +append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_LINK_FLAGS) +append_list_if(COMPILER_RT_HAS_LIBPTHREAD -lpthread XRAY_LINK_FLAGS) +if (APPLE) + list(APPEND XRAY_LINK_FLAGS -lc++) +else() + append_list_if(COMPILER_RT_HAS_LIBSTDCXX lstdc++ XRAY_LINK_FLAGS) +endif() + macro(add_xray_unittest testname) cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN}) - if(UNIX AND NOT APPLE) + if(UNIX) foreach(arch ${XRAY_TEST_ARCH}) set(TEST_OBJECTS) generate_compiler_rt_tests(TEST_OBJECTS @@ -24,9 +34,8 @@ CFLAGS ${XRAY_UNITTEST_CFLAGS} LINK_FLAGS -fxray-instrument ${TARGET_LINK_FLAGS} - -lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT} - -lpthread - -ldl -lrt) + ${CMAKE_THREAD_LIBS_INIT} + ${XRAY_LINK_FLAGS}) set_target_properties(XRayUnitTests PROPERTIES RUNTIME_O
clang patch for -fno-var-tracking-assignments option
Hi All, The attached patch adds a new option '-fno-var-tracking-assignments' in the same group (clang_ignored_f_Group) where the existing '-fno-var-tracking' resides. Thanks, Mikhail clang-no-var-tracking-assignments.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: clang patch for -fno-var-tracking-assignments option
On Fri, Oct 20, 2017 at 11:44 AM, Mikhail Artemyev via cfe-commits wrote: > Hi All, > > The attached patch adds a new option '-fno-var-tracking-assignments' in the > same group (clang_ignored_f_Group) where the existing '-fno-var-tracking' > resides. It might be best to upload it to https://llvm.org/docs/Phabricator.html, so that it is easier to track, and it won't get lost that way. > Thanks, > Mikhail Roman. > ___ > 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
[PATCH] D39116: clang patch for -fno-var-tracking-assignments option
martemyev created this revision. martemyev added a project: clang. The patch adds a new option '-fno-var-tracking-assignments' in the same group (clang_ignored_f_Group) where the existing '-fno-var-tracking' resides. https://reviews.llvm.org/D39116 Files: include/clang/Driver/Options.td Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1515,6 +1515,7 @@ def fuse_init_array : Flag<["-"], "fuse-init-array">, Group, Flags<[CC1Option]>, HelpText<"Use .init_array instead of .ctors">; def fno_var_tracking : Flag<["-"], "fno-var-tracking">, Group; +def fno_var_tracking_assignments : Flag<["-"], "fno-var-tracking-assignments">, Group; def fverbose_asm : Flag<["-"], "fverbose-asm">, Group; def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group, HelpText<"Set the default symbol visibility for all global declarations">, Values<"hidden,default">; Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1515,6 +1515,7 @@ def fuse_init_array : Flag<["-"], "fuse-init-array">, Group, Flags<[CC1Option]>, HelpText<"Use .init_array instead of .ctors">; def fno_var_tracking : Flag<["-"], "fno-var-tracking">, Group; +def fno_var_tracking_assignments : Flag<["-"], "fno-var-tracking-assignments">, Group; def fverbose_asm : Flag<["-"], "fverbose-asm">, Group; def fvisibility_EQ : Joined<["-"], "fvisibility=">, Group, HelpText<"Set the default symbol visibility for all global declarations">, Values<"hidden,default">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37954: Try to shorten system header paths when using -MD depfiles
joerg added a comment. This is not about any operating system, but basic consistent behavior. either do the canonicalisation or not. Doing it sometimes is just bogus. You've effectively implemented -fcanonical-system-headers=sometimes. Repository: rL LLVM https://reviews.llvm.org/D37954 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true
xazax.hun added inline comments. Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:651-652 + } else if (StoreSite->getLocation().getAs()) { +os << "Reach the max loop limit."; +os << " Assigning a conjured symbol"; +if (R->canPrintPretty()) { zaks.anna wrote: > MTC wrote: > > NoQ wrote: > > > This is user-facing text, and users shouldn't know about conjured > > > symbols, and "max" shouldn't be shortened, and i'm not sure what else. > > > I'd probably suggest something along the lines of "Contents of <...> are > > > wiped", but this is still not good enough. > > > > > > Also could you add a test that displays this note? I.e. with > > > `-analyzer-output=text`. > > Thanks for your review. > > > > You are right, whether this information should be displayed to the user is > > a question worth discussing. > I am not convinced that we need to print this information to the user. The > problem here is that it leaks internal implementation details about the > analyzer. The users should not know about "loop limits" and "invalidation" > and most of the users would not even know what this means. I can see how this > is useful to the analyzer developers for debugging the analyzer, but not to > the end user. > While we might not want to expose this to the user this can be really useful to understand what the analyzer is doing when we debugging a false positive finding. Maybe it would be worth to introduce a developer mode or verbose mode for those purposes. What do you think? https://reviews.llvm.org/D37187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
hokein created this revision. Herald added a subscriber: klimek. https://reviews.llvm.org/D39120 Files: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp unittests/Rename/RenameFunctionTest.cpp Index: unittests/Rename/RenameFunctionTest.cpp === --- unittests/Rename/RenameFunctionTest.cpp +++ unittests/Rename/RenameFunctionTest.cpp @@ -220,6 +220,25 @@ CompareSnippets(Expected, After); } +TEST_F(RenameFunctionTest, RenameTemplateFunctions) { + std::string Before = R"( + namespace na { + template T X(); + } + namespace na { void f() { X(); } } + namespace nb { void g() { na::X(); } } + )"; + std::string Expected = R"( + namespace na { + template T Y(); + } + namespace na { void f() { nb::Y(); } } + namespace nb { void g() { Y(); } } + )"; + std::string After = runClangRenameOnCode(Before, "na::X", "nb::Y"); + CompareSnippets(Expected, After); +} + TEST_F(RenameFunctionTest, RenameOutOfLineFunctionDecls) { std::string Before = R"( namespace na { Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp === --- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp +++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp @@ -221,7 +221,12 @@ } auto StartLoc = Expr->getLocStart(); -auto EndLoc = Expr->getLocEnd(); +// For template function call expressions like `foo()`, we want to +// restrict the end of location to just before the `<` character. +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); + // In case of renaming an enum declaration, we have to explicitly handle // unscoped enum constants referenced in expressions (e.g. // "auto r = ns1::ns2::Green" where Green is an enum constant of an unscoped Index: unittests/Rename/RenameFunctionTest.cpp === --- unittests/Rename/RenameFunctionTest.cpp +++ unittests/Rename/RenameFunctionTest.cpp @@ -220,6 +220,25 @@ CompareSnippets(Expected, After); } +TEST_F(RenameFunctionTest, RenameTemplateFunctions) { + std::string Before = R"( + namespace na { + template T X(); + } + namespace na { void f() { X(); } } + namespace nb { void g() { na::X(); } } + )"; + std::string Expected = R"( + namespace na { + template T Y(); + } + namespace na { void f() { nb::Y(); } } + namespace nb { void g() { Y(); } } + )"; + std::string After = runClangRenameOnCode(Before, "na::X", "nb::Y"); + CompareSnippets(Expected, After); +} + TEST_F(RenameFunctionTest, RenameOutOfLineFunctionDecls) { std::string Before = R"( namespace na { Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp === --- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp +++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp @@ -221,7 +221,12 @@ } auto StartLoc = Expr->getLocStart(); -auto EndLoc = Expr->getLocEnd(); +// For template function call expressions like `foo()`, we want to +// restrict the end of location to just before the `<` character. +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); + // In case of renaming an enum declaration, we have to explicitly handle // unscoped enum constants referenced in expressions (e.g. // "auto r = ns1::ns2::Green" where Green is an enum constant of an unscoped ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
ioeric added inline comments. Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:227 +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); I wonder what would happen if we have `foo ()`? https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316211 - [CodeGen] Fix generation of TBAA info for array-to-pointer conversions
Author: kosarev Date: Fri Oct 20 05:35:17 2017 New Revision: 316211 URL: http://llvm.org/viewvc/llvm-project?rev=316211&view=rev Log: [CodeGen] Fix generation of TBAA info for array-to-pointer conversions Resolves: Fatal error: Offset not zero at the point of scalar access. http://llvm.org/PR34992 Differential Revision: https://reviews.llvm.org/D39083 Added: cfe/trunk/test/CodeGen/tbaa-array.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=316211&r1=316210&r2=316211&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Oct 20 05:35:17 2017 @@ -3072,8 +3072,6 @@ Address CodeGenFunction::EmitArrayToPoin // Expressions of array type can't be bitfields or vector elements. LValue LV = EmitLValue(E); Address Addr = LV.getAddress(); - if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); // If the array type was an incomplete type, we need to make sure // the decay ends up being the right type. @@ -3088,7 +3086,15 @@ Address CodeGenFunction::EmitArrayToPoin Addr = Builder.CreateStructGEP(Addr, 0, CharUnits::Zero(), "arraydecay"); } + // The result of this decay conversion points to an array element within the + // base lvalue. However, since TBAA currently does not support representing + // accesses to elements of member arrays, we conservatively represent accesses + // to the pointee object as if it had no any base lvalue specified. + // TODO: Support TBAA for member arrays. QualType EltType = E->getType()->castAsArrayTypeUnsafe()->getElementType(); + if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = CGM.getTBAAAccessInfo(EltType); + return Builder.CreateElementBitCast(Addr, ConvertTypeForMem(EltType)); } Added: cfe/trunk/test/CodeGen/tbaa-array.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-array.cpp?rev=316211&view=auto == --- cfe/trunk/test/CodeGen/tbaa-array.cpp (added) +++ cfe/trunk/test/CodeGen/tbaa-array.cpp Fri Oct 20 05:35:17 2017 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for accesses to array +// elements. + +struct A { int i; }; +struct B { A a[1]; }; + +int foo(B *b) { +// CHECK-LABEL: _Z3fooP1B +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] + return b->a->i; +} + +// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} +// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} +// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39083: [CodeGen] Fix generation of TBAA info for array-to-pointer conversions
This revision was automatically updated to reflect the committed changes. Closed by commit rL316211: [CodeGen] Fix generation of TBAA info for array-to-pointer conversions (authored by kosarev). Changed prior to commit: https://reviews.llvm.org/D39083?vs=119552&id=119646#toc Repository: rL LLVM https://reviews.llvm.org/D39083 Files: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/test/CodeGen/tbaa-array.cpp Index: cfe/trunk/test/CodeGen/tbaa-array.cpp === --- cfe/trunk/test/CodeGen/tbaa-array.cpp +++ cfe/trunk/test/CodeGen/tbaa-array.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for accesses to array +// elements. + +struct A { int i; }; +struct B { A a[1]; }; + +int foo(B *b) { +// CHECK-LABEL: _Z3fooP1B +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] + return b->a->i; +} + +// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} +// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} +// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -3072,8 +3072,6 @@ // Expressions of array type can't be bitfields or vector elements. LValue LV = EmitLValue(E); Address Addr = LV.getAddress(); - if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); // If the array type was an incomplete type, we need to make sure // the decay ends up being the right type. @@ -3088,7 +3086,15 @@ Addr = Builder.CreateStructGEP(Addr, 0, CharUnits::Zero(), "arraydecay"); } + // The result of this decay conversion points to an array element within the + // base lvalue. However, since TBAA currently does not support representing + // accesses to elements of member arrays, we conservatively represent accesses + // to the pointee object as if it had no any base lvalue specified. + // TODO: Support TBAA for member arrays. QualType EltType = E->getType()->castAsArrayTypeUnsafe()->getElementType(); + if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = CGM.getTBAAAccessInfo(EltType); + return Builder.CreateElementBitCast(Addr, ConvertTypeForMem(EltType)); } Index: cfe/trunk/test/CodeGen/tbaa-array.cpp === --- cfe/trunk/test/CodeGen/tbaa-array.cpp +++ cfe/trunk/test/CodeGen/tbaa-array.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for accesses to array +// elements. + +struct A { int i; }; +struct B { A a[1]; }; + +int foo(B *b) { +// CHECK-LABEL: _Z3fooP1B +// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_i:!.*]] + return b->a->i; +} + +// CHECK-DAG: [[TAG_A_i]] = !{[[TYPE_A:!.*]], [[TYPE_int:!.*]], i64 0} +// CHECK-DAG: [[TYPE_A]] = !{!"_ZTS1A", !{{.*}}, i64 0} +// CHECK-DAG: [[TYPE_int]] = !{!"int", !{{.*}}, i64 0} Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -3072,8 +3072,6 @@ // Expressions of array type can't be bitfields or vector elements. LValue LV = EmitLValue(E); Address Addr = LV.getAddress(); - if (BaseInfo) *BaseInfo = LV.getBaseInfo(); - if (TBAAInfo) *TBAAInfo = LV.getTBAAInfo(); // If the array type was an incomplete type, we need to make sure // the decay ends up being the right type. @@ -3088,7 +3086,15 @@ Addr = Builder.CreateStructGEP(Addr, 0, CharUnits::Zero(), "arraydecay"); } + // The result of this decay conversion points to an array element within the + // base lvalue. However, since TBAA currently does not support representing + // accesses to elements of member arrays, we conservatively represent accesses + // to the pointee object as if it had no any base lvalue specified. + // TODO: Support TBAA for member arrays. QualType EltType = E->getType()->castAsArrayTypeUnsafe()->getElementType(); + if (BaseInfo) *BaseInfo = LV.getBaseInfo(); + if (TBAAInfo) *TBAAInfo = CGM.getTBAAAccessInfo(EltType); + return Builder.CreateElementBitCast(Addr, ConvertTypeForMem(EltType)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316212 - [clang-refactor] Add "-Inplace" option to the commandline tool.
Author: hokein Date: Fri Oct 20 05:37:16 2017 New Revision: 316212 URL: http://llvm.org/viewvc/llvm-project?rev=316212&view=rev Log: [clang-refactor] Add "-Inplace" option to the commandline tool. Summary: Change clang-refactor default behavior to print the new code after refactoring (instead of editing the source files), which would make it easier to use and debug the refactoring action. Reviewers: arphaman, ioeric Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39092 Modified: cfe/trunk/test/Refactor/tool-apply-replacements.cpp cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Modified: cfe/trunk/test/Refactor/tool-apply-replacements.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/tool-apply-replacements.cpp?rev=316212&r1=316211&r2=316212&view=diff == --- cfe/trunk/test/Refactor/tool-apply-replacements.cpp (original) +++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp Fri Oct 20 05:37:16 2017 @@ -1,10 +1,8 @@ -// RUN: rm -f %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7-7:15 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -i -selection=%t.cpp:7:7 -new-name=test %t.cpp -- +// RUN: FileCheck -input-file=%t.cpp %s class RenameMe { // CHECK: class test { Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=316212&r1=316211&r2=316212&view=diff == --- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original) +++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Fri Oct 20 05:37:16 2017 @@ -40,6 +40,11 @@ static cl::OptionCategory CommonRefactor static cl::opt Verbose("v", cl::desc("Use verbose output"), cl::cat(cl::GeneralCategory), cl::sub(*cl::AllSubCommands)); + +static cl::opt Inplace("i", cl::desc("Inplace edit s"), + cl::cat(cl::GeneralCategory), + cl::sub(*cl::AllSubCommands)); + } // end namespace opts namespace { @@ -436,13 +441,18 @@ public: return true; } - std::error_code EC; - llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); - if (EC) { -llvm::errs() << EC.message() << "\n"; -return true; + if (opts::Inplace) { +std::error_code EC; +llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); +if (EC) { + llvm::errs() << EC.message() << "\n"; + return true; +} +OS << *Result; +continue; } - OS << *Result; + + llvm::outs() << *Result; } return false; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39083: [CodeGen] Fix generation of TBAA info for array-to-pointer conversions
kosarev added a comment. Thanks Hal. Repository: rL LLVM https://reviews.llvm.org/D39083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39092: [clang-refactor] Add "-Inplace" option to the commandline tool.
This revision was automatically updated to reflect the committed changes. Closed by commit rL316212: [clang-refactor] Add "-Inplace" option to the commandline tool. (authored by hokein). Repository: rL LLVM https://reviews.llvm.org/D39092 Files: cfe/trunk/test/Refactor/tool-apply-replacements.cpp cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Index: cfe/trunk/test/Refactor/tool-apply-replacements.cpp === --- cfe/trunk/test/Refactor/tool-apply-replacements.cpp +++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp @@ -1,10 +1,8 @@ -// RUN: rm -f %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7-7:15 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -i -selection=%t.cpp:7:7 -new-name=test %t.cpp -- +// RUN: FileCheck -input-file=%t.cpp %s class RenameMe { // CHECK: class test { Index: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp === --- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp +++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp @@ -40,6 +40,11 @@ static cl::opt Verbose("v", cl::desc("Use verbose output"), cl::cat(cl::GeneralCategory), cl::sub(*cl::AllSubCommands)); + +static cl::opt Inplace("i", cl::desc("Inplace edit s"), + cl::cat(cl::GeneralCategory), + cl::sub(*cl::AllSubCommands)); + } // end namespace opts namespace { @@ -436,13 +441,18 @@ return true; } - std::error_code EC; - llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); - if (EC) { -llvm::errs() << EC.message() << "\n"; -return true; + if (opts::Inplace) { +std::error_code EC; +llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); +if (EC) { + llvm::errs() << EC.message() << "\n"; + return true; +} +OS << *Result; +continue; } - OS << *Result; + + llvm::outs() << *Result; } return false; } Index: cfe/trunk/test/Refactor/tool-apply-replacements.cpp === --- cfe/trunk/test/Refactor/tool-apply-replacements.cpp +++ cfe/trunk/test/Refactor/tool-apply-replacements.cpp @@ -1,10 +1,8 @@ -// RUN: rm -f %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp -// RUN: cp %s %t.cp.cpp -// RUN: clang-refactor local-rename -selection=%t.cp.cpp:9:7-9:15 -new-name=test %t.cp.cpp -- -// RUN: grep -v CHECK %t.cp.cpp | FileCheck %t.cp.cpp +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -selection=%t.cpp:7:7-7:15 -new-name=test %t.cpp -- | FileCheck %s +// RUN: clang-refactor local-rename -i -selection=%t.cpp:7:7 -new-name=test %t.cpp -- +// RUN: FileCheck -input-file=%t.cpp %s class RenameMe { // CHECK: class test { Index: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp === --- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp +++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp @@ -40,6 +40,11 @@ static cl::opt Verbose("v", cl::desc("Use verbose output"), cl::cat(cl::GeneralCategory), cl::sub(*cl::AllSubCommands)); + +static cl::opt Inplace("i", cl::desc("Inplace edit s"), + cl::cat(cl::GeneralCategory), + cl::sub(*cl::AllSubCommands)); + } // end namespace opts namespace { @@ -436,13 +441,18 @@ return true; } - std::error_code EC; - llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); - if (EC) { -llvm::errs() << EC.message() << "\n"; -return true; + if (opts::Inplace) { +std::error_code EC; +llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text); +if (EC) { + llvm::errs() << EC.message() << "\n"; + return true; +} +OS << *Result; +continue; } - OS << *Result; + + llvm::outs() << *Result; } return false; } ___
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
baloghadamsoftware created this revision. Herald added subscribers: mgorny, srhines. A possible error is to write ``malloc(strlen(s+1))`` instead of ``malloc(strlen(s)+1)``. Unfortunately the former is also valid syntactically, but allocates less memory by two bytes (if ``s`` is at least one character long, undefined behavior otherwise) which may result in overflow cases. This check detects such cases and also suggests the fix for them. https://reviews.llvm.org/D39121 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.cpp clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst test/clang-tidy/misc-misplaced-operator-in-strlen-in-alloc.cpp Index: test/clang-tidy/misc-misplaced-operator-in-strlen-in-alloc.cpp === --- /dev/null +++ test/clang-tidy/misc-misplaced-operator-in-strlen-in-alloc.cpp @@ -0,0 +1,26 @@ +// RUN: %check_clang_tidy %s misc-misplaced-operator-in-strlen-in-alloc %t + +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void *calloc(size_t, size_t); +void *realloc(void *, size_t); + +size_t strlen(const char*); + +void bad_malloc(char *name) { + char *new_name = (char*) malloc(strlen(name + 1)); + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Binary operator + 1 is inside strlen + // CHECK-FIXES: {{^ char \*new_name = \(char\*\) malloc\(}}strlen(name) + 1{{\);$}} +} + +void bad_calloc(char *name) { + char *new_names = (char*) calloc(2, strlen(name + 1)); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: Binary operator + 1 is inside strlen + // CHECK-FIXES: {{^ char \*new_names = \(char\*\) calloc\(2, }}strlen(name) + 1{{\);$}} +} + +void bad_realloc(char * old_name, char *name) { + char *new_name = (char*) realloc(old_name, strlen(name + 1)); + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: Binary operator + 1 is inside strlen + // CHECK-FIXES: {{^ char \*new_name = \(char\*\) realloc\(old_name, }}strlen(name) + 1{{\);$}} +} Index: docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst === --- /dev/null +++ docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst @@ -0,0 +1,26 @@ +.. title:: clang-tidy - misc-misplaced-operator-in-strlen-in-alloc + +misc-misplaced-operator-in-strlen-in-alloc +== + +Finds cases a value is added to or subtracted from the string in the parameter +of ``strlen()`` method instead of to the result and use its return value as an +argument of a memory allocation function (``malloc()``, ``calloc()``, +``realloc()``). + +Example code: + +.. code-block:: c + +void bad_malloc(char *str) { + char *c = (char*) malloc(strlen(str + 1)); +} + + +The suggested fix is to add value to the return value of ``strlen()`` and not +to its argument. In the example above the fix would be + +.. code-block:: c + + char *c = (char*) malloc(strlen(str) + 1); + Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -7,9 +7,9 @@ android-cloexec-accept android-cloexec-accept4 android-cloexec-creat + android-cloexec-dup android-cloexec-epoll-create android-cloexec-epoll-create1 - android-cloexec-dup android-cloexec-fopen android-cloexec-inotify-init android-cloexec-inotify-init1 @@ -38,7 +38,7 @@ cert-msc30-c (redirects to cert-msc50-cpp) cert-msc50-cpp cert-oop11-cpp (redirects to misc-move-constructor-init) - cppcoreguidelines-c-copy-assignment-signature + cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) cppcoreguidelines-interfaces-global-init cppcoreguidelines-no-malloc cppcoreguidelines-owning-memory @@ -76,8 +76,8 @@ hicpp-explicit-conversions (redirects to google-explicit-constructor) hicpp-function-size (redirects to readability-function-size) hicpp-invalid-access-moved (redirects to misc-use-after-move) - hicpp-move-const-arg (redirects to misc-move-const-arg) hicpp-member-init (redirects to cppcoreguidelines-pro-type-member-init) + hicpp-move-const-arg (redirects to misc-move-const-arg) hicpp-named-parameter (redirects to readability-named-parameter) hicpp-new-delete-operators (redirects to misc-new-delete-overloads) hicpp-no-array-decay (redirects to cppcoreguidelines-pro-bounds-array-to-pointer-decay) @@ -95,7 +95,7 @@ hicpp-use-noexcept (redirects to modernize-use-noexcept) hicpp-use-nullptr (redirects to modernize-use-nullptr) hicpp-use-override (redirects to modernize-use-override) - hicpp-vararg (redirects to cppcoreguidelines-pro-type-
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
hokein added inline comments. Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:227 +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); ioeric wrote: > I wonder what would happen if we have `foo ()`? There will be a blank left like `bar ();` if we don't format the apply replacement, but I don't think this case really matters because we often format the placements before applying them. https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
ioeric added inline comments. Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:227 +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); hokein wrote: > ioeric wrote: > > I wonder what would happen if we have `foo ()`? > There will be a blank left like `bar ();` if we don't format the apply > replacement, but I don't think this case really matters because we often > format the placements before applying them. Could you add a test for this? Thanks! https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39122: [Sema] Fixes for enum handling for tautological comparison diagnostics
lebedev.ri created this revision. lebedev.ri added a project: clang. As Mattias Eriksson has reported in PR35009, in C, for enums, the underlying type should be used when checking for the tautological comparison, unlike C++, where the enumerator values define the value range. So if not in CPlusPlus mode, use the enum underlying type. Also, i have discovered a problem (a crash) when evaluating tautological-ness of the following comparison: enum A { A_a = 0 }; if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; This affects both the C and C++, but after the first fix, only C++ code was affected. That was also fixed, while preserving (i think?) the proper diagnostic output. And while there, attempt to enhance the test coverage. Yes, some tests got moved around, sorry about that :) Fixes PR35009 Repository: rL LLVM https://reviews.llvm.org/D39122 Files: lib/Sema/SemaChecking.cpp test/Sema/outof-range-enum-constant-compare.c test/Sema/tautological-constant-enum-compare.c test/Sema/tautological-unsigned-enum-zero-compare.c test/Sema/tautological-unsigned-enum-zero-compare.cpp Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp === --- test/Sema/tautological-unsigned-enum-zero-compare.cpp +++ test/Sema/tautological-unsigned-enum-zero-compare.cpp @@ -7,169 +7,321 @@ // On windows, it is signed by default. We do not want to warn in that case. int main() { - enum A { A_foo, A_bar }; + enum A { A_foo = 0 }; enum A a; - enum B : unsigned { B_foo, B_bar }; + enum B : unsigned { B_foo = 0 }; enum B b; - enum C : signed { c_foo, c_bar }; + enum C : signed { C_foo = 0 }; enum C c; #ifdef ALL_WARN if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0 >= a) +return 0; + if (a > 0) return 0; if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (a <= 0) +return 0; if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; + if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0 < a) +return 0; + if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0U >= a) +return 0; + if (a > 0U) return 0; if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (a <= 0U) +return 0; if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; + if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0U < a) +return 0; if (b < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (b >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0 >= b) +return 0; + if (b > 0) return 0; if (0 <= b) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (b <= 0) +return 0; if (0 > b) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; - if (b < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; - if (b >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} -return 0; - if (0U <= b) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} -return 0; - if (0U > b) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} -return 0; - - if (c < 0) // ok -return 0; - if (c >= 0) // ok -return 0; - if (0 <= c) // ok -return 0; - if (0 > c) // ok -return 0; - if (c < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; - if (c >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} -return 0; - if (0U <= c) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} -return 0; - if (0U > c) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} -return 0; -#elif defined(SIGN_WARN) - if (a < 0) // ok -return 0; - if (a >= 0) // ok -return 0; - if (0 <= a) // ok -return 0; - if (0 > a) // ok -return 0; - if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; -
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
hokein updated this revision to Diff 119654. hokein marked an inline comment as done. hokein added a comment. Test for `foo ()`. https://reviews.llvm.org/D39120 Files: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp unittests/Rename/RenameFunctionTest.cpp Index: unittests/Rename/RenameFunctionTest.cpp === --- unittests/Rename/RenameFunctionTest.cpp +++ unittests/Rename/RenameFunctionTest.cpp @@ -220,6 +220,25 @@ CompareSnippets(Expected, After); } +TEST_F(RenameFunctionTest, RenameTemplateFunctions) { + std::string Before = R"( + namespace na { + template T X(); + } + namespace na { void f() { X(); } } + namespace nb { void g() { na::X (); } } + )"; + std::string Expected = R"( + namespace na { + template T Y(); + } + namespace na { void f() { nb::Y(); } } + namespace nb { void g() { Y(); } } + )"; + std::string After = runClangRenameOnCode(Before, "na::X", "nb::Y"); + CompareSnippets(Expected, After); +} + TEST_F(RenameFunctionTest, RenameOutOfLineFunctionDecls) { std::string Before = R"( namespace na { Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp === --- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp +++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp @@ -221,7 +221,12 @@ } auto StartLoc = Expr->getLocStart(); -auto EndLoc = Expr->getLocEnd(); +// For template function call expressions like `foo()`, we want to +// restrict the end of location to just before the `<` character. +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); + // In case of renaming an enum declaration, we have to explicitly handle // unscoped enum constants referenced in expressions (e.g. // "auto r = ns1::ns2::Green" where Green is an enum constant of an unscoped Index: unittests/Rename/RenameFunctionTest.cpp === --- unittests/Rename/RenameFunctionTest.cpp +++ unittests/Rename/RenameFunctionTest.cpp @@ -220,6 +220,25 @@ CompareSnippets(Expected, After); } +TEST_F(RenameFunctionTest, RenameTemplateFunctions) { + std::string Before = R"( + namespace na { + template T X(); + } + namespace na { void f() { X(); } } + namespace nb { void g() { na::X (); } } + )"; + std::string Expected = R"( + namespace na { + template T Y(); + } + namespace na { void f() { nb::Y(); } } + namespace nb { void g() { Y(); } } + )"; + std::string After = runClangRenameOnCode(Before, "na::X", "nb::Y"); + CompareSnippets(Expected, After); +} + TEST_F(RenameFunctionTest, RenameOutOfLineFunctionDecls) { std::string Before = R"( namespace na { Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp === --- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp +++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp @@ -221,7 +221,12 @@ } auto StartLoc = Expr->getLocStart(); -auto EndLoc = Expr->getLocEnd(); +// For template function call expressions like `foo()`, we want to +// restrict the end of location to just before the `<` character. +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); + // In case of renaming an enum declaration, we have to explicitly handle // unscoped enum constants referenced in expressions (e.g. // "auto r = ns1::ns2::Green" where Green is an enum constant of an unscoped ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
hokein added inline comments. Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:227 +SourceLocation EndLoc = Expr->hasExplicitTemplateArgs() +? Expr->getLAngleLoc().getLocWithOffset(-1) +: Expr->getLocEnd(); ioeric wrote: > hokein wrote: > > ioeric wrote: > > > I wonder what would happen if we have `foo ()`? > > There will be a blank left like `bar ();` if we don't format the apply > > replacement, but I don't think this case really matters because we often > > format the placements before applying them. > Could you add a test for this? Thanks! Done, but note that our unittest will format the expected/actual code before doing verification. https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
martong added a comment. Consider the use of a function pointer: void* malloc(int); int strlen(char*); auto fp = malloc; void bad_malloc(char *str) { char *c = (char *)fp(strlen(str + 1)); } I think, the checker will not match in this case. One might use allocation functions via a function pointer in case of more possible allocation strategies (e.g having a different strategy for a shared memory allocation). https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
hintonda added a comment. In https://reviews.llvm.org/D36347#901885, @zturner wrote: > One possible reason for why this never got any traction is that > `lldb-commits` wasn't added as a subscriber. While it's true that the tagged > people should have chimed in, having the whole commits list will get some > more visibility. I never saw this come to my inbox. > > I think this would be most suitable in the `lldb/examples` folder. > > I can't really review this thoroughly, because it relies on a bash script, > and I use Windows where we bash isn't really a thing. My bash is rusty, but > it looks like you're embedding a python script in the bash script? It might > be good if this were just an lldb script command. Take a look at `command > script add` in LLDB, and in the `examples` folder for some examples of > existing commands that work this way. The nice thing about doing it this way > is that you could just be inside LLDB and write `(lldb) break-diag > -Wcovered-switch`, for example, which would be a much tighter integration > with the debugger. Thanks for taking a look. I mainly work on *nix systems, hence the initial shell script, but if there's an interest, I'll be happy to convert it to a single python script as you suggest, and resubmit it as a patch to lldb. Thanks again... https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
xazax.hun added inline comments. Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.cpp:30 + Finder->addMatcher( + callExpr(callee(functionDecl(hasName("malloc"))), + hasArgument(0, anyOf(hasDescendant(BadUse), BadUse))) Maybe it is worth to have a configurable list of allocation functions? Maybe it would be worth to support`alloca` as well? Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.cpp:44 +const MatchFinder::MatchResult &Result) { + // FIXME: Add callback implementation. + const auto *Alloc = Result.Nodes.getNodeAs("Alloc"); What is this fixme? Comment at: clang-tidy/misc/MisplacedOperatorInStrlenInAllocCheck.h:19 + +/// FIXME: Write a short description. +/// There is a missing description. Comment at: docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst:16 +void bad_malloc(char *str) { + char *c = (char*) malloc(strlen(str + 1)); +} What if this code is intentional for some reason? I think in thase case it could be rewritten like the following (which is much cleaner): ``` char *c = (char*) malloc(strlen(str)-1); ``` I think it might be a good idea to mention this possibility as a way to suppress this warning in the documentation. https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
martong added a comment. We might get false positives in case of certain substring operations. Consider the case of copying a substring, pseudo code below: const char * s = "abcdefg"; int offset = my_find('d', s); // I want to copy "defg" char *new_subststring = (char*) malloc(strlen(s + offset)); strcpy(...); https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39120: [rename] Don't overwrite the template argument when renaming a template function.
cierpuchaw added inline comments. Comment at: unittests/Rename/RenameFunctionTest.cpp:232 + std::string Expected = R"( + namespace na { + template T Y(); Shouldn't this be `namespace nb {`? https://reviews.llvm.org/D39120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33537: [clang-tidy] Exception Escape Checker
xazax.hun added a comment. I agree that we should not spend too much effort on making warnings from the compiler and tidy disjunct. https://reviews.llvm.org/D33537 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
+jingham On Fri, Oct 20, 2017 at 6:57 AM Don Hinton via Phabricator < revi...@reviews.llvm.org> wrote: > hintonda added a comment. > > In https://reviews.llvm.org/D36347#901885, @zturner wrote: > > > One possible reason for why this never got any traction is that > `lldb-commits` wasn't added as a subscriber. While it's true that the > tagged people should have chimed in, having the whole commits list will get > some more visibility. I never saw this come to my inbox. > > > > I think this would be most suitable in the `lldb/examples` folder. > > > > I can't really review this thoroughly, because it relies on a bash > script, and I use Windows where we bash isn't really a thing. My bash is > rusty, but it looks like you're embedding a python script in the bash > script? It might be good if this were just an lldb script command. Take a > look at `command script add` in LLDB, and in the `examples` folder for some > examples of existing commands that work this way. The nice thing about > doing it this way is that you could just be inside LLDB and write `(lldb) > break-diag -Wcovered-switch`, for example, which would be a much tighter > integration with the debugger. > > > Thanks for taking a look. > > I mainly work on *nix systems, hence the initial shell script, but if > there's an interest, I'll be happy to convert it to a single python script > as you suggest, and resubmit it as a patch to lldb. > > Thanks again... > > > https://reviews.llvm.org/D36347 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
aaron.ballman added inline comments. Comment at: docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst:16 +void bad_malloc(char *str) { + char *c = (char*) malloc(strlen(str + 1)); +} xazax.hun wrote: > What if this code is intentional for some reason? > I think in thase case it could be rewritten like the following (which is much > cleaner): > ``` > char *c = (char*) malloc(strlen(str)-1); > ``` > I think it might be a good idea to mention this possibility as a way to > suppress this warning in the documentation. This is my concern as well -- I'd like to know how chatty this diagnostic is on real-world code bases, especially ones that rely on C rather than C++. A somewhat common code pattern in Win32 coding are double-null-terminated lists of strings, where you have null terminated strings at adjacent memory locations with two null characters for the end of the list. This could result in reasonable code like `malloc(strlen(str + offset) + 1)`. https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
Eugene.Zelenko added a comment. Same mistake could be made with new[] operator. Comment at: docs/clang-tidy/checks/list.rst:10 android-cloexec-creat + android-cloexec-dup android-cloexec-epoll-create I think will be better to fix order of other checks separately from this check. Comment at: docs/clang-tidy/checks/misc-misplaced-operator-in-strlen-in-alloc.rst:7 +Finds cases a value is added to or subtracted from the string in the parameter +of ``strlen()`` method instead of to the result and use its return value as an +argument of a memory allocation function (``malloc()``, ``calloc()``, strlen() is function, not method. https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
clayborg added a comment. Please do convert to python. Just know that you can use "lldb -P" to get the python path that is needed in order to do "import lldb" in the python script. So you can try doing a "import lldb", and if that fails, catch the exception, run "lldb -P", add that path to the python path: try: # Just try for LLDB in case the lldb module is already in the python search # paths import lldb except ImportError: # We failed to import lldb automatically. Run lldb with the -P option so # it tells us the python path we should use. lldb_py_dirs = list() (status, output) = commands.getstatusoutput("lldb -P") dir = os.path.realpath(output) if status == 0 and os.path.isdir(dir): lldb_py_dirs.append(dir) success = False for lldb_py_dir in lldb_py_dirs: if os.path.exists(lldb_py_dir): if not (sys.path.__contains__(lldb_py_dir)): sys.path.append(lldb_py_dir) try: import lldb except ImportError: pass else: success = True break if not success: print("error: couldn't locate the 'lldb' module, please set " "PYTHONPATH correctly") sys.exit(1) https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37299: [Modules] Add ability to specify module name to module file mapping in a file
boris added a comment. Ping. https://reviews.llvm.org/D37299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37187: [Analyzer] Fix Bug 25609 - Assertion UNREACHABLE: 'Unexpected ProgramPoint' with widen-loops=true
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:651-652 + } else if (StoreSite->getLocation().getAs()) { +os << "Reach the max loop limit."; +os << " Assigning a conjured symbol"; +if (R->canPrintPretty()) { xazax.hun wrote: > zaks.anna wrote: > > MTC wrote: > > > NoQ wrote: > > > > This is user-facing text, and users shouldn't know about conjured > > > > symbols, and "max" shouldn't be shortened, and i'm not sure what else. > > > > I'd probably suggest something along the lines of "Contents of <...> > > > > are wiped", but this is still not good enough. > > > > > > > > Also could you add a test that displays this note? I.e. with > > > > `-analyzer-output=text`. > > > Thanks for your review. > > > > > > You are right, whether this information should be displayed to the user > > > is a question worth discussing. > > I am not convinced that we need to print this information to the user. The > > problem here is that it leaks internal implementation details about the > > analyzer. The users should not know about "loop limits" and "invalidation" > > and most of the users would not even know what this means. I can see how > > this is useful to the analyzer developers for debugging the analyzer, but > > not to the end user. > > > While we might not want to expose this to the user this can be really useful > to understand what the analyzer is doing when we debugging a false positive > finding. Maybe it would be worth to introduce a developer mode or verbose > mode for those purposes. What do you think? I'd be fine with that in theory, though the downside is that it would pollute the code a bit. One trick that's often used to better understand a report when debugging is to remove the path note pruning (by passing a flag). I am not sure if that approach can be extended for this case. Ex: maybe we could have special markers on the notes saying that they are for debug purposes only and have the pruning remove them. By the way, is this change related to the other change from this patch? https://reviews.llvm.org/D37187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
zturner added a comment. In https://reviews.llvm.org/D36347#902157, @clayborg wrote: > Please do convert to python. Just know that you can use "lldb -P" to get the > python path that is needed in order to do "import lldb" in the python script. > So you can try doing a "import lldb", and if that fails, catch the exception, > run "lldb -P", add that path to the python path: > > try: > # Just try for LLDB in case the lldb module is already in the python > search > # paths > import lldb > except ImportError: > # We failed to import lldb automatically. Run lldb with the -P option so > # it tells us the python path we should use. > lldb_py_dirs = list() > (status, output) = commands.getstatusoutput("lldb -P") > dir = os.path.realpath(output) > if status == 0 and os.path.isdir(dir): > lldb_py_dirs.append(dir) > success = False > for lldb_py_dir in lldb_py_dirs: > if os.path.exists(lldb_py_dir): > if not (sys.path.__contains__(lldb_py_dir)): > sys.path.append(lldb_py_dir) > try: > import lldb > except ImportError: > pass > else: > success = True > break > if not success: > print("error: couldn't locate the 'lldb' module, please set " > "PYTHONPATH correctly") > sys.exit(1) > > Is any of this really necessary? If you load this script via `command script add` (which is definitely better than having this be a post-processing script that someone has to manually run) then it is guaranteed to be in the path. Just import it, like the other examples in `lldb/examples/python/jump.py` for an example. The idea is to have it do the indexing when the command is loaded and save it to a global, and then each time it runs it uses the global index. This way it's invisible to the user, you just run `bcd -Wcovered-switch` or something without worrying about it. https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
clayborg added a comment. If you want to run the script from the command line, then it is necessary. If it is run from within LLDB it will just work. I like to have my LLDB python scripts work both ways. This might be better implemented as a new command that gets installed and can be used within LLDB. See: http://llvm.org/svn/llvm-project/lldb/trunk/examples/python/cmdtemplate.py https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
jingham added a comment. I can't see anything wrong with the SB API use here. I don't feel qualified to comment on the most effective workflow for an analysis I've never had to do, however. https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33537: [clang-tidy] Exception Escape Checker
JonasToth added a comment. > I agree that we should not spend too much effort on making warnings from the > compiler and tidy disjunct. +1 There is an effort to treat clangs frontend warnings similar to clang-tidy checks within clang-tidy. This would allow to manage the overlap as well. Will this check find stuff like this (or is it part of the frontend) int throwing() { throw int(42); } int not_throwing() noexcept { throwing(); } It would be nice to have a check that could automatically introduce `noexcept` into a codebase for cases it safe. I think this path would be a good place for it. https://reviews.llvm.org/D33537 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38986: [Analyzer] Better unreachable message in enumeration
dcoughlin added a comment. What is the workflow where this is needed? Is it when an end-user is running a build with assertions and can't provide a reproducer but can provide the console output? Does llvm_unreachable() guarantee that the string construction code is completely removed from release builds? https://reviews.llvm.org/D38986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39035: Unnamed bitfields don't block constant evaluation of constexpr constructors
jordan_rose added a comment. Thanks, Aaron! Comment at: test/SemaCXX/warn-global-constructors.cpp:130 + +namespace HasUnnamedBitfield { + struct HasUnnamedBitfield { aaron.ballman wrote: > Does this namespace require a name? If so, can it be named different than the > struct declared within it? I'm just trying to keep from having my test cases collide with the rest of the file and any future additions. I'll change it. (There's no PR or Radar for this at the moment; I just came across it while working on something else.) Repository: rL LLVM https://reviews.llvm.org/D39035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38922: [analyzer] LoopUnrolling: check the bitwidth of the used numbers (pr34943)
dcoughlin accepted this revision. dcoughlin added a comment. Thanks for fixing this! https://reviews.llvm.org/D38922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r316221 - [clang-tidy] Add missing test files in r316090.
Author: hokein Date: Fri Oct 20 10:54:53 2017 New Revision: 316221 URL: http://llvm.org/viewvc/llvm-project?rev=316221&view=rev Log: [clang-tidy] Add missing test files in r316090. Added: clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m Added: clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m?rev=316221&view=auto == --- clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m (added) +++ clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m Fri Oct 20 10:54:53 2017 @@ -0,0 +1,21 @@ +// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t + +// This test checks if Objective-C 2.0 (@properties) and +// Automatic Reference Counting (ARC) are enabled for .m files +// checked via check_clang_tidy.py. + +#if !__has_feature(objc_arc) +#error Objective-C ARC not enabled as expected +#endif + +@interface Foo +@property (nonatomic, assign) int shouldDoStuff; +- (void)nop; +@end + +void fail(Foo *f) +{ + if(f.shouldDoStuff); [f nop]; + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-FIXES: if(f.shouldDoStuff) [f nop]; +} Added: clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m?rev=316221&view=auto == --- clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m (added) +++ clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m Fri Oct 20 10:54:53 2017 @@ -0,0 +1,29 @@ +// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1 + +// This test ensures check_clang_tidy.py allows disabling Objective-C ARC and +// Objective-C 2.0 via passing arguments after -- on the command line. +// +// (We could include a test which doesn't pass any arguments after -- +// to check if ARC and ObjC 2.0 are disabled by default, but that test +// could change behavior based on the default Objective-C runtime for +// the platform, which would make this test flaky.) + +#if __has_feature(objc_arc) +#error Objective-C ARC unexpectedly enabled even with -fno-objc-arc +#endif + +#ifdef __OBJC2__ +#error Objective-C 2.0 unexpectedly enabled even with -fobjc-abi-version=1 +#endif + +@interface Foo +- (int)shouldDoStuff; +- (void)nop; +@end + +void fail(Foo *f) +{ + if([f shouldDoStuff]); [f nop]; + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [misc-suspicious-semicolon] + // CHECK-FIXES: if([f shouldDoStuff]) [f nop]; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39129: [OpenCL] Fix generation of constant address space sampler in function scope
Anastasia created this revision. After the change of constant address space function scope variable in 6e34f0e ("[OpenCL] Emit function-scope variable in constant address space as static variable", 2017-05-15) a bug has been introduced that triggered unreachable during generation of samplers. This is because sampler in global scope has not to be generated. The initialization function has to be used instead of a variable everywhere the sampler variable is being referenced. This patch fixes the bug and adds missing test case. https://reviews.llvm.org/D39129 Files: lib/CodeGen/CGDecl.cpp test/CodeGenOpenCL/sampler.cl Index: test/CodeGenOpenCL/sampler.cl === --- test/CodeGenOpenCL/sampler.cl +++ test/CodeGenOpenCL/sampler.cl @@ -33,6 +33,10 @@ // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) // CHECK: store %opencl.sampler_t addrspace(2)* [[SAMP]], %opencl.sampler_t addrspace(2)** [[smp_ptr]] + // Initialising constant AS sampler will be handled as global (we won't generate local alloca for it) + // CHECK-NOT: alloca %opencl.sampler_t addrspace(2)* + constant sampler_t smp_const_as = 11; + // Case 1b fnc4smp(smp); // CHECK-NOT: call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) @@ -58,4 +62,8 @@ fnc4smp(5); // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + fnc4smp(smp_const_as); + // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 11) + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) } Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -158,6 +158,13 @@ // Don't emit it now, allow it to be emitted lazily on its first use. return; + // Samplers in constant address space are handled as a special case + // unlike other variables they are not generated as globals + // and their initialiser will be used everywhere it is being referenced. + if (D.getType().getAddressSpace() == LangAS::opencl_constant && + D.getType().getTypePtr()->isSamplerT()) + return; + // Some function-scope variable does not have static storage but still // needs to be emitted like a static variable, e.g. a function-scope // variable in constant address space in OpenCL. Index: test/CodeGenOpenCL/sampler.cl === --- test/CodeGenOpenCL/sampler.cl +++ test/CodeGenOpenCL/sampler.cl @@ -33,6 +33,10 @@ // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) // CHECK: store %opencl.sampler_t addrspace(2)* [[SAMP]], %opencl.sampler_t addrspace(2)** [[smp_ptr]] + // Initialising constant AS sampler will be handled as global (we won't generate local alloca for it) + // CHECK-NOT: alloca %opencl.sampler_t addrspace(2)* + constant sampler_t smp_const_as = 11; + // Case 1b fnc4smp(smp); // CHECK-NOT: call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 19) @@ -58,4 +62,8 @@ fnc4smp(5); // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + fnc4smp(smp_const_as); + // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 11) + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) } Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -158,6 +158,13 @@ // Don't emit it now, allow it to be emitted lazily on its first use. return; + // Samplers in constant address space are handled as a special case + // unlike other variables they are not generated as globals + // and their initialiser will be used everywhere it is being referenced. + if (D.getType().getAddressSpace() == LangAS::opencl_constant && + D.getType().getTypePtr()->isSamplerT()) + return; + // Some function-scope variable does not have static storage but still // needs to be emitted like a static variable, e.g. a function-scope // variable in constant address space in OpenCL. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39031: [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once
dcoughlin accepted this revision. dcoughlin added a comment. This revision is now accepted and ready to land. Some nits inline, but looks good to me! Comment at: lib/Analysis/BodyFarm.cpp:388 + // reference. + for (unsigned int i = 2; i < D->getNumParams(); i++) { + Nit: 'i' doesn't match the naming conventions and it is not particularly descriptive. Perhaps "ParamIndex"? Comment at: lib/Analysis/BodyFarm.cpp:391 +const ParmVarDecl *PDecl = D->getParamDecl(i); +QualType PTy = PDecl->getType().getNonReferenceType(); +Expr *ParamExpr = M.makeDeclRefExpr(PDecl); Nit: You can move PTy inside the if block so it is not calculated when it is not needed. https://reviews.llvm.org/D39031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r316224 - GNU: do not read the FDE count if omitted
Author: compnerd Date: Fri Oct 20 11:47:35 2017 New Revision: 316224 URL: http://llvm.org/viewvc/llvm-project?rev=316224&view=rev Log: GNU: do not read the FDE count if omitted If there is no binary search table computed, the FDECount encoding is DW_EH_PE_omit. Do not attempt to read the FDECount in such a situation as we will read an incorrect value. binutils only writes out the FDECount if the encoding is not DW_EH_PE_omit. Modified: libunwind/trunk/src/EHHeaderParser.hpp Modified: libunwind/trunk/src/EHHeaderParser.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/EHHeaderParser.hpp?rev=316224&r1=316223&r2=316224&view=diff == --- libunwind/trunk/src/EHHeaderParser.hpp (original) +++ libunwind/trunk/src/EHHeaderParser.hpp Fri Oct 20 11:47:35 2017 @@ -67,7 +67,9 @@ void EHHeaderParser::decodeEHHdr(A &a ehHdrInfo.eh_frame_ptr = addressSpace.getEncodedP(p, ehHdrEnd, eh_frame_ptr_enc, ehHdrStart); ehHdrInfo.fde_count = - addressSpace.getEncodedP(p, ehHdrEnd, fde_count_enc, ehHdrStart); + fde_count_enc == DW_EH_PE_omit + ? 0 + : addressSpace.getEncodedP(p, ehHdrEnd, fde_count_enc, ehHdrStart); ehHdrInfo.table = p; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r316046 - Basic: fix __{,U}INTPTR_TYPE__ on ARM
On 10/17/2017 5:00 PM, Saleem Abdulrasool via cfe-commits wrote: Author: compnerd Date: Tue Oct 17 17:00:50 2017 New Revision: 316046 URL: http://llvm.org/viewvc/llvm-project?rev=316046&view=rev Log: Basic: fix __{,U}INTPTR_TYPE__ on ARM Darwin and OpenBSD are the only platforms which use `long int` for `__INTPTR_TYPE__`. The other platforms use `int` in 32-bit, and `long int` on 64-bit (except for VMS and Windows which are LLP64). Adjust the type definitions to match the platform definitions. We now generate the same definition as GCC on all the targets. Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp cfe/trunk/test/Preprocessor/init.c cfe/trunk/test/Preprocessor/stdint.c Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=316046&r1=316045&r2=316046&view=diff == --- cfe/trunk/lib/Basic/Targets/ARM.cpp (original) +++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Oct 17 17:00:50 2017 @@ -236,6 +236,10 @@ ARMTargetInfo::ARMTargetInfo(const llvm: break; } + IntPtrType = (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD) + ? SignedLong + : SignedInt; + // Cache arch related info. setArchInfo(); @@ -923,7 +927,6 @@ WindowsARMTargetInfo::WindowsARMTargetIn const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts), Triple(Triple) { SizeType = UnsignedInt; - IntPtrType = SignedInt; } Generally, PtrDiffType, IntPtrType, and SizeType are all the same (ignoring signedness). Please change the code to set all of these together. With the code scattered like this, it isn't obvious your changes are consistent. (Actually, I'm pretty sure they aren't consistent.) Also, in the future, please don't commit any change which affects ABI definitions without pre-commit review; this is a tricky area, even if a change seems simple. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38549: [clang-tidy] Link targets and Asm parsers
zturner updated this revision to Diff 119677. zturner added a comment. Added a test. Alex, if you can confirm this test gives sufficient coverage I can go ahead and submit today. Thanks! https://reviews.llvm.org/D38549 Files: clang-tools-extra/clang-tidy/CMakeLists.txt clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp Index: clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp === --- clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp +++ clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp @@ -9,4 +9,9 @@ void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } } Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp === --- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -18,6 +18,7 @@ #include "../ClangTidy.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TargetSelect.h" using namespace clang::ast_matchers; using namespace clang::driver; @@ -403,6 +404,10 @@ ProfileData Profile; + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + ClangTidyContext Context(std::move(OwningOptionsProvider)); runClangTidy(Context, OptionsParser.getCompilations(), PathList, EnableCheckProfile ? &Profile : nullptr); Index: clang-tools-extra/clang-tidy/CMakeLists.txt === --- clang-tools-extra/clang-tidy/CMakeLists.txt +++ clang-tools-extra/clang-tidy/CMakeLists.txt @@ -1,4 +1,6 @@ set(LLVM_LINK_COMPONENTS + AllTargetsAsmParsers + AllTargetsInfos Support ) Index: clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp === --- clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp +++ clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp @@ -9,4 +9,9 @@ void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } } Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp === --- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -18,6 +18,7 @@ #include "../ClangTidy.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TargetSelect.h" using namespace clang::ast_matchers; using namespace clang::driver; @@ -403,6 +404,10 @@ ProfileData Profile; + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + ClangTidyContext Context(std::move(OwningOptionsProvider)); runClangTidy(Context, OptionsParser.getCompilations(), PathList, EnableCheckProfile ? &Profile : nullptr); Index: clang-tools-extra/clang-tidy/CMakeLists.txt === --- clang-tools-extra/clang-tidy/CMakeLists.txt +++ clang-tools-extra/clang-tidy/CMakeLists.txt @@ -1,4 +1,6 @@ set(LLVM_LINK_COMPONENTS + AllTargetsAsmParsers + AllTargetsInfos Support ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39122: [Sema] Fixes for enum handling for tautological comparison diagnostics
efriedma added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8612 +OtherT = OtherT->getAs()->getDecl()->getIntegerType(); + } + Why are you changing this here, as opposed to changing IntRange::forValueOfCanonicalType? Repository: rL LLVM https://reviews.llvm.org/D39122 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39133: [Sema] Better fix for tags defined inside an enumeration (PR28903).
vsapsai created this revision. When we encounter an opening parenthesis and parse the rest as type cast, use DeclSpecContext DSC_type_specifier so we hit the existing check that prevents defining tags in contexts where type specifier is expected. This reverts implementation done in r313386, r313894, and keeps the tests. rdar://problem/28530809 https://reviews.llvm.org/D39133 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Parse/ParseExpr.cpp clang/lib/Sema/SemaDecl.cpp clang/test/CXX/drs/dr5xx.cpp clang/test/SemaCXX/enum.cpp Index: clang/test/SemaCXX/enum.cpp === --- clang/test/SemaCXX/enum.cpp +++ clang/test/SemaCXX/enum.cpp @@ -114,7 +114,7 @@ // PR28903 struct PR28903 { enum { -PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in an enumeration}} +PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in a type specifier}} PR28903_B, PR28903_C = PR28903_B }) Index: clang/test/CXX/drs/dr5xx.cpp === --- clang/test/CXX/drs/dr5xx.cpp +++ clang/test/CXX/drs/dr5xx.cpp @@ -424,7 +424,7 @@ while (const n = 0) {} // expected-error {{requires a type specifier}} for (const n = 0; // expected-error {{requires a type specifier}} const m = 0; ) {} // expected-error {{requires a type specifier}} - sizeof(const); // expected-error {{requires a type specifier}} + sizeof(const); // expected-error {{expected a type}} struct S { const n; // expected-error {{requires a type specifier}} operator const(); // expected-error {{expected a type}} Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14012,13 +14012,6 @@ Invalid = true; } - if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition && - DC->getDeclKind() == Decl::Enum) { -Diag(New->getLocation(), diag::err_type_defined_in_enum) - << Context.getTagDeclType(New); -Invalid = true; - } - // Maybe add qualifier info. if (SS.isNotEmpty()) { if (SS.isSet()) { Index: clang/lib/Parse/ParseExpr.cpp === --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -2373,7 +2373,7 @@ // Parse the type declarator. DeclSpec DS(AttrFactory); -ParseSpecifierQualifierList(DS); +ParseSpecifierQualifierList(DS, AS_none, DSC_type_specifier); Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); ParseDeclarator(DeclaratorInfo); Index: clang/include/clang/Basic/DiagnosticSemaKinds.td === --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1349,8 +1349,6 @@ "%0 cannot be defined in a type alias template">; def err_type_defined_in_condition : Error< "%0 cannot be defined in a condition">; -def err_type_defined_in_enum : Error< - "%0 cannot be defined in an enumeration">; def note_pure_virtual_function : Note< "unimplemented pure virtual method %0 in %1">; Index: clang/test/SemaCXX/enum.cpp === --- clang/test/SemaCXX/enum.cpp +++ clang/test/SemaCXX/enum.cpp @@ -114,7 +114,7 @@ // PR28903 struct PR28903 { enum { -PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in an enumeration}} +PR28903_A = (enum { // expected-error-re {{'PR28903::(anonymous enum at {{.*}})' cannot be defined in a type specifier}} PR28903_B, PR28903_C = PR28903_B }) Index: clang/test/CXX/drs/dr5xx.cpp === --- clang/test/CXX/drs/dr5xx.cpp +++ clang/test/CXX/drs/dr5xx.cpp @@ -424,7 +424,7 @@ while (const n = 0) {} // expected-error {{requires a type specifier}} for (const n = 0; // expected-error {{requires a type specifier}} const m = 0; ) {} // expected-error {{requires a type specifier}} - sizeof(const); // expected-error {{requires a type specifier}} + sizeof(const); // expected-error {{expected a type}} struct S { const n; // expected-error {{requires a type specifier}} operator const(); // expected-error {{expected a type}} Index: clang/lib/Sema/SemaDecl.cpp === --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14012,13 +14012,6 @@ Invalid = true; } - if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition && - DC->getDeclKind() == Decl::Enum) { -Diag(New->getLocation(), diag::err_type_defined_in_enum) - << Context.getTagDeclType(New); -Inva
[PATCH] D39104: Allow /showIncludes with /P
thakis accepted this revision. thakis added a comment. This revision is now accepted and ready to land. Thanks! https://reviews.llvm.org/D39104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37182: [libcxx] Special visibility macros for the experimental library
smeenai added a comment. Sorry, this has been on my queue for a long time, but I haven't gotten the chance to get to it yet. I'll try to take a look (at this and your other patches) in the next few days. https://reviews.llvm.org/D37182 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316225 - Allow /showIncludes with /P
Author: erichkeane Date: Fri Oct 20 12:18:30 2017 New Revision: 316225 URL: http://llvm.org/viewvc/llvm-project?rev=316225&view=rev Log: Allow /showIncludes with /P r213589 was checked in as a solution to https://bugs.llvm.org/show_bug.cgi?id=20336. However, it is possible to use /EP with /P to suppress #line directives AND output to a file. There is no reason in that case to suppress /showIncludes. This was reported here: https://bugs.llvm.org/show_bug.cgi?id=34997 Differential Revision: https://reviews.llvm.org/D39104 Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=316225&r1=316224&r2=316225&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Oct 20 12:18:30 2017 @@ -4873,7 +4873,9 @@ void Clang::AddClangCLArgs(const ArgList // Both /showIncludes and /E (and /EP) write to stdout. Allowing both // would produce interleaved output, so ignore /showIncludes in such cases. - if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) + if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) || + (Args.hasArg(options::OPT__SLASH_P) && + Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E))) if (Arg *A = Args.getLastArg(options::OPT_show_includes)) A->render(Args, CmdArgs); Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=316225&r1=316224&r2=316225&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Fri Oct 20 12:18:30 2017 @@ -197,8 +197,12 @@ // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s +// RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // showIncludes_E: warning: argument unused during compilation: '--show-includes' +// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E_And_P %s +// showIncludes_E_And_P-NOT: warning: argument unused during compilation: '--show-includes' + // /source-charset: should warn on everything except UTF-8. // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s // source-charset-utf-16: invalid value 'utf-16' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39104: Allow /showIncludes with /P
This revision was automatically updated to reflect the committed changes. Closed by commit rL316225: Allow /showIncludes with /P (authored by erichkeane). Changed prior to commit: https://reviews.llvm.org/D39104?vs=119607&id=119686#toc Repository: rL LLVM https://reviews.llvm.org/D39104 Files: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/cl-options.c Index: cfe/trunk/test/Driver/cl-options.c === --- cfe/trunk/test/Driver/cl-options.c +++ cfe/trunk/test/Driver/cl-options.c @@ -197,8 +197,12 @@ // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s +// RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // showIncludes_E: warning: argument unused during compilation: '--show-includes' +// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E_And_P %s +// showIncludes_E_And_P-NOT: warning: argument unused during compilation: '--show-includes' + // /source-charset: should warn on everything except UTF-8. // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s // source-charset-utf-16: invalid value 'utf-16' Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -4873,7 +4873,9 @@ // Both /showIncludes and /E (and /EP) write to stdout. Allowing both // would produce interleaved output, so ignore /showIncludes in such cases. - if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) + if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) || + (Args.hasArg(options::OPT__SLASH_P) && + Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E))) if (Arg *A = Args.getLastArg(options::OPT_show_includes)) A->render(Args, CmdArgs); Index: cfe/trunk/test/Driver/cl-options.c === --- cfe/trunk/test/Driver/cl-options.c +++ cfe/trunk/test/Driver/cl-options.c @@ -197,8 +197,12 @@ // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s +// RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s // showIncludes_E: warning: argument unused during compilation: '--show-includes' +// RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E_And_P %s +// showIncludes_E_And_P-NOT: warning: argument unused during compilation: '--show-includes' + // /source-charset: should warn on everything except UTF-8. // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s // source-charset-utf-16: invalid value 'utf-16' Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp === --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp @@ -4873,7 +4873,9 @@ // Both /showIncludes and /E (and /EP) write to stdout. Allowing both // would produce interleaved output, so ignore /showIncludes in such cases. - if (!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) + if ((!Args.hasArg(options::OPT_E) && !Args.hasArg(options::OPT__SLASH_EP)) || + (Args.hasArg(options::OPT__SLASH_P) && + Args.hasArg(options::OPT__SLASH_EP) && !Args.hasArg(options::OPT_E))) if (Arg *A = Args.getLastArg(options::OPT_show_includes)) A->render(Args, CmdArgs); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39136: [OpenMP] Avoid VLAs for some reductions on array sections
Hahnfeld created this revision. In some cases the compiler can deduce the length of an array section as constants. With this information, VLAs can be avoided in place of a constant sized array or even a scalar value if the length is 1. Example: int a[4], b[2]; pragma omp parallel reduction(+: a[1:2], b[1:1]) { } For chained array sections, this optimization is restricted to cases where all array sections except the last have a constant length 1. This trivially guarantees that there are no holes in the memory region that needs to be privatized. Example: int c[3][4]; pragma omp parallel reduction(+: c[1:1][1:2]) { } https://reviews.llvm.org/D39136 Files: lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/Sema/SemaOpenMP.cpp test/OpenMP/for_reduction_codegen.cpp test/OpenMP/for_reduction_codegen_UDR.cpp Index: test/OpenMP/for_reduction_codegen_UDR.cpp === --- test/OpenMP/for_reduction_codegen_UDR.cpp +++ test/OpenMP/for_reduction_codegen_UDR.cpp @@ -40,15 +40,16 @@ // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer #pragma omp declare reduction(operator&& : int : omp_out = 111 & omp_in) -template +template T tmain() { T t; S test; T t_var = T(), t_var1; T vec[] = {1, 2}; S s_arr[] = {1, 2}; S &var = test; S var1; + S arr[length]; #pragma omp declare reduction(operator& : T : omp_out = 15 + omp_in) #pragma omp declare reduction(operator+ : T : omp_out = 1513 + omp_in) initializer(omp_priv = 321) #pragma omp declare reduction(min : T : omp_out = 47 - omp_in) initializer(omp_priv = 432 / omp_orig) @@ -66,6 +67,12 @@ vec[i] = t_var; s_arr[i] = var; } +#pragma omp parallel +#pragma omp for reduction(+ : arr[1:length-2]) + for (int i = 0; i < 2; ++i) { +vec[i] = t_var; +s_arr[i] = var; + } return T(); } @@ -78,12 +85,12 @@ S test; float t_var = 0, t_var1; int vec[] = {1, 2}; - S s_arr[] = {1, 2}; + S s_arr[] = {1, 2, 3, 4}; S &var = test; S var1, arrs[10][4]; S **var2 = foo(); - S vvar2[2]; - S(&var3)[2] = s_arr; + S vvar2[5]; + S(&var3)[4] = s_arr; #pragma omp declare reduction(operator+ : int : omp_out = 555 * omp_in) initializer(omp_priv = 888) #pragma omp parallel #pragma omp for reduction(+ : t_var) reduction(& : var) reduction(&& : var1) reduction(min : t_var1) @@ -115,24 +122,24 @@ #pragma omp for reduction(& : var3) for (int i = 0; i < 10; ++i) ; - return tmain(); + return tmain(); } // CHECK: define {{.*}}i{{[0-9]+}} @main() // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]], // CHECK: call {{.*}} [[S_FLOAT_TY_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]]) -// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, float*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*, [2 x i32]*, [2 x [[S_FLOAT_TY]]]*)* [[MAIN_MICROTASK:@.+]] to void +// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 6, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, float*, [[S_FLOAT_TY]]*, [[S_FLOAT_TY]]*, float*, [2 x i32]*, [4 x [[S_FLOAT_TY]]]*)* [[MAIN_MICROTASK:@.+]] to void // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i64, i64, i32*, [2 x i32]*, [10 x [4 x [[S_FLOAT_TY*)* [[MAIN_MICROTASK1:@.+]] to void // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i64, i64, i32*, [10 x [4 x [[S_FLOAT_TY*)* [[MAIN_MICROTASK2:@.+]] to void // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [[S_FLOAT_TY]]***)* [[MAIN_MICROTASK3:@.+]] to void -// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x [[S_FLOAT_TY]]]*)* [[MAIN_MICROTASK4:@.+]] to void -// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 1, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, [2 x [[S_FLOAT_TY]]]*)* [[MAIN_MICROTASK5:@.+]] to void -// CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}},
[PATCH] D39122: [Sema] Fixes for enum handling for tautological comparison diagnostics
Rakete added inline comments. Comment at: lib/Sema/SemaChecking.cpp:8610 + if(!S.getLangOpts().CPlusPlus && OtherT->isEnumeralType()) { +OtherT = OtherT->getAs()->getDecl()->getIntegerType(); Please drop the braces. Comment at: lib/Sema/SemaChecking.cpp:8616 + // Special-case for C++ for enum with one enumerator with value of 0 + if (OtherRange.Width == 0) You missed a dot at the end. Comment at: lib/Sema/SemaChecking.cpp:8665 + bool Result; bool ConstIsLowerBound = (Op == BO_LT || Op == BO_LE) ^ RhsConstant; You can define `Result` lower down (and make it `const`). Comment at: lib/Sema/SemaChecking.cpp:8713 + QualType WrittenType = OtherT; + if(!S.getLangOpts().CPlusPlus && OtherT->isEnumeralType()) { +OtherT = OtherT->getAs()->getDecl()->getIntegerType(); Same as before. Also, shouldn't this be a function instead of duplicating the same code two times? Comment at: test/Sema/outof-range-enum-constant-compare.c:1 +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s +// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s I don't know what the convention is, but I would prefer to use platform independent tests wherever possible. I couldn't find a flag to change the underlying type of an enum, so I'm not sure if my suggestion is even feasible. Repository: rL LLVM https://reviews.llvm.org/D39122 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39136: [OpenMP] Avoid VLAs for some reductions on array sections
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D39136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316229 - [OpenMP] Avoid VLAs for some reductions on array sections
Author: hahnfeld Date: Fri Oct 20 12:40:40 2017 New Revision: 316229 URL: http://llvm.org/viewvc/llvm-project?rev=316229&view=rev Log: [OpenMP] Avoid VLAs for some reductions on array sections In some cases the compiler can deduce the length of an array section as constants. With this information, VLAs can be avoided in place of a constant sized array or even a scalar value if the length is 1. Example: int a[4], b[2]; pragma omp parallel reduction(+: a[1:2], b[1:1]) { } For chained array sections, this optimization is restricted to cases where all array sections except the last have a constant length 1. This trivially guarantees that there are no holes in the memory region that needs to be privatized. Example: int c[3][4]; pragma omp parallel reduction(+: c[1:1][1:2]) { } Differential Revision: https://reviews.llvm.org/D39136 Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/for_reduction_codegen.cpp cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=316229&r1=316228&r2=316229&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Oct 20 12:40:40 2017 @@ -925,7 +925,7 @@ void ReductionCodeGen::emitAggregateType cast(cast(ClausesData[N].Private)->getDecl()); QualType PrivateType = PrivateVD->getType(); bool AsArraySection = isa(ClausesData[N].Ref); - if (!AsArraySection && !PrivateType->isVariablyModifiedType()) { + if (!PrivateType->isVariablyModifiedType()) { Sizes.emplace_back( CGF.getTypeSize( SharedAddresses[N].first.getType().getNonReferenceType()), @@ -963,10 +963,9 @@ void ReductionCodeGen::emitAggregateType auto *PrivateVD = cast(cast(ClausesData[N].Private)->getDecl()); QualType PrivateType = PrivateVD->getType(); - bool AsArraySection = isa(ClausesData[N].Ref); - if (!AsArraySection && !PrivateType->isVariablyModifiedType()) { + if (!PrivateType->isVariablyModifiedType()) { assert(!Size && !Sizes[N].second && - "Size should be nullptr for non-variably modified redution " + "Size should be nullptr for non-variably modified reduction " "items."); return; } @@ -994,8 +993,7 @@ void ReductionCodeGen::emitInitializatio CGF.ConvertTypeForMem(SharedType)), SharedType, SharedAddresses[N].first.getBaseInfo(), CGF.CGM.getTBAAAccessInfo(SharedType)); - if (isa(ClausesData[N].Ref) || - CGF.getContext().getAsArrayType(PrivateVD->getType())) { + if (CGF.getContext().getAsArrayType(PrivateVD->getType())) { emitAggregateInitialization(CGF, N, PrivateAddr, SharedLVal, DRD); } else if (DRD && (DRD->getInitializer() || !PrivateVD->hasInit())) { emitInitWithReductionInitializer(CGF, DRD, ClausesData[N].ReductionOp, Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=316229&r1=316228&r2=316229&view=diff == --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Oct 20 12:40:40 2017 @@ -996,7 +996,9 @@ void CodeGenFunction::EmitOMPReductionCl auto *LHSVD = cast(cast(*ILHS)->getDecl()); auto *RHSVD = cast(cast(*IRHS)->getDecl()); -if (isa(IRef)) { +QualType Type = PrivateVD->getType(); +bool isaOMPArraySectionExpr = isa(IRef); +if (isaOMPArraySectionExpr && Type->isVariablyModifiedType()) { // Store the address of the original variable associated with the LHS // implicit variable. PrivateScope.addPrivate(LHSVD, [&RedCG, Count]() -> Address { @@ -1005,7 +1007,8 @@ void CodeGenFunction::EmitOMPReductionCl PrivateScope.addPrivate(RHSVD, [this, PrivateVD]() -> Address { return GetAddrOfLocalVar(PrivateVD); }); -} else if (isa(IRef)) { +} else if ((isaOMPArraySectionExpr && Type->isScalarType()) || + isa(IRef)) { // Store the address of the original variable associated with the LHS // implicit variable. PrivateScope.addPrivate(LHSVD, [&RedCG, Count]() -> Address { Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=316229&r1=316228&r2=316229&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Oct 20 12:40:40 2017 @@ -9330,6 +9330,68 @@ struct ReductionData { }; } // namespace +static bool CheckOMPArraySectionConstantForReduction( +ASTC
[PATCH] D39136: [OpenMP] Avoid VLAs for some reductions on array sections
This revision was automatically updated to reflect the committed changes. Closed by commit rL316229: [OpenMP] Avoid VLAs for some reductions on array sections (authored by Hahnfeld). Changed prior to commit: https://reviews.llvm.org/D39136?vs=119687&id=119689#toc Repository: rL LLVM https://reviews.llvm.org/D39136 Files: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/for_reduction_codegen.cpp cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp === --- cfe/trunk/lib/Sema/SemaOpenMP.cpp +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp @@ -9330,6 +9330,68 @@ }; } // namespace +static bool CheckOMPArraySectionConstantForReduction( +ASTContext &Context, const OMPArraySectionExpr *OASE, bool &SingleElement, +SmallVectorImpl &ArraySizes) { + const Expr *Length = OASE->getLength(); + if (Length == nullptr) { +// For array sections of the form [1:] or [:], we would need to analyze +// the lower bound... +if (OASE->getColonLoc().isValid()) + return false; + +// This is an array subscript which has implicit length 1! +SingleElement = true; +ArraySizes.push_back(llvm::APSInt::get(1)); + } else { +llvm::APSInt ConstantLengthValue; +if (!Length->EvaluateAsInt(ConstantLengthValue, Context)) + return false; + +SingleElement = (ConstantLengthValue.getSExtValue() == 1); +ArraySizes.push_back(ConstantLengthValue); + } + + // Get the base of this array section and walk up from there. + const Expr *Base = OASE->getBase()->IgnoreParenImpCasts(); + + // We require length = 1 for all array sections except the right-most to + // guarantee that the memory region is contiguous and has no holes in it. + while (const auto *TempOASE = dyn_cast(Base)) { +Length = TempOASE->getLength(); +if (Length == nullptr) { + // For array sections of the form [1:] or [:], we would need to analyze + // the lower bound... + if (OASE->getColonLoc().isValid()) +return false; + + // This is an array subscript which has implicit length 1! + ArraySizes.push_back(llvm::APSInt::get(1)); +} else { + llvm::APSInt ConstantLengthValue; + if (!Length->EvaluateAsInt(ConstantLengthValue, Context) || + ConstantLengthValue.getSExtValue() != 1) +return false; + + ArraySizes.push_back(ConstantLengthValue); +} +Base = TempOASE->getBase()->IgnoreParenImpCasts(); + } + + // If we have a single element, we don't need to add the implicit lengths. + if (!SingleElement) { +while (const auto *TempASE = dyn_cast(Base)) { + // Has implicit length 1! + ArraySizes.push_back(llvm::APSInt::get(1)); + Base = TempASE->getBase()->IgnoreParenImpCasts(); +} + } + + // This array section can be privatized as a single value or as a constant + // sized array. + return true; +} + static bool ActOnOMPReductionKindClause( Sema &S, DSAStackTy *Stack, OpenMPClauseKind ClauseKind, ArrayRef VarList, SourceLocation StartLoc, SourceLocation LParenLoc, @@ -9628,7 +9690,26 @@ auto *RHSVD = buildVarDecl(S, ELoc, Type, D->getName(), D->hasAttrs() ? &D->getAttrs() : nullptr); auto PrivateTy = Type; -if (OASE || + +// Try if we can determine constant lengths for all array sections and avoid +// the VLA. +bool ConstantLengthOASE = false; +if (OASE) { + bool SingleElement; + llvm::SmallVector ArraySizes; + ConstantLengthOASE = CheckOMPArraySectionConstantForReduction( + Context, OASE, SingleElement, ArraySizes); + + // If we don't have a single element, we must emit a constant array type. + if (ConstantLengthOASE && !SingleElement) { +for (auto &Size : ArraySizes) { + PrivateTy = Context.getConstantArrayType( + PrivateTy, Size, ArrayType::Normal, /*IndexTypeQuals=*/0); +} + } +} + +if ((OASE && !ConstantLengthOASE) || (!ASE && D->getType().getNonReferenceType()->isVariablyModifiedType())) { // For arrays/array sections only: Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp === --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp @@ -925,7 +925,7 @@ cast(cast(ClausesData[N].Private)->getDecl()); QualType PrivateType = PrivateVD->getType(); bool AsArraySection = isa(ClausesData[N].Ref); - if (!AsArraySection && !PrivateType->isVariablyModifiedType()) { + if (!PrivateType->isVariablyModifiedType()) { Sizes.emplace_back( CGF.getTypeSize( SharedAddresses[N].first.getType().getNonReferenceType()), @@ -963,10 +963,9 @@ auto *PrivateVD = cast(cast(ClausesData[N].Private)->getDecl()); QualType Priv
[PATCH] D36347: Add new script to launch lldb and set breakpoints for diagnostics all diagnostics seen.
jasonmolenda added a comment. Sorry for missing this back in August. I think it'd be clearer to import your python once in the startup, like -o "script import $module" \ Multiple imports are a no-op IIUC so it's harmless to re-import the module every time the breakpoint is hit (I'm guessing it's only hit once, for that matter), but I think it's clearer to have this on its own line. For what it's worth, if you use breakpoint command add -F python-function, your function is passed in the frame as well as the SBBreakpointLocation. See 'help breakpoint add' for more information about this; I used this in a breakpoint python command I wrote a while back, def handle_pthread_create_return(frame, bp_loc, dict): global pthreads_being_created thread_index_id = frame.GetThread().GetIndexID() [...] it might be a good idea to name the breakpoint you're adding and then you can delete it explicitly, in case the user is doing something unexpected with breakpoints. e.g. % ~/k/svn/lldb/build/Debug/lldb /tmp/a.out (lldb) target create "/tmp/a.out" Current executable set to '/tmp/a.out' (x86_64). (lldb) br s -n main -N worker Breakpoint 1: where = a.out`main, address = 0x00010ec0 (lldb) br del worker 1 breakpoints deleted; 0 breakpoint locations disabled. (lldb) br li No breakpoints currently set. (lldb) https://reviews.llvm.org/D36347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39138: [CodeGen] Generate TBAA info for 'this' pointers
kosarev created this revision. kosarev added a project: clang. Repository: rL LLVM https://reviews.llvm.org/D39138 Files: lib/CodeGen/CGCXXABI.cpp test/CodeGen/tbaa-this.cpp Index: test/CodeGen/tbaa-this.cpp === --- test/CodeGen/tbaa-this.cpp +++ test/CodeGen/tbaa-this.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for 'this' pointers. + +struct C { + C *self(); +}; + +C *C::self() { +// CHECK-LABEL: _ZN1C4selfEv +// CHECK: load {{.*}}, !tbaa [[TAG_pointer:!.*]] + return this; +} + +C* foo(C *p) { + return p->self(); +} + +// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0} +// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", !{{.*}}, i64 0} Index: lib/CodeGen/CGCXXABI.cpp === --- lib/CodeGen/CGCXXABI.cpp +++ lib/CodeGen/CGCXXABI.cpp @@ -152,9 +152,12 @@ void CGCXXABI::EmitThisParam(CodeGenFunction &CGF) { /// Initialize the 'this' slot. assert(getThisDecl(CGF) && "no 'this' variable for function"); - CGF.CXXABIThisValue -= CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(getThisDecl(CGF)), - "this"); + ImplicitParamDecl *ThisPtrDecl = getThisDecl(CGF); + auto *Load = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(ThisPtrDecl), + "this"); + QualType ThisPtrType = ThisPtrDecl->getType(); + CGM.DecorateInstructionWithTBAA(Load, CGM.getTBAAAccessInfo(ThisPtrType)); + CGF.CXXABIThisValue = Load; } void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, Index: test/CodeGen/tbaa-this.cpp === --- test/CodeGen/tbaa-this.cpp +++ test/CodeGen/tbaa-this.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple x86_64-linux -O1 -disable-llvm-passes %s \ +// RUN: -emit-llvm -o - | FileCheck %s +// +// Check that we generate correct TBAA information for 'this' pointers. + +struct C { + C *self(); +}; + +C *C::self() { +// CHECK-LABEL: _ZN1C4selfEv +// CHECK: load {{.*}}, !tbaa [[TAG_pointer:!.*]] + return this; +} + +C* foo(C *p) { + return p->self(); +} + +// CHECK-DAG: [[TAG_pointer]] = !{[[TYPE_pointer:!.*]], [[TYPE_pointer]], i64 0} +// CHECK-DAG: [[TYPE_pointer]] = !{!"any pointer", !{{.*}}, i64 0} Index: lib/CodeGen/CGCXXABI.cpp === --- lib/CodeGen/CGCXXABI.cpp +++ lib/CodeGen/CGCXXABI.cpp @@ -152,9 +152,12 @@ void CGCXXABI::EmitThisParam(CodeGenFunction &CGF) { /// Initialize the 'this' slot. assert(getThisDecl(CGF) && "no 'this' variable for function"); - CGF.CXXABIThisValue -= CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(getThisDecl(CGF)), - "this"); + ImplicitParamDecl *ThisPtrDecl = getThisDecl(CGF); + auto *Load = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(ThisPtrDecl), + "this"); + QualType ThisPtrType = ThisPtrDecl->getType(); + CGM.DecorateInstructionWithTBAA(Load, CGM.getTBAAAccessInfo(ThisPtrType)); + CGF.CXXABIThisValue = Load; } void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316235 - Revert "[OpenMP] Avoid VLAs for some reductions on array sections"
Author: hahnfeld Date: Fri Oct 20 13:16:17 2017 New Revision: 316235 URL: http://llvm.org/viewvc/llvm-project?rev=316235&view=rev Log: Revert "[OpenMP] Avoid VLAs for some reductions on array sections" This breaks at least two buildbots: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/1175 http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/10478 This reverts commit r316229 during local investigation. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/for_reduction_codegen.cpp cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=316235&r1=316234&r2=316235&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Oct 20 13:16:17 2017 @@ -925,7 +925,7 @@ void ReductionCodeGen::emitAggregateType cast(cast(ClausesData[N].Private)->getDecl()); QualType PrivateType = PrivateVD->getType(); bool AsArraySection = isa(ClausesData[N].Ref); - if (!PrivateType->isVariablyModifiedType()) { + if (!AsArraySection && !PrivateType->isVariablyModifiedType()) { Sizes.emplace_back( CGF.getTypeSize( SharedAddresses[N].first.getType().getNonReferenceType()), @@ -963,9 +963,10 @@ void ReductionCodeGen::emitAggregateType auto *PrivateVD = cast(cast(ClausesData[N].Private)->getDecl()); QualType PrivateType = PrivateVD->getType(); - if (!PrivateType->isVariablyModifiedType()) { + bool AsArraySection = isa(ClausesData[N].Ref); + if (!AsArraySection && !PrivateType->isVariablyModifiedType()) { assert(!Size && !Sizes[N].second && - "Size should be nullptr for non-variably modified reduction " + "Size should be nullptr for non-variably modified redution " "items."); return; } @@ -993,7 +994,8 @@ void ReductionCodeGen::emitInitializatio CGF.ConvertTypeForMem(SharedType)), SharedType, SharedAddresses[N].first.getBaseInfo(), CGF.CGM.getTBAAAccessInfo(SharedType)); - if (CGF.getContext().getAsArrayType(PrivateVD->getType())) { + if (isa(ClausesData[N].Ref) || + CGF.getContext().getAsArrayType(PrivateVD->getType())) { emitAggregateInitialization(CGF, N, PrivateAddr, SharedLVal, DRD); } else if (DRD && (DRD->getInitializer() || !PrivateVD->hasInit())) { emitInitWithReductionInitializer(CGF, DRD, ClausesData[N].ReductionOp, Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=316235&r1=316234&r2=316235&view=diff == --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Oct 20 13:16:17 2017 @@ -996,9 +996,7 @@ void CodeGenFunction::EmitOMPReductionCl auto *LHSVD = cast(cast(*ILHS)->getDecl()); auto *RHSVD = cast(cast(*IRHS)->getDecl()); -QualType Type = PrivateVD->getType(); -bool isaOMPArraySectionExpr = isa(IRef); -if (isaOMPArraySectionExpr && Type->isVariablyModifiedType()) { +if (isa(IRef)) { // Store the address of the original variable associated with the LHS // implicit variable. PrivateScope.addPrivate(LHSVD, [&RedCG, Count]() -> Address { @@ -1007,8 +1005,7 @@ void CodeGenFunction::EmitOMPReductionCl PrivateScope.addPrivate(RHSVD, [this, PrivateVD]() -> Address { return GetAddrOfLocalVar(PrivateVD); }); -} else if ((isaOMPArraySectionExpr && Type->isScalarType()) || - isa(IRef)) { +} else if (isa(IRef)) { // Store the address of the original variable associated with the LHS // implicit variable. PrivateScope.addPrivate(LHSVD, [&RedCG, Count]() -> Address { Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=316235&r1=316234&r2=316235&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Oct 20 13:16:17 2017 @@ -9330,68 +9330,6 @@ struct ReductionData { }; } // namespace -static bool CheckOMPArraySectionConstantForReduction( -ASTContext &Context, const OMPArraySectionExpr *OASE, bool &SingleElement, -SmallVectorImpl &ArraySizes) { - const Expr *Length = OASE->getLength(); - if (Length == nullptr) { -// For array sections of the form [1:] or [:], we would need to analyze -// the lower bound... -if (OASE->getColonLoc().isValid()) - return false; - -// This is an array subscript which has impli
[PATCH] D39136: [OpenMP] Avoid VLAs for some reductions on array sections
Hahnfeld reopened this revision. Hahnfeld added a comment. This revision is now accepted and ready to land. At least two buildbots failing: http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/1175 http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/10478 Repository: rL LLVM https://reviews.llvm.org/D39136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r316238 - r600: Add missing datalayout to .ll files
Author: jvesely Date: Fri Oct 20 14:00:31 2017 New Revision: 316238 URL: http://llvm.org/viewvc/llvm-project?rev=316238&view=rev Log: r600: Add missing datalayout to .ll files Signed-off-by: Jan Vesely Acked-by: Aaron Watry Modified: libclc/trunk/r600/lib/synchronization/barrier_impl.ll libclc/trunk/r600/lib/workitem/get_global_size.ll libclc/trunk/r600/lib/workitem/get_local_size.ll libclc/trunk/r600/lib/workitem/get_num_groups.ll Modified: libclc/trunk/r600/lib/synchronization/barrier_impl.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier_impl.ll?rev=316238&r1=316237&r2=316238&view=diff == --- libclc/trunk/r600/lib/synchronization/barrier_impl.ll (original) +++ libclc/trunk/r600/lib/synchronization/barrier_impl.ll Fri Oct 20 14:00:31 2017 @@ -1,5 +1,7 @@ declare void @llvm.r600.group.barrier() #0 +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define void @barrier(i32 %flags) #1 { entry: ; We should call mem_fence here, but that is not implemented for r600 yet Modified: libclc/trunk/r600/lib/workitem/get_global_size.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_global_size.ll?rev=316238&r1=316237&r2=316238&view=diff == --- libclc/trunk/r600/lib/workitem/get_global_size.ll (original) +++ libclc/trunk/r600/lib/workitem/get_global_size.ll Fri Oct 20 14:00:31 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.global.size. declare i32 @llvm.r600.read.global.size.y() nounwind readnone declare i32 @llvm.r600.read.global.size.z() nounwind readnone +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: Modified: libclc/trunk/r600/lib/workitem/get_local_size.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_local_size.ll?rev=316238&r1=316237&r2=316238&view=diff == --- libclc/trunk/r600/lib/workitem/get_local_size.ll (original) +++ libclc/trunk/r600/lib/workitem/get_local_size.ll Fri Oct 20 14:00:31 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.local.size.x declare i32 @llvm.r600.read.local.size.y() nounwind readnone declare i32 @llvm.r600.read.local.size.z() nounwind readnone +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: Modified: libclc/trunk/r600/lib/workitem/get_num_groups.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/workitem/get_num_groups.ll?rev=316238&r1=316237&r2=316238&view=diff == --- libclc/trunk/r600/lib/workitem/get_num_groups.ll (original) +++ libclc/trunk/r600/lib/workitem/get_num_groups.ll Fri Oct 20 14:00:31 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.ngroups.x() declare i32 @llvm.r600.read.ngroups.y() nounwind readnone declare i32 @llvm.r600.read.ngroups.z() nounwind readnone +target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i32 @get_num_groups(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39122: [Sema] Fixes for enum handling for tautological comparison diagnostics
lebedev.ri updated this revision to Diff 119705. lebedev.ri marked 5 inline comments as done. lebedev.ri added a comment. Addressed review notes. For C++, enum handling clearly needs more work, because not all tautological comparisons are actually diagnosed, so there is no `clang/test/Sema/outof-range-enum-constant-compare.cpp`, `clang/test/Sema/tautological-constant-enum-compare.cpp` for this very reason. Repository: rL LLVM https://reviews.llvm.org/D39122 Files: lib/Sema/SemaChecking.cpp test/Sema/outof-range-enum-constant-compare.c test/Sema/tautological-constant-enum-compare.c test/Sema/tautological-unsigned-enum-zero-compare.c test/Sema/tautological-unsigned-enum-zero-compare.cpp Index: test/Sema/tautological-unsigned-enum-zero-compare.cpp === --- test/Sema/tautological-unsigned-enum-zero-compare.cpp +++ test/Sema/tautological-unsigned-enum-zero-compare.cpp @@ -7,169 +7,321 @@ // On windows, it is signed by default. We do not want to warn in that case. int main() { - enum A { A_foo, A_bar }; + enum A { A_foo = 0 }; enum A a; - enum B : unsigned { B_foo, B_bar }; + enum B : unsigned { B_foo = 0 }; enum B b; - enum C : signed { c_foo, c_bar }; + enum C : signed { C_foo = 0 }; enum C c; #ifdef ALL_WARN if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0 >= a) +return 0; + if (a > 0) return 0; if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (a <= 0) +return 0; if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; + if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0 < a) +return 0; + if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0U >= a) +return 0; + if (a > 0U) return 0; if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (a <= 0U) +return 0; if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; + if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} +return 0; + if (0U < a) +return 0; if (b < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} return 0; - if (b >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} + if (0 >= b) +return 0; + if (b > 0) return 0; if (0 <= b) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} return 0; + if (b <= 0) +return 0; if (0 > b) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} return 0; - if (b < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; - if (b >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} -return 0; - if (0U <= b) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} -return 0; - if (0U > b) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} -return 0; - - if (c < 0) // ok -return 0; - if (c >= 0) // ok -return 0; - if (0 <= c) // ok -return 0; - if (0 > c) // ok -return 0; - if (c < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; - if (c >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} -return 0; - if (0U <= c) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} -return 0; - if (0U > c) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} -return 0; -#elif defined(SIGN_WARN) - if (a < 0) // ok -return 0; - if (a >= 0) // ok -return 0; - if (0 <= a) // ok -return 0; - if (0 > a) // ok -return 0; - if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; - if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}} -return 0; - if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}} -return 0; - if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}} -return 0; - - if (b < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}} -return 0; if
[libclc] r316239 - amdgcn: Add missing datalayout info to .ll files
Author: jvesely Date: Fri Oct 20 14:10:18 2017 New Revision: 316239 URL: http://llvm.org/viewvc/llvm-project?rev=316239&view=rev Log: amdgcn: Add missing datalayout info to .ll files Signed-off-by: Jan Vesely Acked-by: Aaron Watry Modified: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll libclc/trunk/amdgcn/lib/workitem/get_global_size.ll libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll libclc/trunk/amdgcn/lib/workitem/get_local_size.ll libclc/trunk/amdgcn/lib/workitem/get_num_groups.39.ll libclc/trunk/amdgcn/lib/workitem/get_num_groups.ll Modified: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=316239&r1=316238&r2=316239&view=diff == --- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll (original) +++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Fri Oct 20 14:10:18 2017 @@ -1,3 +1,5 @@ +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline { entry: %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst Modified: libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll?rev=316239&r1=316238&r2=316239&view=diff == --- libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll (original) +++ libclc/trunk/amdgcn/lib/workitem/get_global_size.39.ll Fri Oct 20 14:10:18 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.global.size. declare i32 @llvm.r600.read.global.size.y() nounwind readnone declare i32 @llvm.r600.read.global.size.z() nounwind readnone +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i32 @get_global_size(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: Modified: libclc/trunk/amdgcn/lib/workitem/get_global_size.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_global_size.ll?rev=316239&r1=316238&r2=316239&view=diff == --- libclc/trunk/amdgcn/lib/workitem/get_global_size.ll (original) +++ libclc/trunk/amdgcn/lib/workitem/get_global_size.ll Fri Oct 20 14:10:18 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.global.size. declare i32 @llvm.r600.read.global.size.y() nounwind readnone declare i32 @llvm.r600.read.global.size.z() nounwind readnone +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i64 @get_global_size(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: Modified: libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll?rev=316239&r1=316238&r2=316239&view=diff == --- libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll (original) +++ libclc/trunk/amdgcn/lib/workitem/get_local_size.39.ll Fri Oct 20 14:10:18 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.local.size.x declare i32 @llvm.r600.read.local.size.y() nounwind readnone declare i32 @llvm.r600.read.local.size.z() nounwind readnone +target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" + define i32 @get_local_size(i32 %dim) nounwind readnone alwaysinline { switch i32 %dim, label %default [i32 0, label %x_dim i32 1, label %y_dim i32 2, label %z_dim] x_dim: Modified: libclc/trunk/amdgcn/lib/workitem/get_local_size.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/workitem/get_local_size.ll?rev=316239&r1=316238&r2=316239&view=diff == --- libclc/trunk/amdgcn/lib/workitem/get_local_size.ll (original) +++ libclc/trunk/amdgcn/lib/workitem/get_local_size.ll Fri Oct 20 14:10:18 2017 @@ -2,6 +2,8 @@ declare i32 @llvm.r600.read.local.size.x declare i32 @llvm.r600.read.l
[PATCH] D38982: [refactor] Initial outline of implementation of "extract function" refactoring
arphaman updated this revision to Diff 119708. arphaman marked 4 inline comments as done. arphaman added a comment. Address review comments. Repository: rL LLVM https://reviews.llvm.org/D38982 Files: include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h include/clang/Tooling/Refactoring/RefactoringRuleContext.h lib/Tooling/Refactoring/ASTSelection.cpp lib/Tooling/Refactoring/ASTSelectionRequirements.cpp lib/Tooling/Refactoring/Extract.cpp test/Refactor/Extract/ExtractExprIntoFunction.cpp test/Refactor/LocalRename/Field.cpp test/Refactor/LocalRename/NoSymbolSelectedError.cpp tools/clang-refactor/TestSupport.cpp Index: tools/clang-refactor/TestSupport.cpp === --- tools/clang-refactor/TestSupport.cpp +++ tools/clang-refactor/TestSupport.cpp @@ -102,14 +102,7 @@ llvm::errs() << toString(Result.takeError()); return true; } -auto Buf = llvm::MemoryBuffer::getMemBuffer(Result->c_str()); -for (llvm::line_iterator It(*Buf, /*SkipBlanks=*/false); !It.is_at_end(); - ++It) { - // Drop the 'CHECK' lines alltogether to avoid erroneous matches. - if (It->contains("CHECK")) -continue; - OS << *It << "\n"; -} +OS << *Result; } return false; } Index: test/Refactor/LocalRename/NoSymbolSelectedError.cpp === --- test/Refactor/LocalRename/NoSymbolSelectedError.cpp +++ test/Refactor/LocalRename/NoSymbolSelectedError.cpp @@ -1,5 +1,5 @@ -// RUN: not clang-refactor local-rename -selection=%s:4:1 -new-name=Bar %s -- 2>&1 | FileCheck %s -// RUN: clang-refactor local-rename -selection=test:%s -new-name=Bar %s -- 2>&1 | FileCheck --check-prefix=TESTCHECK %s +// RUN: not clang-refactor local-rename -selection=%s:4:1 -new-name=Bar %s -- 2>&1 | grep -v CHECK | FileCheck %s +// RUN: clang-refactor local-rename -selection=test:%s -new-name=Bar %s -- 2>&1 | grep -v CHECK | FileCheck --check-prefix=TESTCHECK %s class Baz { // CHECK: [[@LINE]]:1: error: there is no symbol at the given location }; Index: test/Refactor/LocalRename/Field.cpp === --- test/Refactor/LocalRename/Field.cpp +++ test/Refactor/LocalRename/Field.cpp @@ -1,4 +1,4 @@ -// RUN: clang-refactor local-rename -selection=test:%s -new-name=Bar %s -- | FileCheck %s +// RUN: clang-refactor local-rename -selection=test:%s -new-name=Bar %s -- | grep -v CHECK | FileCheck %s class Baz { int /*range=*/Foo; Index: test/Refactor/Extract/ExtractExprIntoFunction.cpp === --- test/Refactor/Extract/ExtractExprIntoFunction.cpp +++ test/Refactor/Extract/ExtractExprIntoFunction.cpp @@ -1,4 +1,4 @@ -// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 2>&1 | FileCheck %s +// RUN: clang-refactor extract -selection=test:%s %s -- -std=c++11 2>&1 | grep -v CHECK | FileCheck %s void simpleExtractNoCaptures() { Index: lib/Tooling/Refactoring/Extract.cpp === --- lib/Tooling/Refactoring/Extract.cpp +++ lib/Tooling/Refactoring/Extract.cpp @@ -45,12 +45,12 @@ } class ExtractableCodeSelectionRequirement final -: public CodeRangeSelectionRequirement { +: public CodeRangeASTSelectionRequirement { public: Expected evaluate(RefactoringRuleContext &Context) const { Expected Selection = -CodeRangeSelectionRequirement::evaluate(Context); +CodeRangeASTSelectionRequirement::evaluate(Context); if (!Selection) return Selection.takeError(); CodeRangeASTSelection &Code = *Selection; @@ -207,7 +207,8 @@ StringRef getCommand() const override { return "extract"; } StringRef getDescription() const override { -return "Extracts code into a new function / method / variable"; +return "(WIP action; use with caution!) Extracts code into a new function " + "/ method / variable"; } /// Returns a set of refactoring actions rules that are defined by this Index: lib/Tooling/Refactoring/ASTSelectionRequirements.cpp === --- lib/Tooling/Refactoring/ASTSelectionRequirements.cpp +++ lib/Tooling/Refactoring/ASTSelectionRequirements.cpp @@ -28,8 +28,8 @@ return std::move(*Selection); } -Expected -CodeRangeSelectionRequirement::evaluate(RefactoringRuleContext &Context) const { +Expected CodeRangeASTSelectionRequirement::evaluate( +RefactoringRuleContext &Context) const { // FIXME: Memoize so that selection is evaluated only once. Expected ASTSelection = ASTSelectionRequirement::evaluate(Context); Index: lib/Tooling/Refactoring/ASTSelection.cpp === --- lib/Tooling/Refactoring/ASTSelection.cpp +++ lib/Tooling/Refactoring/ASTSelection.cpp @@ -337,6 +337,9
[PATCH] D38982: [refactor] Initial outline of implementation of "extract function" refactoring
arphaman added a comment. In https://reviews.llvm.org/D38982#900744, @ioeric wrote: > Code looks good in general. I see there are a bunch of major features > missing; it might make sense to print a warning or document the major missing > features in the high-level API. I added a warning in the description of the action. Comment at: include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h:75 /// \see CodeRangeASTSelection -class CodeRangeSelectionRequirement : public ASTSelectionRequirement { +class CodeRangeASTSelectionRequirement : public ASTSelectionRequirement { public: Renamed to `CodeRangeASTSelectionRequirement` Comment at: lib/Tooling/Refactoring/Extract.cpp:167 + OS << "return "; +OS << ExtractedCodeRewriter.getRewrittenText(ExtractedRange); +// FIXME: Compute the correct semicolon policy. ioeric wrote: > An alternative way to get the source code is: > ``` > Lexer::getSourceText( > CharSourceRange::getTokenRange(SM.getSpellingLoc(Start), > SM.getSpellingLoc(End)), > SM, Result.Context->getLangOpts()); > ``` I will need to get the rewritten source, so I've started using it in the first patch. Comment at: tools/clang-refactor/TestSupport.cpp:106 +auto Buf = llvm::MemoryBuffer::getMemBuffer(Result->c_str()); +for (llvm::line_iterator It(*Buf, /*SkipBlanks=*/false); !It.is_at_end(); + ++It) { ioeric wrote: > Can we filter the `CHECK`s with `sed` in the test? Similar to > https://github.com/llvm-mirror/clang-tools-extra/blob/master/test/change-namespace/simple-move.cpp#L1 Fixed. Repository: rL LLVM https://reviews.llvm.org/D38982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38982: [refactor] Initial outline of implementation of "extract function" refactoring
arphaman updated this revision to Diff 119711. arphaman added a comment. Fix diff Repository: rL LLVM https://reviews.llvm.org/D38982 Files: include/clang/Basic/DiagnosticRefactoringKinds.td include/clang/Tooling/Refactoring/ASTSelection.h include/clang/Tooling/Refactoring/RefactoringActionRegistry.def include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h include/clang/Tooling/Refactoring/RefactoringRuleContext.h lib/Tooling/Refactoring/ASTSelection.cpp lib/Tooling/Refactoring/ASTSelectionRequirements.cpp lib/Tooling/Refactoring/CMakeLists.txt lib/Tooling/Refactoring/Extract.cpp test/Refactor/Extract/ExtractExprIntoFunction.cpp test/Refactor/LocalRename/Field.cpp test/Refactor/LocalRename/NoSymbolSelectedError.cpp test/Refactor/tool-test-support.c tools/clang-refactor/TestSupport.cpp Index: tools/clang-refactor/TestSupport.cpp === --- tools/clang-refactor/TestSupport.cpp +++ tools/clang-refactor/TestSupport.cpp @@ -20,6 +20,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Error.h" #include "llvm/Support/ErrorOr.h" +#include "llvm/Support/LineIterator.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Regex.h" #include "llvm/Support/raw_ostream.h" @@ -241,9 +242,9 @@ // Dump the results: const auto &TestGroup = TestRanges.GroupedRanges[Group.index()]; if (!CanonicalResult) { - llvm::errs() << TestGroup.Ranges.size() << " '" << TestGroup.Name + llvm::outs() << TestGroup.Ranges.size() << " '" << TestGroup.Name << "' results:\n"; - llvm::errs() << *CanonicalErrorMessage << "\n"; + llvm::outs() << *CanonicalErrorMessage << "\n"; } else { llvm::outs() << TestGroup.Ranges.size() << " '" << TestGroup.Name << "' results:\n"; @@ -271,6 +272,25 @@ (NewlinePos == StringRef::npos ? ColumnOffset : (unsigned)NewlinePos); } +static unsigned addEndLineOffsetAndEndColumn(StringRef Source, unsigned Offset, + unsigned LineNumberOffset, + unsigned Column) { + StringRef Line = Source.drop_front(Offset); + unsigned LineOffset = 0; + for (; LineNumberOffset != 0; --LineNumberOffset) { +size_t NewlinePos = Line.find_first_of("\r\n"); +// Line offset goes out of bounds. +if (NewlinePos == StringRef::npos) + break; +LineOffset += NewlinePos + 1; +Line = Line.drop_front(NewlinePos + 1); + } + // Source now points to the line at +lineOffset; + size_t LineStart = Source.find_last_of("\r\n", /*From=*/Offset + LineOffset); + return addColumnOffset( + Source, LineStart == StringRef::npos ? 0 : LineStart + 1, Column - 1); +} + Optional findTestSelectionRanges(StringRef Filename) { ErrorOr> ErrOrFile = @@ -282,11 +302,11 @@ } StringRef Source = ErrOrFile.get()->getBuffer(); - // FIXME (Alex L): 3rd capture groups for +line:column. // See the doc comment for this function for the explanation of this // syntax. static Regex RangeRegex("range[[:blank:]]*([[:alpha:]_]*)?[[:blank:]]*=[[:" - "blank:]]*(\\+[[:digit:]]+)?"); + "blank:]]*(\\+[[:digit:]]+)?[[:blank:]]*(->[[:blank:]" + "]*[\\+\\:[:digit:]]+)?"); std::map> GroupedRanges; @@ -304,18 +324,22 @@ StringRef Comment = Source.substr(Tok.getLocation().getRawEncoding(), Tok.getLength()); SmallVector Matches; -// Allow CHECK: comments to contain range= commands. -if (!RangeRegex.match(Comment, &Matches) || Comment.contains("CHECK")) { - // Try to detect mistyped 'range:' comments to ensure tests don't miss - // anything. +// Try to detect mistyped 'range:' comments to ensure tests don't miss +// anything. +auto DetectMistypedCommand = [&]() -> bool { if (Comment.contains_lower("range") && Comment.contains("=") && !Comment.contains_lower("run") && !Comment.contains("CHECK")) { llvm::errs() << "error: suspicious comment '" << Comment << "' that " "resembles the range command found\n"; llvm::errs() << "note: please reword if this isn't a range command\n"; -return None; } + return false; +}; +// Allow CHECK: comments to contain range= commands. +if (!RangeRegex.match(Comment, &Matches) || Comment.contains("CHECK")) { + if (DetectMistypedCommand()) +return None; continue; } unsigned Offset = Tok.getEndLoc().getRawEncoding(); @@ -325,9 +349,27 @@ if (Matches[2].drop_front().getAsInteger(10, ColumnOffset)) assert(false && "regex should have produced a number"); } -// FIXME (Alex L): Support true ranges. Offset = addColumnOffset(Source, Offset, Col
[PATCH] D38704: [libunwind] Abstract rwlocks into a class, provide a SRW lock implementation for windows
mstorsjo added a comment. Ping @zturner and others https://reviews.llvm.org/D38704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38819: [libunwind] Add support for dwarf unwinding on windows on x86_64
mstorsjo added a comment. Ping https://reviews.llvm.org/D38819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39105: Patch bug 27628 (clang-tidy should exit with a failure code when there are errors)
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Looks good! Thank you! https://reviews.llvm.org/D39105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38549: [clang-tidy] Link targets and Asm parsers
alexfh added inline comments. Comment at: clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp:13-16 + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } Will this compile on linux and mac? If no, maybe a separate test just for windows is the way to go. https://reviews.llvm.org/D38549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38549: [clang-tidy] Link targets and Asm parsers
alexfh added inline comments. Comment at: clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp:13-16 + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } alexfh wrote: > Will this compile on linux and mac? If no, maybe a separate test just for > windows is the way to go. ... answering my own question: no, it doesn't compile on linux (https://godbolt.org/g/9HVvjp). Please add a separate test guarded by `REQUIRES: system-windows` and ensure it breaks before your patch and passes with it. https://reviews.llvm.org/D38549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM buildmaster will be updated and restarted tonight
Hello everyone, LLVM buildmaster will be updated and restarted after 7 PM Pacific time. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316245 - Implement current CWG direction for support of arrays of unknown bounds in
Author: rsmith Date: Fri Oct 20 15:56:25 2017 New Revision: 316245 URL: http://llvm.org/viewvc/llvm-project?rev=316245&view=rev Log: Implement current CWG direction for support of arrays of unknown bounds in constant expressions. We permit array-to-pointer decay on such arrays, but disallow pointer arithmetic (since we do not know whether it will have defined behavior). This is based on r311970 and r301822 (the former by me and the latter by Robert Haberlach). Between then and now, two things have changed: we have committee feedback indicating that this is indeed the right direction, and the code broken by this change has been fixed. This is necessary in C++17 to continue accepting certain forms of non-type template argument involving arrays of unknown bound. Added: cfe/trunk/test/SemaCXX/constexpr-array-unknown-bound.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td cfe/trunk/include/clang/Basic/DiagnosticIDs.h cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=316245&r1=316244&r2=316245&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri Oct 20 15:56:25 2017 @@ -127,6 +127,10 @@ def note_constexpr_access_null : Note< def note_constexpr_access_past_end : Note< "%select{read of|assignment to|increment of|decrement of}0 " "dereferenced one-past-the-end pointer is not allowed in a constant expression">; +def note_constexpr_access_unsized_array : Note< + "%select{read of|assignment to|increment of|decrement of}0 " + "pointer to element of array without known bound " + "is not allowed in a constant expression">; def note_constexpr_access_inactive_union_member : Note< "%select{read of|assignment to|increment of|decrement of}0 " "member %1 of union with %select{active member %3|no active member}2 " @@ -154,6 +158,11 @@ def note_constexpr_baa_insufficient_alig def note_constexpr_baa_value_insufficient_alignment : Note< "value of the aligned pointer (%0) is not a multiple of the asserted %1 " "%plural{1:byte|:bytes}1">; +def note_constexpr_unsupported_unsized_array : Note< + "array-to-pointer decay of array member without known bound is not supported">; +def note_constexpr_unsized_array_indexed : Note< + "indexing of array without known bound is not allowed " + "in a constant expression">; def warn_integer_constant_overflow : Warning< "overflow in expression; result is %0 with type %1">, Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=316245&r1=316244&r2=316245&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original) +++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Fri Oct 20 15:56:25 2017 @@ -34,7 +34,7 @@ namespace clang { DIAG_SIZE_SERIALIZATION = 120, DIAG_SIZE_LEX = 400, DIAG_SIZE_PARSE = 500, - DIAG_SIZE_AST = 110, + DIAG_SIZE_AST = 150, DIAG_SIZE_COMMENT = 100, DIAG_SIZE_CROSSTU = 100, DIAG_SIZE_SEMA = 3500, Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=316245&r1=316244&r2=316245&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Oct 20 15:56:25 2017 @@ -62,7 +62,13 @@ namespace { static QualType getType(APValue::LValueBase B) { if (!B) return QualType(); if (const ValueDecl *D = B.dyn_cast()) - return D->getType(); + // FIXME: It's unclear where we're supposed to take the type from, and + // this actually matters for arrays of unknown bound. Using the type of + // the most recent declaration isn't clearly correct in general. Eg: + // + // extern int arr[]; void f() { extern int arr[3]; }; + // constexpr int *p = &arr[1]; // valid? + return cast(D->getMostRecentDecl())->getType(); const Expr *Base = B.get(); @@ -141,6 +147,12 @@ namespace { return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E); } + /// The bound to claim that an array of unknown bound has. + /// The value in MostDerivedArraySize is undefined in this case. So, set it + /// to an arbitrary value that's likely to loudly break things if it's used. + static const uint64_t AssumedSizeForUnsizedArray = + std::numeric_limits::max() / 2; + /// Dete
[clang-tools-extra] r316246 - [clang-tidy] Don't error on MS-style inline assembly.
Author: zturner Date: Fri Oct 20 16:00:51 2017 New Revision: 316246 URL: http://llvm.org/viewvc/llvm-project?rev=316246&view=rev Log: [clang-tidy] Don't error on MS-style inline assembly. To get MS-style inline assembly, we need to link in the various backends. Some other clang tools already do this, and this issue has been raised with clang-tidy several times, indicating there is sufficient desire to make this work. Differential Revision: https://reviews.llvm.org/D38549 Added: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=316246&r1=316245&r2=316246&view=diff == --- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Fri Oct 20 16:00:51 2017 @@ -1,4 +1,7 @@ set(LLVM_LINK_COMPONENTS + AllTargetsAsmParsers + AllTargetsDescs + AllTargetsInfos Support ) Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=316246&r1=316245&r2=316246&view=diff == --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Fri Oct 20 16:00:51 2017 @@ -18,6 +18,7 @@ #include "../ClangTidy.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TargetSelect.h" using namespace clang::ast_matchers; using namespace clang::driver; @@ -403,6 +404,10 @@ static int clangTidyMain(int argc, const ProfileData Profile; + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + ClangTidyContext Context(std::move(OwningOptionsProvider)); runClangTidy(Context, OptionsParser.getCompilations(), PathList, EnableCheckProfile ? &Profile : nullptr); Added: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp?rev=316246&view=auto == --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp (added) +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp Fri Oct 20 16:00:51 2017 @@ -0,0 +1,9 @@ +// REQUIRES: system-windows +// RUN: %check_clang_tidy %s hicpp-no-assembler %t + +void f() { + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } +} Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp?rev=316246&r1=316245&r2=316246&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp Fri Oct 20 16:00:51 2017 @@ -9,4 +9,9 @@ static int s asm("spam"); void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38549: [clang-tidy] Link targets and Asm parsers
This revision was automatically updated to reflect the committed changes. Closed by commit rL316246: [clang-tidy] Don't error on MS-style inline assembly. (authored by zturner). Changed prior to commit: https://reviews.llvm.org/D38549?vs=119677&id=119722#toc Repository: rL LLVM https://reviews.llvm.org/D38549 Files: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp === --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp @@ -0,0 +1,9 @@ +// REQUIRES: system-windows +// RUN: %check_clang_tidy %s hicpp-no-assembler %t + +void f() { + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } +} Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp === --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp @@ -9,4 +9,9 @@ void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } } Index: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt === --- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt +++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt @@ -1,4 +1,7 @@ set(LLVM_LINK_COMPONENTS + AllTargetsAsmParsers + AllTargetsDescs + AllTargetsInfos Support ) Index: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp === --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp @@ -18,6 +18,7 @@ #include "../ClangTidy.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TargetSelect.h" using namespace clang::ast_matchers; using namespace clang::driver; @@ -403,6 +404,10 @@ ProfileData Profile; + llvm::InitializeAllTargetInfos(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmParsers(); + ClangTidyContext Context(std::move(OwningOptionsProvider)); runClangTidy(Context, OptionsParser.getCompilations(), PathList, EnableCheckProfile ? &Profile : nullptr); Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp === --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp @@ -0,0 +1,9 @@ +// REQUIRES: system-windows +// RUN: %check_clang_tidy %s hicpp-no-assembler %t + +void f() { + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } +} Index: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp === --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp @@ -9,4 +9,9 @@ void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + + _asm { +mov al, 2; +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] + } } Index: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt === --- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt +++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt @@ -1,4 +1,7 @@ set(LLVM_LINK_COMPONENTS + AllTargetsAsmParsers + AllTargetsDescs + AllTargetsInfos Support ) Index: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp === --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp @@ -18,6 +18,7 @@ #include "../ClangTidy.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" +#include "llvm/Support/TargetSelect.h" using namespace clang::ast_matchers; using namespace clang::driver; @@ -403,6 +404,10 @@ ProfileData Profile; + llvm
[PATCH] D39105: Patch bug 27628 (clang-tidy should exit with a failure code when there are errors)
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. This patch breaks a number of tests. Please run the tests and fix the failures. https://reviews.llvm.org/D39105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39105: Patch bug 27628 (clang-tidy should exit with a failure code when there are errors)
alexfh added inline comments. Comment at: clang-tidy/tool/ClangTidyMain.cpp:452 + if (FoundErrors) { + return 1; Failed tests reminded me of the -fix-errors flag. I suppose, clang-tidy should not return an error code, when all errors it noticed, contained fixes that were successfully applied by -fix-errors. https://reviews.llvm.org/D39105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r316247 - [clang-tidy] Remove MSVC inline assembly test from cross-plat test.
Author: zturner Date: Fri Oct 20 16:09:20 2017 New Revision: 316247 URL: http://llvm.org/viewvc/llvm-project?rev=316247&view=rev Log: [clang-tidy] Remove MSVC inline assembly test from cross-plat test. This originally started out here in dev, but I moved it to another file when it became clear this wouldn't work on non-Windows. Unfortunately I forgot to remove it from this file. Test is still live, just in another source file. Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp?rev=316247&r1=316246&r2=316247&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp Fri Oct 20 16:09:20 2017 @@ -9,9 +9,4 @@ static int s asm("spam"); void f() { __asm("mov al, 2"); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] - - _asm { -mov al, 2; -// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler] - } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39149: [libc++] Prevent tautological comparisons
smeenai created this revision. Tip-of-tree clang produces `-Wtautological-constant-compare` for tautological constant comparisons, and these pieces of code will trigger that diagnostic when `int` and `long` have the same size (for example, when compiling for a 32-bit target, or for Windows 64-bit). I personally find the diagnostic to be pretty unhelpful when dealing with templates, since my change is essentially manually writing out the code the compiler would have (or at least should have) produced anyway. An alternative would be to just disable the diagnostic around these regions instead of manually avoiding the comparisons. https://reviews.llvm.org/D39149 Files: include/istream src/string.cpp Index: src/string.cpp === --- src/string.cpp +++ src/string.cpp @@ -88,8 +88,10 @@ { // Use long as no Standard string to integer exists. long r = as_integer_helper( func, s, idx, base, strtol ); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (r < numeric_limits::min() || numeric_limits::max() < r) throw_from_string_out_of_range(func); +#endif return static_cast(r); } @@ -133,8 +135,10 @@ { // Use long as no Stantard string to integer exists. long r = as_integer_helper( func, s, idx, base, wcstol ); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (r < numeric_limits::min() || numeric_limits::max() < r) throw_from_string_out_of_range(func); +#endif return static_cast(r); } Index: include/istream === --- include/istream +++ include/istream @@ -711,6 +711,7 @@ ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; @@ -723,6 +724,9 @@ } else __n = static_cast(__temp); +#else +__n = static_cast(__temp); +#endif this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS Index: src/string.cpp === --- src/string.cpp +++ src/string.cpp @@ -88,8 +88,10 @@ { // Use long as no Standard string to integer exists. long r = as_integer_helper( func, s, idx, base, strtol ); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (r < numeric_limits::min() || numeric_limits::max() < r) throw_from_string_out_of_range(func); +#endif return static_cast(r); } @@ -133,8 +135,10 @@ { // Use long as no Stantard string to integer exists. long r = as_integer_helper( func, s, idx, base, wcstol ); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (r < numeric_limits::min() || numeric_limits::max() < r) throw_from_string_out_of_range(func); +#endif return static_cast(r); } Index: include/istream === --- include/istream +++ include/istream @@ -711,6 +711,7 @@ ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); +#if __SIZEOF_INT__ != __SIZEOF_LONG__ if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; @@ -723,6 +724,9 @@ } else __n = static_cast(__temp); +#else +__n = static_cast(__temp); +#endif this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316249 - [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once
Author: george.karpenkov Date: Fri Oct 20 16:29:59 2017 New Revision: 316249 URL: http://llvm.org/viewvc/llvm-project?rev=316249&view=rev Log: [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once Explicitly not supporting functor objects. Differential Revision: https://reviews.llvm.org/D39031 Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/test/Analysis/call_once.cpp Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=316249&r1=316248&r2=316249&view=diff == --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original) +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Fri Oct 20 16:29:59 2017 @@ -264,11 +264,8 @@ static CallExpr *create_call_once_funcpt static CallExpr *create_call_once_lambda_call(ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, - QualType CallbackType, + CXXRecordDecl *CallbackDecl, ArrayRef CallArgs) { - - CXXRecordDecl *CallbackDecl = CallbackType->getAsCXXRecordDecl(); - assert(CallbackDecl != nullptr); assert(CallbackDecl->isLambda()); FunctionDecl *callOperatorDecl = CallbackDecl->getLambdaCallOperator(); @@ -319,6 +316,9 @@ static Stmt *create_call_once(ASTContext const ParmVarDecl *Flag = D->getParamDecl(0); const ParmVarDecl *Callback = D->getParamDecl(1); QualType CallbackType = Callback->getType().getNonReferenceType(); + + // Nullable pointer, non-null iff function is a CXXRecordDecl. + CXXRecordDecl *CallbackRecordDecl = CallbackType->getAsCXXRecordDecl(); QualType FlagType = Flag->getType().getNonReferenceType(); auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl()); @@ -348,28 +348,58 @@ static Stmt *create_call_once(ASTContext return nullptr; } - bool isLambdaCall = CallbackType->getAsCXXRecordDecl() && - CallbackType->getAsCXXRecordDecl()->isLambda(); + bool isLambdaCall = CallbackRecordDecl && CallbackRecordDecl->isLambda(); + if (CallbackRecordDecl && !isLambdaCall) { +DEBUG(llvm::dbgs() << "Not supported: synthesizing body for functors when " + << "body farming std::call_once, ignoring the call."); +return nullptr; + } SmallVector CallArgs; + const FunctionProtoType *CallbackFunctionType; + if (isLambdaCall) { - if (isLambdaCall) // Lambda requires callback itself inserted as a first parameter. CallArgs.push_back( M.makeDeclRefExpr(Callback, /* RefersToEnclosingVariableOrCapture= */ true)); +CallbackFunctionType = CallbackRecordDecl->getLambdaCallOperator() + ->getType() + ->getAs(); + } else { +CallbackFunctionType = +CallbackType->getPointeeType()->getAs(); + } - // All arguments past first two ones are passed to the callback. - for (unsigned int i = 2; i < D->getNumParams(); i++) -CallArgs.push_back( -M.makeLvalueToRvalue(D->getParamDecl(i), - /* RefersToEnclosingVariableOrCapture= */ false)); + if (!CallbackFunctionType) +return nullptr; + + // First two arguments are used for the flag and for the callback. + if (D->getNumParams() != CallbackFunctionType->getNumParams() + 2) { +DEBUG(llvm::dbgs() << "Number of params of the callback does not match " + << "the number of params passed to std::call_once, " + << "ignoring the call"); +return nullptr; + } + + // All arguments past first two ones are passed to the callback, + // and we turn lvalues into rvalues if the argument is not passed by + // reference. + for (unsigned int ParamIdx = 2; ParamIdx < D->getNumParams(); ParamIdx++) { +const ParmVarDecl *PDecl = D->getParamDecl(ParamIdx); +Expr *ParamExpr = M.makeDeclRefExpr(PDecl); +if (!CallbackFunctionType->getParamType(ParamIdx - 2)->isReferenceType()) { + QualType PTy = PDecl->getType().getNonReferenceType(); + ParamExpr = M.makeLvalueToRvalue(ParamExpr, PTy); +} +CallArgs.push_back(ParamExpr); + } CallExpr *CallbackCall; if (isLambdaCall) { -CallbackCall = -create_call_once_lambda_call(C, M, Callback, CallbackType, CallArgs); +CallbackCall = create_call_once_lambda_call(C, M, Callback, +CallbackRecordDecl, CallArgs); } else { // Function pointer case. Modified: cfe/trunk/test/Analysis/call_once.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=316249&r1=316248&r2=316249&view=diff == --- cfe/trunk/test/Analysis/call_once
[PATCH] D39031: [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once
This revision was automatically updated to reflect the committed changes. Closed by commit rL316249: [Analyzer] Correctly handle parameters passed by reference when bodyfarming std… (authored by george.karpenkov). Changed prior to commit: https://reviews.llvm.org/D39031?vs=119415&id=119724#toc Repository: rL LLVM https://reviews.llvm.org/D39031 Files: cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/test/Analysis/call_once.cpp Index: cfe/trunk/test/Analysis/call_once.cpp === --- cfe/trunk/test/Analysis/call_once.cpp +++ cfe/trunk/test/Analysis/call_once.cpp @@ -249,3 +249,44 @@ void test_no_segfault_on_different_impl() { std::call_once(g, false); // no-warning } + +void test_lambda_refcapture() { + static std::once_flag flag; + int a = 6; + std::call_once(flag, [&](int &a) { a = 42; }, a); + clang_analyzer_eval(a == 42); // expected-warning{{TRUE}} +} + +void test_lambda_refcapture2() { + static std::once_flag flag; + int a = 6; + std::call_once(flag, [=](int &a) { a = 42; }, a); + clang_analyzer_eval(a == 42); // expected-warning{{TRUE}} +} + +void test_lambda_fail_refcapture() { + static std::once_flag flag; + int a = 6; + std::call_once(flag, [=](int a) { a = 42; }, a); + clang_analyzer_eval(a == 42); // expected-warning{{FALSE}} +} + +void mutator(int ¶m) { + param = 42; +} +void test_reftypes_funcptr() { + static std::once_flag flag; + int a = 6; + std::call_once(flag, &mutator, a); + clang_analyzer_eval(a == 42); // expected-warning{{TRUE}} +} + +void fail_mutator(int param) { + param = 42; +} +void test_mutator_noref() { + static std::once_flag flag; + int a = 6; + std::call_once(flag, &fail_mutator, a); + clang_analyzer_eval(a == 42); // expected-warning{{FALSE}} +} Index: cfe/trunk/lib/Analysis/BodyFarm.cpp === --- cfe/trunk/lib/Analysis/BodyFarm.cpp +++ cfe/trunk/lib/Analysis/BodyFarm.cpp @@ -264,11 +264,8 @@ static CallExpr *create_call_once_lambda_call(ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, - QualType CallbackType, + CXXRecordDecl *CallbackDecl, ArrayRef CallArgs) { - - CXXRecordDecl *CallbackDecl = CallbackType->getAsCXXRecordDecl(); - assert(CallbackDecl != nullptr); assert(CallbackDecl->isLambda()); FunctionDecl *callOperatorDecl = CallbackDecl->getLambdaCallOperator(); @@ -319,6 +316,9 @@ const ParmVarDecl *Flag = D->getParamDecl(0); const ParmVarDecl *Callback = D->getParamDecl(1); QualType CallbackType = Callback->getType().getNonReferenceType(); + + // Nullable pointer, non-null iff function is a CXXRecordDecl. + CXXRecordDecl *CallbackRecordDecl = CallbackType->getAsCXXRecordDecl(); QualType FlagType = Flag->getType().getNonReferenceType(); auto *FlagRecordDecl = dyn_cast_or_null(FlagType->getAsTagDecl()); @@ -348,28 +348,58 @@ return nullptr; } - bool isLambdaCall = CallbackType->getAsCXXRecordDecl() && - CallbackType->getAsCXXRecordDecl()->isLambda(); + bool isLambdaCall = CallbackRecordDecl && CallbackRecordDecl->isLambda(); + if (CallbackRecordDecl && !isLambdaCall) { +DEBUG(llvm::dbgs() << "Not supported: synthesizing body for functors when " + << "body farming std::call_once, ignoring the call."); +return nullptr; + } SmallVector CallArgs; + const FunctionProtoType *CallbackFunctionType; + if (isLambdaCall) { - if (isLambdaCall) // Lambda requires callback itself inserted as a first parameter. CallArgs.push_back( M.makeDeclRefExpr(Callback, /* RefersToEnclosingVariableOrCapture= */ true)); +CallbackFunctionType = CallbackRecordDecl->getLambdaCallOperator() + ->getType() + ->getAs(); + } else { +CallbackFunctionType = +CallbackType->getPointeeType()->getAs(); + } - // All arguments past first two ones are passed to the callback. - for (unsigned int i = 2; i < D->getNumParams(); i++) -CallArgs.push_back( -M.makeLvalueToRvalue(D->getParamDecl(i), - /* RefersToEnclosingVariableOrCapture= */ false)); + if (!CallbackFunctionType) +return nullptr; + + // First two arguments are used for the flag and for the callback. + if (D->getNumParams() != CallbackFunctionType->getNumParams() + 2) { +DEBUG(llvm::dbgs() << "Number of params of the callback does not match " + << "the number of params passed to std::call_once, " + << "ignoring the call"); +return nullptr; + } + + // All arguments past first two ones are passed to the callback, + // and we turn lvalues into rvalues if the argument is not passed by
r316250 - [CodeGen] add tests for __builtin_sqrt*; NFC
Author: spatel Date: Fri Oct 20 16:32:41 2017 New Revision: 316250 URL: http://llvm.org/viewvc/llvm-project?rev=316250&view=rev Log: [CodeGen] add tests for __builtin_sqrt*; NFC I don't know if this is correct, but this is what we currently do. More discussion in PR27108 and PR27435 and D27618. Modified: cfe/trunk/test/CodeGen/builtins.c Modified: cfe/trunk/test/CodeGen/builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=316250&r1=316249&r2=316250&view=diff == --- cfe/trunk/test/CodeGen/builtins.c (original) +++ cfe/trunk/test/CodeGen/builtins.c Fri Oct 20 16:32:41 2017 @@ -317,6 +317,15 @@ void test_float_builtin_ops(float F, dou resld = __builtin_floorl(LD); // CHECK: call x86_fp80 @llvm.floor.f80 + resf = __builtin_sqrtf(F); + // CHECK: call float @sqrtf( + + resd = __builtin_sqrt(D); + // CHECK: call double @sqrt( + + resld = __builtin_sqrtl(LD); + // CHECK: call x86_fp80 @sqrtl( + resf = __builtin_truncf(F); // CHECK: call float @llvm.trunc.f32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
alexfh added a comment. Apart from all other comments, I think, this check would better be placed under bugprone/. Repository: rL LLVM https://reviews.llvm.org/D39121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39156: [libunwind] Make HIDDEN_DIRECTIVE a function-like macro. NFCI.
mstorsjo created this revision. This avoids a hack for making it a no-op for windows. Also explicitly check for `_WIN32` instead of asduming it. https://reviews.llvm.org/D39156 Files: src/assembly.h Index: src/assembly.h === --- src/assembly.h +++ src/assembly.h @@ -24,27 +24,14 @@ #define SEPARATOR ; #endif -#if defined(__APPLE__) -#define HIDDEN_DIRECTIVE .private_extern -#elif defined(_WIN32) -// In the COFF object file format, there's no attributes for a global, -// non-static symbol to make it somehow hidden. So on windows, we don't -// want to set this at all. To avoid conditionals in -// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already -// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the -// duplicate .globl directives are harmless). -#define HIDDEN_DIRECTIVE .globl -#else -#define HIDDEN_DIRECTIVE .hidden -#endif - #define GLUE2(a, b) a ## b #define GLUE(a, b) GLUE2(a, b) #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) #if defined(__APPLE__) #define SYMBOL_IS_FUNC(name) +#define HIDDEN_SYMBOL(name) .private_extern name #define NO_EXEC_STACK_DIRECTIVE #elif defined(__ELF__) @@ -54,24 +41,30 @@ #else #define SYMBOL_IS_FUNC(name) .type name,@function #endif +#define HIDDEN_SYMBOL(name) .hidden name #if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ defined(__linux__) #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits #else #define NO_EXEC_STACK_DIRECTIVE #endif -#else +#elif defined(_WIN32) #define SYMBOL_IS_FUNC(name) \ .def name SEPARATOR \ .scl 2 SEPARATOR \ .type 32 SEPARATOR \ .endef +#define HIDDEN_SYMBOL(name) #define NO_EXEC_STACK_DIRECTIVE +#else + +#error Unsupported target + #endif #define DEFINE_LIBUNWIND_FUNCTION(name) \ @@ -81,7 +74,7 @@ #define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \ .globl SYMBOL_NAME(name) SEPARATOR \ - HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR\ + HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ SYMBOL_NAME(name): Index: src/assembly.h === --- src/assembly.h +++ src/assembly.h @@ -24,27 +24,14 @@ #define SEPARATOR ; #endif -#if defined(__APPLE__) -#define HIDDEN_DIRECTIVE .private_extern -#elif defined(_WIN32) -// In the COFF object file format, there's no attributes for a global, -// non-static symbol to make it somehow hidden. So on windows, we don't -// want to set this at all. To avoid conditionals in -// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already -// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the -// duplicate .globl directives are harmless). -#define HIDDEN_DIRECTIVE .globl -#else -#define HIDDEN_DIRECTIVE .hidden -#endif - #define GLUE2(a, b) a ## b #define GLUE(a, b) GLUE2(a, b) #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) #if defined(__APPLE__) #define SYMBOL_IS_FUNC(name) +#define HIDDEN_SYMBOL(name) .private_extern name #define NO_EXEC_STACK_DIRECTIVE #elif defined(__ELF__) @@ -54,24 +41,30 @@ #else #define SYMBOL_IS_FUNC(name) .type name,@function #endif +#define HIDDEN_SYMBOL(name) .hidden name #if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ defined(__linux__) #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits #else #define NO_EXEC_STACK_DIRECTIVE #endif -#else +#elif defined(_WIN32) #define SYMBOL_IS_FUNC(name) \ .def name SEPARATOR \ .scl 2 SEPARATOR \ .type 32 SEPARATOR \ .endef +#define HIDDEN_SYMBOL(name) #define NO_EXEC_STACK_DIRECTIVE +#else + +#error Unsupported target + #endif #define DEFINE_LIBUNWIND_FUNCTION(name) \ @@ -81,7 +74,7 @@ #define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \ .globl SYMBOL_NAME(name) SEPARATOR \ - HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR\ + HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ SYMBOL_NAME(name): ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits