[PATCH] D37254: [Sema] Disallow assigning record lvalues with nested const-qualified fields.
bjope added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5888 def note_typecheck_assign_const : Note< "%select{" Shouldn't there be one more entry here as well? (see comment about updating both err_typecheck_assign_const and note_typecheck_assign_const when adding things to the enum at line 10181). If I understand it correctly you never print notes for the new NestedConstMember, so there isn't really a need for a fifth entry in the select today. But if someone adds new enum values later (putting them after NestedContMember) then it might be nice if the size of this select matches with the old size of the enum. Comment at: lib/Sema/SemaExpr.cpp:10329 + S.Diag(Field->getLocation(), diag::note_typecheck_assign_const) + << ConstMember << false /*non-static*/ << Field + << Field->getType() << Field->getSourceRange(); If adding a new entry to note_typecheck_assign_const (identical to the ConstMember entry) then you can use NestedConstMember here. It would make it possible to change the string for NestedConstMember notes without also changing all ConstMember notes. Now it kind of looks like an error that the error diagnostic is for a NestedConstMember, but the note is about a ConstMember. That might confuse someone, since it looks like a typo unless you know what is going on here. https://reviews.llvm.org/D37254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312701 - [mips] Replace Triple::Environment check by the isGNUEnvironment() call. NFC
Author: atanasyan Date: Wed Sep 6 23:05:06 2017 New Revision: 312701 URL: http://llvm.org/viewvc/llvm-project?rev=312701&view=rev Log: [mips] Replace Triple::Environment check by the isGNUEnvironment() call. NFC Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=312701&r1=312700&r2=312701&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Wed Sep 6 23:05:06 2017 @@ -35,7 +35,7 @@ void mips::getMipsCPUAndABI(const ArgLis // MIPS32r6 is the default for mips(el)?-img-linux-gnu and MIPS64r6 is the // default for mips64(el)?-img-linux-gnu. if (Triple.getVendor() == llvm::Triple::ImaginationTechnologies && - Triple.getEnvironment() == llvm::Triple::GNU) { + Triple.isGNUEnvironment()) { DefMips32CPU = "mips32r6"; DefMips64CPU = "mips64r6"; } Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=312701&r1=312700&r2=312701&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Sep 6 23:05:06 2017 @@ -1311,12 +1311,12 @@ bool clang::driver::findMIPSMultilibs(co if (TargetTriple.getVendor() == llvm::Triple::MipsTechnologies && TargetTriple.getOS() == llvm::Triple::Linux && - TargetTriple.getEnvironment() == llvm::Triple::GNU) + TargetTriple.isGNUEnvironment()) return findMipsMtiMultilibs(Flags, NonExistent, Result); if (TargetTriple.getVendor() == llvm::Triple::ImaginationTechnologies && TargetTriple.getOS() == llvm::Triple::Linux && - TargetTriple.getEnvironment() == llvm::Triple::GNU) + TargetTriple.isGNUEnvironment()) return findMipsImgMultilibs(Flags, NonExistent, Result); if (findMipsCsMultilibs(Flags, NonExistent, Result)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312700 - Fix off-by-one error in block mangling.
Author: rsmith Date: Wed Sep 6 22:41:24 2017 New Revision: 312700 URL: http://llvm.org/viewvc/llvm-project?rev=312700&view=rev Log: Fix off-by-one error in block mangling. This restores the ABI prior to r214699. Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=312700&r1=312699&r2=312700&view=diff == --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Sep 6 22:41:24 2017 @@ -1669,6 +1669,10 @@ void CXXNameMangler::mangleUnqualifiedBl // the symbol in question isn't externally visible. if (!Number) Number = Context.getBlockId(Block, false); + else { +// Stored mangling numbers are 1-based. +--Number; + } Out << "Ub"; if (Number > 0) Out << Number - 1; Modified: cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm?rev=312700&r1=312699&r2=312700&view=diff == --- cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm (original) +++ cfe/trunk/test/CodeGenObjCXX/mangle-blocks.mm Wed Sep 6 22:41:24 2017 @@ -1,8 +1,9 @@ // RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s -// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub0_E1k = linkonce_odr global i32 0 -// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb0_E1i = linkonce_odr global i32 0 -// CHECK: @_ZZ26externally_visible_statics1S1xMUb0_E1j = linkonce_odr global i32 0 +// CHECK-DAG: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub_E1k = linkonce_odr global i32 0 +// CHECK-DAG: @_ZZZN26externally_visible_statics10inlinefuncEvEUb_E1i = linkonce_odr global i32 0 +// CHECK-DAG: @_ZZZN26externally_visible_statics10inlinefuncEvEUb0_E1j = linkonce_odr global i32 0 +// CHECK-DAG: @_ZZ26externally_visible_statics1S1xMUb_E1j = linkonce_odr global i32 0 int f(); @@ -68,6 +69,9 @@ namespace externally_visible_statics { ^{ static int i = f(); }(); +^{ + static int j = f(); +}(); } struct S { int x = ^{ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312696 - [modules ts] Add test for [basic.link]p3.
Author: rsmith Date: Wed Sep 6 22:29:39 2017 New Revision: 312696 URL: http://llvm.org/viewvc/llvm-project?rev=312696&view=rev Log: [modules ts] Add test for [basic.link]p3. Added: cfe/trunk/test/CXX/modules-ts/basic/basic.link/p3.cppm Added: cfe/trunk/test/CXX/modules-ts/basic/basic.link/p3.cppm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.link/p3.cppm?rev=312696&view=auto == --- cfe/trunk/test/CXX/modules-ts/basic/basic.link/p3.cppm (added) +++ cfe/trunk/test/CXX/modules-ts/basic/basic.link/p3.cppm Wed Sep 6 22:29:39 2017 @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fmodules-ts %s -emit-module-interface -o %t +// RUN: %clang_cc1 -fmodules-ts -x pcm %t -emit-llvm -o - | FileCheck %s + +export module M; + +// CHECK-DAG: @_ZW1ME1a = constant i32 1 +const int a = 1; +// CHECK-DAG: @b = constant i32 2 +export const int b = 2; + +export int f() { return a + b; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37530: [MinGW] Allow overriding which version of msvcrt to link to
mstorsjo added a comment. In https://reviews.llvm.org/D37530#862644, @rnk wrote: > What do you think of letting people spell this as `-lmsvcrt120`? We could > forward those options and suppress our implicit addition of `-lmsvcrt` if we > see `-lmsvcr*` anywhere. That might work and would probably be sensible. Does the argument order matter, if the `-lmsvcr120` is listed at the end or at the same spot as `-lmsvcrt` were to be included? Another complicating matter is that the pattern shouldn't just be `-lmsvcr*`, it should also match `-lucrtbase` since that's the name of the new Win10 CRT DLL (that I've just posted patches for mingw to support). And not sure if there later would be another import library for the case where one would link to `api-ms-win-crt*-dll` instead (which is mostly similar `ucrtbase.dll` but split up over a number of smaller files). Comment at: lib/Driver/ToolChains/MinGW.cpp:161 if (TC.getArch() == llvm::Triple::x86) -CmdArgs.push_back("_DllMainCRTStartup@12"); +CmdArgs.push_back("DllMainCRTStartup@12"); else rnk wrote: > I guess ld.bfd for COFF does some wacky name mangling. =/ Oh, sorry - this was unrelated to this patch and slip through accidentally. (It turned out to be an issue with the lld mingw frontend, not with clang itself.) https://reviews.llvm.org/D37530 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r312693 - Add even more string_view tests. These found some bugs in the default parameter value for rfind/find_last_of/find_last_not_of
Author: marshall Date: Wed Sep 6 21:19:32 2017 New Revision: 312693 URL: http://llvm.org/viewvc/llvm-project?rev=312693&view=rev Log: Add even more string_view tests. These found some bugs in the default parameter value for rfind/find_last_of/find_last_not_of Added: libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp Modified: libcxx/trunk/include/string Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=312693&r1=312692&r2=312693&view=diff == --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Wed Sep 6 21:19:32 2017 @@ -259,7 +259,7 @@ public: size_type find(value_type c, size_type pos = 0) const noexcept; size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; -size_type ffind(basic_string_view sv, size_type pos = 0) const noexcept; +size_type rfind(basic_string_view sv, size_type pos = npos) const noexcept; size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; size_type rfind(const value_type* s, size_type pos = npos) const noexcept; size_type rfind(value_type c, size_type pos = npos) const noexcept; @@ -271,7 +271,7 @@ public: size_type find_first_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; -size_type find_last_of(basic_string_view sv, size_type pos = 0) const noexcept; +size_type find_last_of(basic_string_view sv, size_type pos = npos) const noexcept; size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_of(value_type c, size_type pos = npos) const noexcept; @@ -283,7 +283,7 @@ public: size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; -size_type find_last_not_of(basic_string_view sv, size_type pos = 0) const noexcept; +size_type find_last_not_of(basic_string_view sv, size_type pos = npos) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; @@ -1147,7 +1147,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY -size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; +size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; @@ -1166,7 +1166,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY -size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; +size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; @@ -1186,7 +1186,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY -size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT; +size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT; size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; _LIBCPP_INLINE_VISIBIL
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
minseong.kim updated this revision to Diff 114115. minseong.kim edited the summary of this revision. minseong.kim added a reviewer: hintonda. minseong.kim removed a subscriber: hintonda. minseong.kim added a comment. I have updated the diff. https://reviews.llvm.org/D35533 Files: lib/Basic/CMakeLists.txt Index: lib/Basic/CMakeLists.txt === --- lib/Basic/CMakeLists.txt +++ lib/Basic/CMakeLists.txt @@ -4,40 +4,6 @@ Support ) -# Figure out if we can track VC revisions. -function(find_first_existing_file out_var) - foreach(file ${ARGN}) -if(EXISTS "${file}") - set(${out_var} "${file}" PARENT_SCOPE) - return() -endif() - endforeach() -endfunction() - -macro(find_first_existing_vc_file out_var path) - set(git_path "${path}/.git") - - # Normally '.git' is a directory that contains a 'logs/HEAD' file that - # is updated as modifications are made to the repository. In case the - # repository is a Git submodule, '.git' is a file that contains text that - # indicates where the repository's Git directory exists. - if (EXISTS "${git_path}" AND NOT IS_DIRECTORY "${git_path}") -FILE(READ "${git_path}" file_contents) -if("${file_contents}" MATCHES "^gitdir: ([^\n]+)") - # '.git' is indeed a link to the submodule's Git directory. - # Use the path to that Git directory. - set(git_path "${path}/${CMAKE_MATCH_1}") -endif() - endif() - - find_first_existing_file(${out_var} -"${git_path}/logs/HEAD" # Git or Git submodule -"${path}/.svn/wc.db" # SVN 1.7 -"${path}/.svn/entries" # SVN 1.6 -"${git_path}/HEAD" # Repo -) -endmacro() - find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}") Index: lib/Basic/CMakeLists.txt === --- lib/Basic/CMakeLists.txt +++ lib/Basic/CMakeLists.txt @@ -4,40 +4,6 @@ Support ) -# Figure out if we can track VC revisions. -function(find_first_existing_file out_var) - foreach(file ${ARGN}) -if(EXISTS "${file}") - set(${out_var} "${file}" PARENT_SCOPE) - return() -endif() - endforeach() -endfunction() - -macro(find_first_existing_vc_file out_var path) - set(git_path "${path}/.git") - - # Normally '.git' is a directory that contains a 'logs/HEAD' file that - # is updated as modifications are made to the repository. In case the - # repository is a Git submodule, '.git' is a file that contains text that - # indicates where the repository's Git directory exists. - if (EXISTS "${git_path}" AND NOT IS_DIRECTORY "${git_path}") -FILE(READ "${git_path}" file_contents) -if("${file_contents}" MATCHES "^gitdir: ([^\n]+)") - # '.git' is indeed a link to the submodule's Git directory. - # Use the path to that Git directory. - set(git_path "${path}/${CMAKE_MATCH_1}") -endif() - endif() - - find_first_existing_file(${out_var} -"${git_path}/logs/HEAD" # Git or Git submodule -"${path}/.svn/wc.db" # SVN 1.7 -"${path}/.svn/entries" # SVN 1.6 -"${git_path}/HEAD" # Repo -) -endmacro() - find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r312691 - Another missing string_view test
Author: marshall Date: Wed Sep 6 20:03:48 2017 New Revision: 312691 URL: http://llvm.org/viewvc/llvm-project?rev=312691&view=rev Log: Another missing string_view test Added: libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp Added: libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp?rev=312691&view=auto == --- libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp (added) +++ libcxx/trunk/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp Wed Sep 6 20:03:48 2017 @@ -0,0 +1,74 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// basic_string& operator=(basic_string_view sv); + +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +template +void +test(S s1, SV sv) +{ +typedef typename S::traits_type T; +s1 = sv; +LIBCPP_ASSERT(s1.__invariants()); +assert(s1.size() == sv.size()); +assert(T::compare(s1.data(), sv.data(), s1.size()) == 0); +assert(s1.capacity() >= s1.size()); +} + +int main() +{ +{ +typedef std::string S; +typedef std::string_view SV; +test(S(), SV("")); +test(S("1"), SV("")); +test(S(), SV("1")); +test(S("1"), SV("2")); +test(S("1"), SV("2")); + +test(S(), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +test(S("123456789"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +} +#if TEST_STD_VER >= 11 +{ +typedef std::basic_string, min_allocator> S; +typedef std::string_view SV; +test(S(), SV("")); +test(S("1"), SV("")); +test(S(), SV("1")); +test(S("1"), SV("2")); +test(S("1"), SV("2")); + +test(S(), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +test(S("123456789"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +} +#endif +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r312690 - Add more string_view tests
Author: marshall Date: Wed Sep 6 19:46:09 2017 New Revision: 312690 URL: http://llvm.org/viewvc/llvm-project?rev=312690&view=rev Log: Add more string_view tests Added: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp Added: libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp?rev=312690&view=auto == --- libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp (added) +++ libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp Wed Sep 6 19:46:09 2017 @@ -0,0 +1,239 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// basic_string& +// insert(size_type pos, string_view sv); + +#include +#include +#include + +#include "test_macros.h" +#include "min_allocator.h" + +template +void +test(S s, typename S::size_type pos, SV sv, S expected) +{ +const typename S::size_type old_size = s.size(); +S s0 = s; +if (pos <= old_size) +{ +s.insert(pos, sv); +LIBCPP_ASSERT(s.__invariants()); +assert(s == expected); +} +#ifndef TEST_HAS_NO_EXCEPTIONS +else +{ +try +{ +s.insert(pos, sv); +assert(false); +} +catch (std::out_of_range&) +{ +assert(pos > old_size); +assert(s == s0); +} +} +#endif +} + +int main() +{ +{ +typedef std::string S; +typedef std::string_view SV; +test(S(""), 0, SV(""), S("")); +test(S(""), 0, SV("12345"), S("12345")); +test(S(""), 0, SV("1234567890"), S("1234567890")); +test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890")); +test(S(""), 1, SV(""), S("can't happen")); +test(S(""), 1, SV("12345"), S("can't happen")); +test(S(""), 1, SV("1234567890"), S("can't happen")); +test(S(""), 1, SV("12345678901234567890"), S("can't happen")); +test(S("abcde"), 0, SV(""), S("abcde")); +test(S("abcde"), 0, SV("12345"), S("12345abcde")); +test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde")); +test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde")); +test(S("abcde"), 1, SV(""), S("abcde")); +test(S("abcde"), 1, SV("12345"), S("a12345bcde")); +test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde")); +test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde")); +test(S("abcde"), 2, SV(""), S("abcde")); +test(S("abcde"), 2, SV("12345"), S("ab12345cde")); +test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde")); +test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde")); +test(S("abcde"), 4, SV(""), S("abcde")); +test(S("abcde"), 4, SV("12345"), S("abcd12345e")); +test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e")); +test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e")); +test(S("abcde"), 5, SV(""), S("abcde")); +test(S("abcde"), 5, SV("12345"), S("abcde12345")); +test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890")); +test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890")); +test(S("abcde"), 6, SV(""), S("can't happen")); +test(S("abcde"), 6, SV("12345"), S("can't happen")); +test(S("abcde"), 6, SV("1234567890"), S("can't happen")); +test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen")); +test(S("abcdefghij"), 0, SV(""), S("abcdefghij")); +test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij")); +test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij")); +test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij")); +test(S("abcdefghij"), 1, SV(""), S("abcdefghij")); +test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij")); +test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij")); +test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij")); +test(S("abcdefghij"), 5, SV(""), S("abcdefghij")); +test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij")); +test(S("abcdefghij"), 5, SV("1234567890")
[PATCH] D37548: [CUDA] When compilation fails, print the compilation mode.
jlebar created this revision. Herald added a subscriber: sanjoy. That is, instead of "1 error generated", we now say "1 error generated when compiling for sm_35". This (partially) solves a usability foogtun wherein e.g. users call a function that's only defined on sm_60 when compiling for sm_35, and they get an unhelpful error message. https://reviews.llvm.org/D37548 Files: clang/lib/Frontend/CompilerInstance.cpp clang/test/SemaCUDA/error-includes-mode.cu Index: clang/test/SemaCUDA/error-includes-mode.cu === --- /dev/null +++ clang/test/SemaCUDA/error-includes-mode.cu @@ -0,0 +1,7 @@ +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix HOST %s +// RUN: not %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 \ +// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SM35 %s + +// HOST: 1 error generated when compiling for host +// SM35: 1 error generated when compiling for sm_35 +error; Index: clang/lib/Frontend/CompilerInstance.cpp === --- clang/lib/Frontend/CompilerInstance.cpp +++ clang/lib/Frontend/CompilerInstance.cpp @@ -1003,8 +1003,17 @@ OS << " and "; if (NumErrors) OS << NumErrors << " error" << (NumErrors == 1 ? "" : "s"); -if (NumWarnings || NumErrors) - OS << " generated.\n"; +if (NumWarnings || NumErrors) { + OS << " generated"; + if (getLangOpts().CUDA) { +if (!getLangOpts().CUDAIsDevice) { + OS << " when compiling for host"; +} else { + OS << " when compiling for " << getTargetOpts().CPU; +} + } + OS << ".\n"; +} } if (getFrontendOpts().ShowStats) { Index: clang/test/SemaCUDA/error-includes-mode.cu === --- /dev/null +++ clang/test/SemaCUDA/error-includes-mode.cu @@ -0,0 +1,7 @@ +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck --check-prefix HOST %s +// RUN: not %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_35 \ +// RUN: -fcuda-is-device -fsyntax-only %s 2>&1 | FileCheck --check-prefix SM35 %s + +// HOST: 1 error generated when compiling for host +// SM35: 1 error generated when compiling for sm_35 +error; Index: clang/lib/Frontend/CompilerInstance.cpp === --- clang/lib/Frontend/CompilerInstance.cpp +++ clang/lib/Frontend/CompilerInstance.cpp @@ -1003,8 +1003,17 @@ OS << " and "; if (NumErrors) OS << NumErrors << " error" << (NumErrors == 1 ? "" : "s"); -if (NumWarnings || NumErrors) - OS << " generated.\n"; +if (NumWarnings || NumErrors) { + OS << " generated"; + if (getLangOpts().CUDA) { +if (!getLangOpts().CUDAIsDevice) { + OS << " when compiling for host"; +} else { + OS << " when compiling for " << getTargetOpts().CPU; +} + } + OS << ".\n"; +} } if (getFrontendOpts().ShowStats) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36806: Switch to cantFail(), since it does the same assertion.
srhines added a comment. Ping. https://reviews.llvm.org/D36806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312684 - [modules ts] Ensure that module linkage variables are always emitted and always have their name mangled.
Author: rsmith Date: Wed Sep 6 17:55:55 2017 New Revision: 312684 URL: http://llvm.org/viewvc/llvm-project?rev=312684&view=rev Log: [modules ts] Ensure that module linkage variables are always emitted and always have their name mangled. Modified: cfe/trunk/lib/AST/Mangle.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm Modified: cfe/trunk/lib/AST/Mangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=312684&r1=312683&r2=312684&view=diff == --- cfe/trunk/lib/AST/Mangle.cpp (original) +++ cfe/trunk/lib/AST/Mangle.cpp Wed Sep 6 17:55:55 2017 @@ -103,6 +103,11 @@ bool MangleContext::shouldMangleDeclName if (CC != CCM_Other) return true; + // If the declaration has an owning module for linkage purposes that needs to + // be mangled, we must mangle its name. + if (!D->hasExternalFormalLinkage() && D->getOwningModuleForLinkage()) +return true; + // In C, functions with no attributes never need to be mangled. Fastpath them. if (!getASTContext().getLangOpts().CPlusPlus && !D->hasAttrs()) return false; Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=312684&r1=312683&r2=312684&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Sep 6 17:55:55 2017 @@ -1591,11 +1591,8 @@ void ASTDeclReader::ReadCXXDefinitionDat Data.ODRHash = Record.readInt(); Data.HasODRHash = true; - if (Record.readInt()) { -Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile - ? ExternalASTSource::EK_Never - : ExternalASTSource::EK_Always; - } + if (Record.readInt()) +Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile; Data.NumBases = Record.readInt(); if (Data.NumBases) @@ -2573,11 +2570,14 @@ static bool isConsumerInterestedIn(ASTCo // An ObjCMethodDecl is never considered as "interesting" because its // implementation container always is. - // An ImportDecl or VarDecl imported from a module will get emitted when - // we import the relevant module. - if ((isa(D) || isa(D)) && D->getImportedOwningModule() && - Ctx.DeclMustBeEmitted(D)) -return false; + // An ImportDecl or VarDecl imported from a module map module will get + // emitted when we import the relevant module. + if (isa(D) || isa(D)) { +auto *M = D->getImportedOwningModule(); +if (M && M->Kind == Module::ModuleMapModule && +Ctx.DeclMustBeEmitted(D)) + return false; + } if (isa(D) || isa(D) || Modified: cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp?rev=312684&r1=312683&r2=312684&view=diff == --- cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp (original) +++ cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp Wed Sep 6 17:55:55 2017 @@ -6,9 +6,8 @@ // CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally global i32 0, // CHECK-DAG: @const_var_exported = available_externally constant i32 3, // -// FIXME: The module name should be mangled into all of these. -// CHECK-DAG: @extern_var_module_linkage = external global -// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global +// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global +// CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr global // CHECK-DAG: @_ZW6ModuleE25static_var_module_linkage = available_externally global i32 0, // CHECK-DAG: @_ZW6ModuleE24const_var_module_linkage = available_externally constant i32 3, Modified: cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm?rev=312684&r1=312683&r2=312684&view=diff == --- cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm (original) +++ cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm Wed Sep 6 17:55:55 2017 @@ -14,14 +14,17 @@ // CHECK-DAG: @_ZW6ModuleE19static_var_exported = global // CHECK-DAG: @const_var_exported = constant // -// FIXME: The module name should be mangled into all of these. -// CHECK-DAG: @extern_var_module_linkage = external global +// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global // FIXME: Should this be 'we
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
hintonda added a comment. In https://reviews.llvm.org/D35533#862852, @minseong.kim wrote: > @hintonda, Absolutely. Incorporating @modocache's module changes into the > version in AddLLVM.cmake would solve the current version display issue for > repo and do not affect the process of other version control systems (e.g. > git, git-svn, svn, and git submodule). I think we crossed, but yes, the version in AddLLVM.cmake handles everything correctly. So, I'd recommend removing these versions. https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37539: [CUDA] Add device overloads for non-placement new/delete.
This revision was automatically updated to reflect the committed changes. Closed by commit rL312681: [CUDA] Add device overloads for non-placement new/delete. (authored by jlebar). Changed prior to commit: https://reviews.llvm.org/D37539?vs=114104&id=114108#toc Repository: rL LLVM https://reviews.llvm.org/D37539 Files: cfe/trunk/lib/Headers/cuda_wrappers/new Index: cfe/trunk/lib/Headers/cuda_wrappers/new === --- cfe/trunk/lib/Headers/cuda_wrappers/new +++ cfe/trunk/lib/Headers/cuda_wrappers/new @@ -26,22 +26,71 @@ #include_next -// Device overrides for placement new and delete. #pragma push_macro("CUDA_NOEXCEPT") #if __cplusplus >= 201103L #define CUDA_NOEXCEPT noexcept #else #define CUDA_NOEXCEPT #endif +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { +size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { +::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ void operator delete(void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ void operator delete[](void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. __device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} __device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {} + #pragma pop_macro("CUDA_NOEXCEPT") #endif // include guard Index: cfe/trunk/lib/Headers/cuda_wrappers/new === --- cfe/trunk/lib/Headers/cuda_wrappers/new +++ cfe/trunk/lib/Headers/cuda_wrappers/new @@ -26,22 +26,71 @@ #include_next -// Device overrides for placement new and delete. #pragma push_macro("CUDA_NOEXCEPT") #if __cplusplus >= 201103L #define CUDA_NOEXCEPT noexcept #else #define CUDA_NOEXCEPT #endif +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { +size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { +::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ void operator delete(void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ void operator delete[](void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. __device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} __device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT
[PATCH] D37540: [CUDA] Tests for device-side overloads of non-placement new/delete.
This revision was automatically updated to reflect the committed changes. Closed by commit rL312682: [CUDA] Tests for device-side overloads of non-placement new/delete. (authored by jlebar). Changed prior to commit: https://reviews.llvm.org/D37540?vs=114094&id=114109#toc Repository: rL LLVM https://reviews.llvm.org/D37540 Files: test-suite/trunk/External/CUDA/CMakeLists.txt test-suite/trunk/External/CUDA/new.cu test-suite/trunk/External/CUDA/new.reference_output Index: test-suite/trunk/External/CUDA/CMakeLists.txt === --- test-suite/trunk/External/CUDA/CMakeLists.txt +++ test-suite/trunk/External/CUDA/CMakeLists.txt @@ -53,6 +53,7 @@ create_one_local_test(cmath cmath.cu) create_one_local_test(complex complex.cu) create_one_local_test(math_h math_h.cu) + create_one_local_test(new new.cu) create_one_local_test(empty empty.cu) create_one_local_test(printf printf.cu) create_one_local_test(future future.cu) Index: test-suite/trunk/External/CUDA/new.reference_output === --- test-suite/trunk/External/CUDA/new.reference_output +++ test-suite/trunk/External/CUDA/new.reference_output @@ -0,0 +1,2 @@ +Success! +exit 0 Index: test-suite/trunk/External/CUDA/new.cu === --- test-suite/trunk/External/CUDA/new.cu +++ test-suite/trunk/External/CUDA/new.cu @@ -0,0 +1,69 @@ +// Check that operator new and operator delete work. + +#include +#include +#include + +__device__ void global_new() { + void* x = ::operator new(42); + assert(x != NULL); + ::operator delete(x); + + x = ::operator new(42, std::nothrow); + assert(x != NULL); + ::operator delete(x, std::nothrow); + + x = ::operator new[](42); + assert(x != NULL); + ::operator delete[](x); + + x = ::operator new[](42, std::nothrow); + assert(x != NULL); + ::operator delete[](x, std::nothrow); +} + +__device__ void sized_delete() { +#if __cplusplus>= 201402L + void* x = ::operator new(42); + assert(x != NULL); + ::operator delete(x, 42); + + x = ::operator new[](42); + assert(x != NULL); + ::operator delete[](x, 42); +#endif +} + +__device__ void int_new() { + int* x = new int(); + assert(*x == 0); + delete x; +} + +struct Foo { + __device__ Foo() : x(42) {} + int x; +}; +__device__ void class_new() { + Foo* foo = new Foo(); + assert(foo->x == 42); + delete foo; +} + +__global__ void kernel() { + global_new(); + sized_delete(); + int_new(); + class_new(); +} + +int main() { + kernel<<<32, 32>>>(); + cudaError_t err = cudaDeviceSynchronize(); + if (err != cudaSuccess) { +printf("CUDA error %d\n", (int)err); +return 1; + } + printf("Success!\n"); + return 0; +} Index: test-suite/trunk/External/CUDA/CMakeLists.txt === --- test-suite/trunk/External/CUDA/CMakeLists.txt +++ test-suite/trunk/External/CUDA/CMakeLists.txt @@ -53,6 +53,7 @@ create_one_local_test(cmath cmath.cu) create_one_local_test(complex complex.cu) create_one_local_test(math_h math_h.cu) + create_one_local_test(new new.cu) create_one_local_test(empty empty.cu) create_one_local_test(printf printf.cu) create_one_local_test(future future.cu) Index: test-suite/trunk/External/CUDA/new.reference_output === --- test-suite/trunk/External/CUDA/new.reference_output +++ test-suite/trunk/External/CUDA/new.reference_output @@ -0,0 +1,2 @@ +Success! +exit 0 Index: test-suite/trunk/External/CUDA/new.cu === --- test-suite/trunk/External/CUDA/new.cu +++ test-suite/trunk/External/CUDA/new.cu @@ -0,0 +1,69 @@ +// Check that operator new and operator delete work. + +#include +#include +#include + +__device__ void global_new() { + void* x = ::operator new(42); + assert(x != NULL); + ::operator delete(x); + + x = ::operator new(42, std::nothrow); + assert(x != NULL); + ::operator delete(x, std::nothrow); + + x = ::operator new[](42); + assert(x != NULL); + ::operator delete[](x); + + x = ::operator new[](42, std::nothrow); + assert(x != NULL); + ::operator delete[](x, std::nothrow); +} + +__device__ void sized_delete() { +#if __cplusplus>= 201402L + void* x = ::operator new(42); + assert(x != NULL); + ::operator delete(x, 42); + + x = ::operator new[](42); + assert(x != NULL); + ::operator delete[](x, 42); +#endif +} + +__device__ void int_new() { + int* x = new int(); + assert(*x == 0); + delete x; +} + +struct Foo { + __device__ Foo() : x(42) {} + int x; +}; +__device__ void class_new() { + Foo* foo = new Foo(); + assert(foo->x == 42); + delete foo; +} + +__global__ void kernel() { + global_new(); + sized_delete(); + int_new(); + class_new(); +} + +int main() { + kernel<<<32, 32>>>(); + cudaError_t err = cudaDeviceSynchr
r312681 - [CUDA] Add device overloads for non-placement new/delete.
Author: jlebar Date: Wed Sep 6 17:37:20 2017 New Revision: 312681 URL: http://llvm.org/viewvc/llvm-project?rev=312681&view=rev Log: [CUDA] Add device overloads for non-placement new/delete. Summary: Tests have to live in the test-suite, and so will come in a separate patch. Fixes PR34360. Reviewers: tra Subscribers: llvm-commits, sanjoy Differential Revision: https://reviews.llvm.org/D37539 Modified: cfe/trunk/lib/Headers/cuda_wrappers/new Modified: cfe/trunk/lib/Headers/cuda_wrappers/new URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cuda_wrappers/new?rev=312681&r1=312680&r2=312681&view=diff == --- cfe/trunk/lib/Headers/cuda_wrappers/new (original) +++ cfe/trunk/lib/Headers/cuda_wrappers/new Wed Sep 6 17:37:20 2017 @@ -26,7 +26,6 @@ #include_next -// Device overrides for placement new and delete. #pragma push_macro("CUDA_NOEXCEPT") #if __cplusplus >= 201103L #define CUDA_NOEXCEPT noexcept @@ -34,6 +33,55 @@ #define CUDA_NOEXCEPT #endif +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { +size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { +::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ void operator delete(void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ void operator delete[](void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. __device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } @@ -42,6 +90,7 @@ __device__ inline void *operator new[](_ } __device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} __device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {} + #pragma pop_macro("CUDA_NOEXCEPT") #endif // include guard ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion planned changes to this revision. inglorion added a comment. rnk and I talked about a different approach. The idea is to explicitly emit locations in some cases (e.g. inside compound statements, the braces of for loops, ...), and otherwise emit locations only when emitting column info or emitting non-codeview debug info. That may lead to more elegant code. I'll give it a try later. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37539: [CUDA] Add device overloads for non-placement new/delete.
jlebar updated this revision to Diff 114104. jlebar marked an inline comment as done. jlebar added a comment. Address review comments. https://reviews.llvm.org/D37539 Files: clang/lib/Headers/cuda_wrappers/new Index: clang/lib/Headers/cuda_wrappers/new === --- clang/lib/Headers/cuda_wrappers/new +++ clang/lib/Headers/cuda_wrappers/new @@ -26,22 +26,71 @@ #include_next -// Device overrides for placement new and delete. #pragma push_macro("CUDA_NOEXCEPT") #if __cplusplus >= 201103L #define CUDA_NOEXCEPT noexcept #else #define CUDA_NOEXCEPT #endif +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { +size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { +::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ void operator delete(void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ void operator delete[](void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. __device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} __device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {} + #pragma pop_macro("CUDA_NOEXCEPT") #endif // include guard Index: clang/lib/Headers/cuda_wrappers/new === --- clang/lib/Headers/cuda_wrappers/new +++ clang/lib/Headers/cuda_wrappers/new @@ -26,22 +26,71 @@ #include_next -// Device overrides for placement new and delete. #pragma push_macro("CUDA_NOEXCEPT") #if __cplusplus >= 201103L #define CUDA_NOEXCEPT noexcept #else #define CUDA_NOEXCEPT #endif +// Device overrides for non-placement new and delete. +__device__ inline void *operator new(__SIZE_TYPE__ size) { + if (size == 0) { +size = 1; + } + return ::malloc(size); +} +__device__ inline void *operator new(__SIZE_TYPE__ size, + const std::nothrow_t &) CUDA_NOEXCEPT { + return ::operator new(size); +} + +__device__ inline void *operator new[](__SIZE_TYPE__ size) { + return ::operator new(size); +} +__device__ inline void *operator new[](__SIZE_TYPE__ size, + const std::nothrow_t &) { + return ::operator new(size); +} + +__device__ inline void operator delete(void* ptr) CUDA_NOEXCEPT { + if (ptr) { +::free(ptr); + } +} +__device__ inline void operator delete(void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +__device__ inline void operator delete[](void* ptr) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ inline void operator delete[](void *ptr, + const std::nothrow_t &) CUDA_NOEXCEPT { + ::operator delete(ptr); +} + +// Sized delete, C++14 only. +#if __cplusplus >= 201402L +__device__ void operator delete(void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +__device__ void operator delete[](void *ptr, __SIZE_TYPE__ size) CUDA_NOEXCEPT { + ::operator delete(ptr); +} +#endif + +// Device overrides for placement new and delete. __device__ inline void *operator new(__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void *operator new[](__SIZE_TYPE__, void *__ptr) CUDA_NOEXCEPT { return __ptr; } __device__ inline void operator delete(void *, void *) CUDA_NOEXCEPT {} __device__ inline void operator delete[](void *, void *) CUDA_NOEXCEPT {} + #pragma pop_macro("CUDA_NOEXCEPT") #endif // include guard ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://list
[PATCH] D37539: [CUDA] Add device overloads for non-placement new/delete.
jlebar marked an inline comment as done. jlebar added inline comments. Comment at: clang/lib/Headers/cuda_wrappers/new:79 +} +__device__ void operator delete[](void *ptr, std::size_t sz) CUDA_NOEXCEPT { + ::operator delete(ptr); tra wrote: > Is std::size_t intentional here? You use __SIZE_TYPE__ everywhere else. Fixed, thanks. https://reviews.llvm.org/D37539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37544: [ubsan] Skip alignment checks which are folded away
vsk created this revision. Don't emit alignment checks which the IR constant folder throws away. I've tested this out on X86FastISel.cpp. While this doesn't decrease end-to-end compile-time significantly, it results in 122 fewer type checks (1% reduction) overall, without adding any real complexity. https://reviews.llvm.org/D37544 Files: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/ubsan-suppress-checks.cpp Index: test/CodeGenCXX/ubsan-suppress-checks.cpp === --- test/CodeGenCXX/ubsan-suppress-checks.cpp +++ test/CodeGenCXX/ubsan-suppress-checks.cpp @@ -17,6 +17,15 @@ // CHECK: ret void } +// CHECK-LABEL: define void @_Z31use_char_aligned_array_elementsv +void use_char_aligned_array_elements() { + static const char Arr[] = {0, 1, 2}; + char X = Arr[2]; + + // CHECK-NOT: and i64 {{.*}}, !nosanitize + // CHECK: ret void +} + struct A { int foo; @@ -229,4 +238,5 @@ d->load_member_3(); load_non_null_pointers(); + use_char_aligned_array_elements(); } Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -618,6 +618,7 @@ auto PtrToAlloca = dyn_cast(Ptr->stripPointerCastsNoFollowAliases()); + llvm::Value *True = llvm::ConstantInt::getTrue(getLLVMContext()); llvm::Value *IsNonNull = nullptr; bool IsGuaranteedNonNull = SkippedChecks.has(SanitizerKind::Null) || PtrToAlloca; @@ -629,8 +630,7 @@ // The IR builder can constant-fold the null check if the pointer points to // a constant. -IsGuaranteedNonNull = -IsNonNull == llvm::ConstantInt::getTrue(getLLVMContext()); +IsGuaranteedNonNull = IsNonNull == True; // Skip the null check if the pointer is known to be non-null. if (!IsGuaranteedNonNull) { @@ -684,7 +684,8 @@ PtrAsInt, llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); llvm::Value *Aligned = Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); - Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); + if (Aligned != True) +Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); } } Index: test/CodeGenCXX/ubsan-suppress-checks.cpp === --- test/CodeGenCXX/ubsan-suppress-checks.cpp +++ test/CodeGenCXX/ubsan-suppress-checks.cpp @@ -17,6 +17,15 @@ // CHECK: ret void } +// CHECK-LABEL: define void @_Z31use_char_aligned_array_elementsv +void use_char_aligned_array_elements() { + static const char Arr[] = {0, 1, 2}; + char X = Arr[2]; + + // CHECK-NOT: and i64 {{.*}}, !nosanitize + // CHECK: ret void +} + struct A { int foo; @@ -229,4 +238,5 @@ d->load_member_3(); load_non_null_pointers(); + use_char_aligned_array_elements(); } Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -618,6 +618,7 @@ auto PtrToAlloca = dyn_cast(Ptr->stripPointerCastsNoFollowAliases()); + llvm::Value *True = llvm::ConstantInt::getTrue(getLLVMContext()); llvm::Value *IsNonNull = nullptr; bool IsGuaranteedNonNull = SkippedChecks.has(SanitizerKind::Null) || PtrToAlloca; @@ -629,8 +630,7 @@ // The IR builder can constant-fold the null check if the pointer points to // a constant. -IsGuaranteedNonNull = -IsNonNull == llvm::ConstantInt::getTrue(getLLVMContext()); +IsGuaranteedNonNull = IsNonNull == True; // Skip the null check if the pointer is known to be non-null. if (!IsGuaranteedNonNull) { @@ -684,7 +684,8 @@ PtrAsInt, llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); llvm::Value *Aligned = Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); - Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); + if (Aligned != True) +Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37543: [ubsan] Add helpers to decide when null/vptr checks are required. NFC.
vsk created this revision. Adding these helpers will make a planned change simpler: [ubsan] Defer pointer type checks, then try to skip the redundant ones https://reviews.llvm.org/D37543 Files: lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2347,6 +2347,12 @@ TCK_NonnullAssign }; + /// Determine whether the pointer type check \p TCK permits null pointers. + static bool isNullPointerAllowed(TypeCheckKind TCK); + + /// Determine whether the pointer type check \p TCK requires a vptr check. + static bool isVptrCheckRequired(TypeCheckKind TCK, QualType Ty); + /// \brief Whether any type-checking sanitizers are enabled. If \c false, /// calls to EmitTypeCheck can be skipped. bool sanitizePerformTypeCheck() const; Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -569,6 +569,19 @@ return Builder.CreateMul(B1, KMul); } +bool CodeGenFunction::isNullPointerAllowed(TypeCheckKind TCK) { + return TCK == TCK_DowncastPointer || TCK == TCK_Upcast || + TCK == TCK_UpcastToVirtualBase; +} + +bool CodeGenFunction::isVptrCheckRequired(TypeCheckKind TCK, QualType Ty) { + CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); + return (RD && RD->hasDefinition() && RD->isDynamicClass()) && + (TCK == TCK_MemberAccess || TCK == TCK_MemberCall || + TCK == TCK_DowncastPointer || TCK == TCK_DowncastReference || + TCK == TCK_UpcastToVirtualBase); +} + bool CodeGenFunction::sanitizePerformTypeCheck() const { return SanOpts.has(SanitizerKind::Null) | SanOpts.has(SanitizerKind::Alignment) | @@ -608,8 +621,7 @@ llvm::Value *IsNonNull = nullptr; bool IsGuaranteedNonNull = SkippedChecks.has(SanitizerKind::Null) || PtrToAlloca; - bool AllowNullPointers = TCK == TCK_DowncastPointer || TCK == TCK_Upcast || - TCK == TCK_UpcastToVirtualBase; + bool AllowNullPointers = isNullPointerAllowed(TCK); if ((SanOpts.has(SanitizerKind::Null) || AllowNullPointers) && !IsGuaranteedNonNull) { // The glvalue must not be an empty glvalue. @@ -696,13 +708,8 @@ // The program has undefined behavior if: //-- the [pointer or glvalue] is used to access a non-static data member // or call a non-static member function - CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); if (SanOpts.has(SanitizerKind::Vptr) && - !SkippedChecks.has(SanitizerKind::Vptr) && - (TCK == TCK_MemberAccess || TCK == TCK_MemberCall || - TCK == TCK_DowncastPointer || TCK == TCK_DowncastReference || - TCK == TCK_UpcastToVirtualBase) && - RD && RD->hasDefinition() && RD->isDynamicClass()) { + !SkippedChecks.has(SanitizerKind::Vptr) && isVptrCheckRequired(TCK, Ty)) { // Ensure that the pointer is non-null before loading it. If there is no // compile-time guarantee, reuse the run-time null check or emit a new one. if (!IsGuaranteedNonNull) { Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2347,6 +2347,12 @@ TCK_NonnullAssign }; + /// Determine whether the pointer type check \p TCK permits null pointers. + static bool isNullPointerAllowed(TypeCheckKind TCK); + + /// Determine whether the pointer type check \p TCK requires a vptr check. + static bool isVptrCheckRequired(TypeCheckKind TCK, QualType Ty); + /// \brief Whether any type-checking sanitizers are enabled. If \c false, /// calls to EmitTypeCheck can be skipped. bool sanitizePerformTypeCheck() const; Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -569,6 +569,19 @@ return Builder.CreateMul(B1, KMul); } +bool CodeGenFunction::isNullPointerAllowed(TypeCheckKind TCK) { + return TCK == TCK_DowncastPointer || TCK == TCK_Upcast || + TCK == TCK_UpcastToVirtualBase; +} + +bool CodeGenFunction::isVptrCheckRequired(TypeCheckKind TCK, QualType Ty) { + CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); + return (RD && RD->hasDefinition() && RD->isDynamicClass()) && + (TCK == TCK_MemberAccess || TCK == TCK_MemberCall || + TCK == TCK_DowncastPointer || TCK == TCK_DowncastReference || + TCK == TCK_UpcastToVirtualBase); +} + bool CodeGenFunction::sanitizePerformTypeCheck() const { return SanOpts.has(SanitizerKind::Null) | SanOpts.has(SanitizerKind::Alignment) | @@ -608,8 +621,7 @@ llvm::Value *IsNonNull = nullptr; bool IsGuaranteedNonNull = SkippedChecks.has(SanitizerKind::Null) || PtrToAlloca; - bool AllowNullPointers = TCK == TCK_DowncastPointer || TCK ==
[PATCH] D37542: [ubsan] Save a ptrtoint when emitting alignment checks
vsk created this revision. The alignment check emits a ptrtoint instruction which can be reused in the call to the diagnostic handler. https://reviews.llvm.org/D37542 Files: lib/CodeGen/CGExpr.cpp test/CodeGen/catch-undef-behavior.c Index: test/CodeGen/catch-undef-behavior.c === --- test/CodeGen/catch-undef-behavior.c +++ test/CodeGen/catch-undef-behavior.c @@ -59,8 +59,7 @@ // CHECK-COMMON-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3 // CHECK-COMMON-NEXT: icmp eq i64 %[[MISALIGN]], 0 - // CHECK-UBSAN: %[[ARG:.*]] = ptrtoint - // CHECK-UBSAN-NEXT: call void @__ubsan_handle_type_mismatch_v1(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[ARG]]) + // CHECK-UBSAN: call void @__ubsan_handle_type_mismatch_v1(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[PTRINT]]) // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]] // CHECK-TRAP-NEXT: unreachable Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -656,6 +656,7 @@ } uint64_t AlignVal = 0; + llvm::Value *PtrAsInt = nullptr; if (SanOpts.has(SanitizerKind::Alignment) && !SkippedChecks.has(SanitizerKind::Alignment)) { @@ -666,11 +667,11 @@ // The glvalue must be suitably aligned. if (AlignVal > 1 && (!PtrToAlloca || PtrToAlloca->getAlignment() < AlignVal)) { - llvm::Value *Align = - Builder.CreateAnd(Builder.CreatePtrToInt(Ptr, IntPtrTy), -llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); + PtrAsInt = Builder.CreatePtrToInt(Ptr, IntPtrTy); + llvm::Value *Align = Builder.CreateAnd( + PtrAsInt, llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); llvm::Value *Aligned = -Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); + Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); } } @@ -683,7 +684,8 @@ EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty), llvm::ConstantInt::get(Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1), llvm::ConstantInt::get(Int8Ty, TCK)}; -EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData, Ptr); +EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData, + PtrAsInt ? PtrAsInt : Ptr); } // If possible, check that the vptr indicates that there is a subobject of @@ -2595,6 +2597,9 @@ llvm::Value *CodeGenFunction::EmitCheckValue(llvm::Value *V) { llvm::Type *TargetTy = IntPtrTy; + if (V->getType() == TargetTy) +return V; + // Floating-point types which fit into intptr_t are bitcast to integers // and then passed directly (after zero-extension, if necessary). if (V->getType()->isFloatingPointTy()) { Index: test/CodeGen/catch-undef-behavior.c === --- test/CodeGen/catch-undef-behavior.c +++ test/CodeGen/catch-undef-behavior.c @@ -59,8 +59,7 @@ // CHECK-COMMON-NEXT: %[[MISALIGN:.*]] = and i64 %[[PTRINT]], 3 // CHECK-COMMON-NEXT: icmp eq i64 %[[MISALIGN]], 0 - // CHECK-UBSAN: %[[ARG:.*]] = ptrtoint - // CHECK-UBSAN-NEXT: call void @__ubsan_handle_type_mismatch_v1(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[ARG]]) + // CHECK-UBSAN: call void @__ubsan_handle_type_mismatch_v1(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), i64 %[[PTRINT]]) // CHECK-TRAP: call void @llvm.trap() [[NR_NUW]] // CHECK-TRAP-NEXT: unreachable Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -656,6 +656,7 @@ } uint64_t AlignVal = 0; + llvm::Value *PtrAsInt = nullptr; if (SanOpts.has(SanitizerKind::Alignment) && !SkippedChecks.has(SanitizerKind::Alignment)) { @@ -666,11 +667,11 @@ // The glvalue must be suitably aligned. if (AlignVal > 1 && (!PtrToAlloca || PtrToAlloca->getAlignment() < AlignVal)) { - llvm::Value *Align = - Builder.CreateAnd(Builder.CreatePtrToInt(Ptr, IntPtrTy), -llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); + PtrAsInt = Builder.CreatePtrToInt(Ptr, IntPtrTy); + llvm::Value *Align = Builder.CreateAnd( + PtrAsInt, llvm::ConstantInt::get(IntPtrTy, AlignVal - 1)); llvm::Value *Aligned = -Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); + Builder.CreateICmpEQ(Align, llvm::ConstantInt::get(IntPtrTy, 0)); Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment)); } } @@ -683,7 +684,8 @@ EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(Ty), llvm::ConstantInt::get(Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1), llvm::ConstantInt::get(Int8Ty, TCK)};
Re: r312633 - [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor
I am extremely uncomfortable about the direction this patch series is going. We have had two different RecursiveASTVisitors before (RecursiveASTVisitor and DataRecursiveASTVisitor), and it was a maintenance nightmare: frequently changes would be made to one of them and missed in the other one, resulting in hard to track down bugs, as well as redundant development effort making changes to both. Back when this was simply deriving from RecursiveASTVisitor and not changing much, LexicallyOrderedRecursiveASTVisitor seemed like it wouldn't suffer from the same problem, but it's becoming increasingly clear that that simply isn't going to be the case long-term. And worse, there seems to be absolutely no purpose in having two different visitors here -- the existing users of RecursiveASTVisitor generally don't care about visitation order. Also, we can play the "what if two people did this" game -- adding RAV functionality in derived classes doesn't compose well. (If post-order traversal were a derived class, you couldn't request a lexically-ordered post-order traversal, and so on.) Therefore, I'd like to suggest that you stop making changes to LexicallyOrderedRecursiveASTVisitor and instead start to fold its functionality back into RecursiveASTVisitor, as follows: * in cases where there is no reason for RAV to visit in non-lexical order, change it to visit in lexical order * if there are any cases where there *is* a reason for non-lexical visitation, add a bool function to it so the derived class can request lexical / non-lexical order (like the existing shouldTraversePostOrder / shouldVisitImplicitCode / ... functions). On 6 September 2017 at 06:12, Johannes Altmanninger via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: krobelus > Date: Wed Sep 6 06:12:11 2017 > New Revision: 312633 > > URL: http://llvm.org/viewvc/llvm-project?rev=312633&view=rev > Log: > [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor > > Summary: > This affects overloaded operators, which are represented by a > CXXOperatorCallExpr whose first child is always a DeclRefExpr referring to > the > operator. For infix, postfix and call operators we want the first argument > to be traversed before the operator. > > Reviewers: arphaman > > Subscribers: klimek, cfe-commits > > Differential Revision: https://reviews.llvm.org/D37200 > > Modified: > cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h > cfe/trunk/include/clang/AST/RecursiveASTVisitor.h > cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVi > sitorTest.cpp > > Modified: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVi > sitor.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ > LexicallyOrderedRecursiveASTVisitor.h?rev=312633&r1=312632& > r2=312633&view=diff > > == > --- cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h > (original) > +++ cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h Wed > Sep 6 06:12:11 2017 > @@ -113,6 +113,33 @@ public: > >bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } > > + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } > + > + SmallVector getStmtChildren(CXXOperatorCallExpr *CE) { > +SmallVector Children(CE->children()); > +bool Swap; > +// Switch the operator and the first operand for all infix and postfix > +// operations. > +switch (CE->getOperator()) { > +case OO_Arrow: > +case OO_Call: > +case OO_Subscript: > + Swap = true; > + break; > +case OO_PlusPlus: > +case OO_MinusMinus: > + // These are postfix unless there is exactly one argument. > + Swap = Children.size() != 2; > + break; > +default: > + Swap = CE->isInfixBinaryOp(); > + break; > +} > +if (Swap && Children.size() > 1) > + std::swap(Children[0], Children[1]); > +return Children; > + } > + > private: >bool TraverseAdditionalLexicallyNestedDeclarations() { > // FIXME: Ideally the gathered declarations and the declarations in > the > > Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/AST/RecursiveASTVisitor.h?rev=312633&r1=312632&r2=312633&view=diff > > == > --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) > +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Sep 6 06:12:11 > 2017 > @@ -315,6 +315,8 @@ public: > > // Methods on Stmts > > + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } > + > private: >template >struct has_same_member_pointer_type : std::false_type {}; > @@ -2084,7 +2086,7 @@ DEF_TRAVERSE_DECL(ParmVarDecl, { >TRY_TO(WalkUpFrom##STMT(S)); > \ > { CODE; } > \ > if (Sh
[PATCH] D37539: [CUDA] Add device overloads for non-placement new/delete.
tra accepted this revision. tra added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/Headers/cuda_wrappers/new:79 +} +__device__ void operator delete[](void *ptr, std::size_t sz) CUDA_NOEXCEPT { + ::operator delete(ptr); Is std::size_t intentional here? You use __SIZE_TYPE__ everywhere else. https://reviews.llvm.org/D37539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
minseong.kim added a comment. @hintonda, Absolutely. Incorporating @modocache's module changes into the version in AddLLVM.cmake would solve the current version display issue for repo and do not affect the process of other version control systems (e.g. git, git-svn, svn, and git submodule). https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37310: [Atomic] Merge alignment information from Decl and from Type when emit atomic expression.
rjmccall added inline comments. Comment at: lib/CodeGen/CGAtomic.cpp:680 + alignChars = std::max(alignChars, alignDecl); +} + Just use EmitPointerWithAlignment instead of EmitScalarExpr to emit the pointer operand. Repository: rL LLVM https://reviews.llvm.org/D37310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
hintonda added a comment. I just looked into both approaches and believe the one taken in AddLLVM.cmake is correct and handles the submodule case correctly. It uses `git rev-parse --git-dir` to find the location of the actual .git directory. Please see https://reviews.llvm.org/D31985 for details. https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37538: [libc++] Remove problematic ADL in container implementations.
rsmith added a comment. Looks good to me, but I'd like EricWF to also review. Comment at: include/deque:1167-1168 allocator_type& __a = __alloc(); -for (iterator __i = begin(), __e = end(); __i != __e; ++__i) -__alloc_traits::destroy(__a, _VSTD::addressof(*__i)); +for (iterator __i = begin(), __e = end(); __i.__ptr_ != __e.__ptr_; __i.operator++()) +__alloc_traits::destroy(__a, _VSTD::addressof(__i.operator*())); size() = 0; The other changes all look like obvious improvements to me. This one is a little more subtle, but if we want types like `deque *>` to be destructible, I think we need to do something equivalent to this. https://reviews.llvm.org/D37538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
hintonda added a comment. In https://reviews.llvm.org/D35533#862798, @minseong.kim wrote: > Hi~ @hintonda, > > Using using find_first_existing_file in ADDLLVM.cmake solves the cases with > repo in conjunction with https://reviews.llvm.org/D35532. However, I am not > sure it can handle @modocache's git submodule cases > (https://reviews.llvm.org/D34955). > > @modocache, could you please check removing find_first_existing_file and > find_first_existing_vc_file from lib/Basic/CMakeLists.txt solves git > submodule cases ? > > If so, I will remove them from clang's cmake to make one unified place for > the same functionality. Essentially, I think having a single version that works in all cases would be best. I really haven't looked into it, but would it make sense to incorporate @modocache's module changes into the version in AddLLVM.cmake? https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion updated this revision to Diff 114097. inglorion marked 5 inline comments as done. inglorion added a comment. I limited the change to only calls, returns, and declarations. I also updated the test case to include a multi-variable declaration, a while loop, a for loop, and an if statement (after verifying the behavior in the debugger, compared to MSVC). I discovered that there is a difference between the generated info for DWARF with or without -dwarf-column-info, so I included that in the test, too. I also made a couple of minor changes that were suggested. https://reviews.llvm.org/D37529 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.h clang/test/CodeGenCXX/debug-info-nested-exprs.cpp Index: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-nested-exprs.cpp @@ -0,0 +1,110 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -emit-llvm -o - %s | FileCheck -check-prefix=NONEST %s +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=COLUMNS %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=COLUMNS %s + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] +// NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]] +// NONEST: store i32 {{.*}}, !dbg ![[LOC]] +// NONEST: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]] +// NONEST: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]] +// NONEST: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]] +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]] +// NONEST: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]] +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]] +// NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]] +// NONEST: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]] +// NONEST: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]] +// NONEST: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]] +// NONEST: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]] +// NONEST: sub nsw i32 {{.*}}, !dbg ![[RETLOC]] +// NONEST: ret i32 {{.*}}, !dbg ![[RETLOC]] +// NONEST: ![[WHILE1]] = !DILocation( +// NONEST: ![[WHILE2]] = !DILocation( +// NONEST: ![[FOR1]] = !DILocation( +// NONEST: ![[FOR2]] = !DILocation( +// NONEST: ![[IF1]] = !DILocation( +// NONEST: ![[IF2]] = !DILocation( +// NONEST: ![[IF3]] = !DILocation( + +// NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]] +// NESTED: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]] +// NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]] +// NESTED: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]] +// NESTED: store i32 0, i32* %b,{{.*}} !dbg ![[ILOC]] +// NESTED: store i32 0, i32* %c,{{.*}} !dbg ![[ILOC]] +// NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]] +// NESTED: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]] +// NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]] +// NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]] +// NESTED: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]] +// NESTED: store i32 %{{[^,]+}}, i32* %a,{{.*}} !dbg ![[IF2:[0-9]+]] +// NESTED: store i32 %{{[^,]+}}, i32* %b,{{.*}} !dbg ![[IF3:[0-9]+]] +// NESTED: mul nsw i32 {{.*}}, !dbg ![[RETMUL:[0-9]+]] +// NESTED: sub nsw i32 {{.*}}, !dbg ![[RETSUB:[0-9]+]] +// NESTED: ret i32 {{.*}}, !dbg ! +// NESTED: ![[BAR]] = !DILocation( +// NESTED: ![[BAZ]] = !DILocation( +// NESTED: ![[QUX]] = !DILocation( +// NESTED: ![[RETSUB]] = !DILocation( +// NESTED: ![[RETMUL]] = !DILocation( + +// COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[BAR:[0-9]+]] +// COLUMNS: call i32 @{{.*}}baz{{.*}}, !dbg ![[BAZ:[0-9]+]] +// COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[QUX:[0-9]+]] +// COLUMNS: store i32 1, i32* %i,{{.*}} !dbg ![[ILOC:[0-9]+]] +// COLUMNS: store i32 0, i32* %b,{{.*}} !dbg ![[BLOC:[0-9]+]] +// COLUMNS: store i32 0, i32* %c,{{.*}} !dbg ![[CLOC:[0-9]+]] +// COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[WHILE1:[0-9]+]] +// COLUMNS: store i32 %{{[^,]+}}, i32* %i,{{.*}} !dbg ![[WHILE2:[0-9]+]] +// COLUMNS: call i32 @{{.*}}bar{{.*}}, !dbg ![[FOR1:[0-9]+]] +// COLUMNS: call i32 @{{.*}}qux{{.*}}, !dbg ![[FOR2:[0-9]+]] +// COLUMNS: store i32 %{{[^,]+}}, i32* %t,{{.*}} !dbg ![[IF1:[0-9]+]] +// COLUMNS: store i32 %{{[^,]+}}
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
minseong.kim added a comment. Hi~ @hintonda, Using using find_first_existing_file in ADDLLVM.cmake solves the cases with repo in conjunction with https://reviews.llvm.org/D35532. However, I am not sure it can handle @modocache's git submodule cases (https://reviews.llvm.org/D34955). @modocache, could you please check removing find_first_existing_file and find_first_existing_vc_file from lib/Basic/CMakeLists.txt solves git submodule cases ? If so, I will remove them from clang's cmake to make one unified place for the same functionality. https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
This revision was automatically updated to reflect the committed changes. Closed by commit rL312677: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode (authored by mgrang). Changed prior to commit: https://reviews.llvm.org/D37400?vs=114089&id=114091#toc Repository: rL LLVM https://reviews.llvm.org/D37400 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +404,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; public: @@ -424,7 +424,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +404,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; public: @@ -424,7 +424,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312677 - [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
Author: mgrang Date: Wed Sep 6 15:54:59 2017 New Revision: 312677 URL: http://llvm.org/viewvc/llvm-project?rev=312677&view=rev Log: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode Summary: This fixes failures seen in the reverse iteration builder: http://lab.llvm.org:8011/builders/reverse-iteration/builds/26 Failing Tests (4): Clang :: Analysis/MisusedMovedObject.cpp Clang :: Analysis/keychainAPI.m Clang :: Analysis/loop-unrolling.cpp Clang :: Analysis/malloc.c Reviewers: zaks.anna, bkramer, chandlerc, krememek, nikhgupt Reviewed By: zaks.anna Subscribers: dcoughlin, NoQ, cfe-commits Differential Revision: https://reviews.llvm.org/D37400 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=312677&r1=312676&r2=312677&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Wed Sep 6 15:54:59 2017 @@ -27,7 +27,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +404,7 @@ private: }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; public: @@ -424,7 +424,7 @@ public: unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
zaks.anna accepted this revision. zaks.anna added a comment. This revision is now accepted and ready to land. Thank you! Anna https://reviews.llvm.org/D37400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
mgrang added inline comments. Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h:407 class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; SmallSetVector size has to be a power of 2. I was split between 4 and 8. I chose 4 as it's closer to 5 :) https://reviews.llvm.org/D37400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
mgrang updated this revision to Diff 114089. mgrang added a comment. Addressed comments. https://reviews.llvm.org/D37400 Files: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +404,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; public: @@ -424,7 +424,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h === --- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -27,7 +27,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/GraphTraits.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include @@ -404,7 +404,7 @@ }; class ExplodedNodeSet { - typedef llvm::SmallPtrSet ImplTy; + typedef llvm::SmallSetVector ImplTy; ImplTy Impl; public: @@ -424,7 +424,7 @@ unsigned size() const { return Impl.size(); } bool empty()const { return Impl.empty(); } - bool erase(ExplodedNode *N) { return Impl.erase(N); } + bool erase(ExplodedNode *N) { return Impl.remove(N); } void clear() { Impl.clear(); } void insert(const ExplodedNodeSet &S) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37538: [libc++] Remove problematic ADL in container implementations.
dlj created this revision. Herald added a subscriber: sanjoy. Herald added a reviewer: EricWF. Some container operations require ADL. For example, std::advance is required to use specific operators, which will participate in ADL. However, implementation details which rely on SFINAE should be careful not to inadvertently invoke ADL. Otherwise, the SFINAE lookup will (incorrectly) consider namespaces other than std::. This is particularly problematic with incomplete types, since the set of associated namespaces for a class includes the body of the class (which may contain inline friend function overloads). If a type is incomplete, its body cannot be added to the set of associated namespaces; this results in an error. The changes in this patch mostly appear to be omissions. Several of the changes are for SFINAE overloads with internal names (in some cases, there are other uses which are already correctly qualified). In a few cases, the implementation details of iterators are directly to avoid invoking ADL (this seems unfortunate; but on balance, better than failing when type erasure is otherwise plausible). https://reviews.llvm.org/D37538 Files: include/__split_buffer include/deque include/memory test/std/containers/containers.general/construct_destruct.pass.cpp Index: test/std/containers/containers.general/construct_destruct.pass.cpp === --- /dev/null +++ test/std/containers/containers.general/construct_destruct.pass.cpp @@ -0,0 +1,130 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Holder is a do-nothing wrapper around a value of the given type. +// +// Since unqualified name lookup and operator overload lookup participate in +// ADL, the dependent type ns::T contributes to the overload set considered by +// ADL. In other words, ADL will consider all associated namespaces: this +// includes not only N, but also any inline friend functions declared by ns::T. +// +// The purpose of this test is to ensure that simply constructing or destroying +// a container does not invoke ADL which would be problematic for unknown types. +// By using the type 'Holder *' as a container value, we can avoid the +// obvious problems with unknown types: a pointer is trivial, and its size is +// known. However, any ADL which includes ns::T as an associated namesapce will +// fail. +// +// For example: +// +// namespace ns { +// class T { +// // 13.5.7 [over.inc]: +// friend std::list::const_iterator +// operator++(std::list::const_iterator it) { +// return /* ... */; +// } +// }; +// } +// +// The C++ standard stipulates that some functions, such as std::advance, use +// overloaded operators (in C++14: 24.4.4 [iterator.operations]). The +// implication is that calls to such a function are dependent on knowing the +// overload set of operators in all associated namespaces; under ADL, this +// includes the private friend function in the example above. +// +// However, for some operations, such as construction and destruction, no such +// ADL is required. This can be important, for example, when using the Pimpl +// pattern: +// +// // Defined in a header file: +// class InterfaceList { +// // Defined in a .cpp file: +// class Impl; +// vector impls; +// public: +// ~InterfaceList(); +// }; +// +template +class Holder { T value; }; + +namespace ns { class Fwd; } + +// TestSequencePtr and TestMappingPtr ensure that a given container type can be +// default-constructed and destroyed with an incomplete value pointer type. +template class Container> +void TestSequencePtr() { + using X = Container*>; + { +X u; +assert(u.empty()); + } + { +auto u = X(); +assert(u.empty()); + } +} + +template class Container> +void TestMappingPtr() { + { +using X = Container*>; +X u1; +assert(u1.empty()); +auto u2 = X(); +assert(u2.empty()); + } + { +using X = Container*, int>; +X u1; +assert(u1.empty()); +auto u2 = X(); +assert(u2.empty()); + } +} + +int main() +{ + // Sequence containers: + { +std::array*, 1> a; +(void)a; + } + TestSequencePtr(); + TestSequencePtr(); + TestSequencePtr(); + TestSequencePtr(); + + // Associative containers, non-mapping: + TestSequencePtr(); + TestSequencePtr(); + + // Associative containers, mapping: + TestMappingPtr(); + TestMappingPtr(); + + // Container adapters: + TestSequencePtr(); + TestSequencePtr(); +} Index: include/mem
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
zaks.anna added a comment. Thanks for addressing the non-determinism!!! The ExplodedNodeSet is predominantly used to hold very small sets and it is used quite a bit in the analyzer. Maybe we could we use SmallSetVector here instead? https://reviews.llvm.org/D37400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
zturner added inline comments. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:44 + int a = bar(x, y) + + baz(x, z) + + qux(y, z); inglorion wrote: > zturner wrote: > > inglorion wrote: > > > zturner wrote: > > > > Can you make a function called `int foo()` and make this `int a = > > > > bar(foo(), y) + ...` > > > Yes. Why? To test an additional level of nesting? > > Yes. for that matter, even better would be if this call to `foo()` spans > > multiple lines. Right here you've got a single statement which spans > > multiple lines, but no individual sub-expression spans multiple lines. And > > FWICT there is no nesting at all, since + is just a builtin operator. > The nesting here is the calls to bar, baz, and qux inside the declaration of > a. The old behavior would emit separate locations for each of the calls, the > new behavior annotates each of the calls with the same location as the > declaration. This causes the debugger to stop only once for the entire > statement when using step over, and makes step into specific work. Sure, but does that execute the same codepath as: ``` int a = bar( baz()); a = bar(baz()); for (const auto &X : foo(bar())) for (int x = foo(); x < bar(); baz(x)) if (foo() && bar()) if (createObject().func()) ``` etc? And what if one or more of these functions get inlined? For example, what if you have: ``` int a = foo(bar(baz()), bar(buzz())); ``` https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
zturner added inline comments. Comment at: clang/lib/CodeGen/CGDebugInfo.h:65 llvm::MDNode *CurInlinedAt = nullptr; + bool LocationEnabled = true; llvm::DIType *VTablePtrType = nullptr; Can you move this line up to put it next to another bool? Not a huge deal, but might as well pack the class members. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:44 + int a = bar(x, y) + + baz(x, z) + + qux(y, z); Can you make a function called `int foo()` and make this `int a = bar(foo(), y) + ...` https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion added inline comments. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:44 + int a = bar(x, y) + + baz(x, z) + + qux(y, z); zturner wrote: > inglorion wrote: > > zturner wrote: > > > Can you make a function called `int foo()` and make this `int a = > > > bar(foo(), y) + ...` > > Yes. Why? To test an additional level of nesting? > Yes. for that matter, even better would be if this call to `foo()` spans > multiple lines. Right here you've got a single statement which spans > multiple lines, but no individual sub-expression spans multiple lines. And > FWICT there is no nesting at all, since + is just a builtin operator. The nesting here is the calls to bar, baz, and qux inside the declaration of a. The old behavior would emit separate locations for each of the calls, the new behavior annotates each of the calls with the same location as the declaration. This causes the debugger to stop only once for the entire statement when using step over, and makes step into specific work. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion created this revision. Herald added a subscriber: aprantl. Microsoft Visual Studio expects debug locations to correspond to statements. We used to emit locations for expressions nested inside statements. This would confuse the debugger, causing it to stop multiple times on the same line and breaking the "step into specific" feature. This change inhibits the emission of debug locations for nested expressions when emitting CodeView debug information, unless column information is enabled. Fixes PR34312. https://reviews.llvm.org/D37529 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.h clang/test/CodeGenCXX/debug-info-nested-exprs.cpp Index: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-nested-exprs.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -emit-llvm -o - %s | FileCheck -check-prefix=NONEST %s +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=NESTED %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=NESTED %s + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] +// NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]] +// NONEST: store i32 {{.*}}, !dbg ![[LOC]] +// NONEST: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]] +// NONEST: sub nsw i32 {{.*}}, !dbg ![[RETLOC]] +// NONEST: ret i32 {{.*}}, !dbg ![[RETLOC]] + +// NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NESTED: call i32 @{{.*}}baz{{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: store i32 {{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]] +// NESTED: sub nsw i32 {{.*}}, !dbg ! +// NESTED-NOT: [[RETLOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: ret i32 {{.*}}, !dbg ! +// NESTED-NOT: [[RETLOC]] +// NESTED-SAME: {{[0-9]+}} + +int bar(int x, int y); +int baz(int x, int y); +int qux(int x, int y); + +int foo(int x, int y, int z) { + int a = bar(x, y) + + baz(x, z) + + qux(y, z); + return a - + (y * z); +} Index: clang/lib/CodeGen/CodeGenModule.h === --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -29,6 +29,7 @@ #include "clang/Basic/Module.h" #include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/XRayLists.h" +#include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" @@ -70,7 +71,6 @@ class ValueDecl; class VarDecl; class LangOptions; -class CodeGenOptions; class HeaderSearchOptions; class PreprocessorOptions; class DiagnosticsEngine; @@ -513,6 +513,11 @@ /// Finalize LLVM code generation. void Release(); + /// Return true if we should emit location information for nested expressions. + bool getNestedExpressionLocationsEnabled() const { +return !CodeGenOpts.EmitCodeView || CodeGenOpts.DebugColumnInfo; + } + /// Return a reference to the configured Objective-C runtime. CGObjCRuntime &getObjCRuntime() { if (!ObjCRuntime) createObjCRuntime(); Index: clang/lib/CodeGen/CodeGenFunction.h === --- clang/lib/CodeGen/CodeGenFunction.h +++ clang/lib/CodeGen/CodeGenFunction.h @@ -87,6 +87,7 @@ class BlockByrefInfo; class BlockFlags; class BlockFieldFlags; +class InhibitDebugLocation; class RegionCodeGenTy; class TargetCodeGenInfo; struct OMPTaskDataTy; @@ -2525,6 +2526,14 @@ // Statement Emission //======// + /// EmitStmtStopPoint - Emit a statement stoppoint if we are emitting debug + /// info. + /// If getNestedExpressionLocationsEnabled() returns false, this also inhibits + /// the emission of debug location information until the returned + /// InhibitDebugLocation + /// object is destroyed. + InhibitDebugLocation EmitStmtStopPoint(const Stmt *S); + /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info. void EmitStopPoint(const Stmt *S); Index: clang/lib/CodeGen/CGStmt.cpp ==
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion added inline comments. Comment at: clang/lib/CodeGen/CGStmt.cpp:45 + } + return IDL; +} inglorion wrote: > rnk wrote: > > Does MSVC accept this? I think it will emit the copy ctor call in an -O0 > > build. > I wrote this thinking that the right thing would happen under copy elision > (there is only one object, move constructor isn't called, and the destructor > only runs once) and without copy elision (there are two objects, move > constructor is called, destructor is run for both objects but is a no-op for > the moved-from object). If that's not the case, how would you rewrite this to > do the right thing? FWIW, the test passes with MSVC in a Debug build, too. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
zturner added inline comments. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:44 + int a = bar(x, y) + + baz(x, z) + + qux(y, z); inglorion wrote: > zturner wrote: > > Can you make a function called `int foo()` and make this `int a = > > bar(foo(), y) + ...` > Yes. Why? To test an additional level of nesting? Yes. for that matter, even better would be if this call to `foo()` spans multiple lines. Right here you've got a single statement which spans multiple lines, but no individual sub-expression spans multiple lines. And FWICT there is no nesting at all, since + is just a builtin operator. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312670 - [NFC] [CSA] Move AnyFunctionCall::getRuntimeDefinition implementation to cpp.
Author: george.karpenkov Date: Wed Sep 6 14:45:01 2017 New Revision: 312670 URL: http://llvm.org/viewvc/llvm-project?rev=312670&view=rev Log: [NFC] [CSA] Move AnyFunctionCall::getRuntimeDefinition implementation to cpp. Differential Revision: https://reviews.llvm.org/D37499 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=312670&r1=312669&r2=312670&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Wed Sep 6 14:45:01 2017 @@ -436,20 +436,7 @@ public: return cast(CallEvent::getDecl()); } - RuntimeDefinition getRuntimeDefinition() const override { -const FunctionDecl *FD = getDecl(); -// Note that the AnalysisDeclContext will have the FunctionDecl with -// the definition (if one exists). -if (FD) { - AnalysisDeclContext *AD = -getLocationContext()->getAnalysisDeclContext()-> -getManager()->getContext(FD); - if (AD->getBody()) -return RuntimeDefinition(AD->getDecl()); -} - -return RuntimeDefinition(); - } + RuntimeDefinition getRuntimeDefinition() const override; bool argumentsMayEscape() const override; Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=312670&r1=312669&r2=312670&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Wed Sep 6 14:45:01 2017 @@ -343,6 +343,22 @@ ArrayRef AnyFunctionCall:: return D->parameters(); } + +RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const { + const FunctionDecl *FD = getDecl(); + // Note that the AnalysisDeclContext will have the FunctionDecl with + // the definition (if one exists). + if (FD) { +AnalysisDeclContext *AD = + getLocationContext()->getAnalysisDeclContext()-> + getManager()->getContext(FD); +if (AD->getBody()) + return RuntimeDefinition(AD->getDecl()); + } + + return RuntimeDefinition(); +} + void AnyFunctionCall::getInitialStackFrameContents( const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312671 - [CSA] [NFC] Move AnalysisContext.h to AnalysisDeclContext.h
Author: george.karpenkov Date: Wed Sep 6 14:45:03 2017 New Revision: 312671 URL: http://llvm.org/viewvc/llvm-project?rev=312671&view=rev Log: [CSA] [NFC] Move AnalysisContext.h to AnalysisDeclContext.h The implementation is in AnalysisDeclContext.cpp and the class is called AnalysisDeclContext. Making those match up has numerous benefits, including: - Easier jump from header to/from implementation. - Easily identify filename from class. Differential Revision: https://reviews.llvm.org/D37500 Added: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h - copied, changed from r312670, cfe/trunk/include/clang/Analysis/AnalysisContext.h Removed: cfe/trunk/include/clang/Analysis/AnalysisContext.h Modified: cfe/trunk/include/clang/Analysis/Analyses/Consumed.h cfe/trunk/include/clang/Analysis/Analyses/Dominators.h cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h cfe/trunk/include/clang/Analysis/ProgramPoint.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp cfe/trunk/lib/Analysis/Consumed.cpp cfe/trunk/lib/Analysis/LiveVariables.cpp cfe/trunk/lib/Analysis/ReachableCode.cpp cfe/trunk/lib/Analysis/ThreadSafety.cpp cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp cfe/trunk/lib/Analysis/UninitializedValues.cpp cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp cfe/trunk/lib/StaticAnalyzer/Core/PrettyStackTraceLocationContext.h cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Modified: cfe/trunk/include/clang/Analysis/Analyses/Consumed.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Consumed.h?rev=312671&r1=312670&r2=312671&view=diff == --- cfe/trunk/include/clang/Analysis/Analyses/Consumed.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/Consumed.h Wed Sep 6 14:45:03 2017 @@ -19,7 +19,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" #include "clang/Analysis/Analyses/PostOrderCFGView.h" -#include "clang/Analysis/AnalysisContext.h" +#include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Basic/SourceLocation.h" namespace clang { Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=312671&r1=312670&r2=312671&view=diff == --- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Wed Sep 6 14:45:03 2017 @@ -14,7 +14,7 @@ #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_DOMINATORS_H #define LLVM_CLANG_ANALYSIS_ANALYSES_DOMINATORS_H -#include "clang/Analysis/AnalysisContext.h" +#include "clang/Analysis/AnalysisDeclContext.h" #include "clang/Analysis/CFG.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/Support/GenericDomTree.h" Modified: cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h?rev=312671&r1=312670&r2=312671&view=diff == --- cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/LiveVariables.h Wed Sep 6 14:45:03 2017 @@ -15,7 +15,7 @@ #define LLVM_CLANG_ANALYSIS_ANALYSES_LIVEVARIABLES_H #include "clang/AST/Decl.h" -#include "clang/Analysis/AnalysisContext.h" +#include "clang/Analysis/AnalysisDeclContext.h" #include "llvm/ADT/ImmutableSet.h" namespace clang { Modified: cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/PostOrderCFGView.h?rev=312671&r1=312670&r2=312671&view=diff == --- c
[PATCH] D37531: Add an usage example of BreakBeforeBraces
sylvestre.ledru created this revision. https://reviews.llvm.org/D37531 Files: docs/ClangFormatStyleOptions.rst Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -533,6 +533,16 @@ If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how each individual brace case should be handled. Otherwise, this is ignored. + .. code-block:: yaml + +# Example of usage: +BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: true + AfterStruct: false + SplitEmptyFunction: false + + Nested configuration flags: Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -533,6 +533,16 @@ If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how each individual brace case should be handled. Otherwise, this is ignored. + .. code-block:: yaml + +# Example of usage: +BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: true + AfterStruct: false + SplitEmptyFunction: false + + Nested configuration flags: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37530: [MinGW] Allow overriding which version of msvcrt to link to
rnk added a comment. What do you think of letting people spell this as `-lmsvcrt120`? We could forward those options and suppress our implicit addition of `-lmsvcrt` if we see `-lmsvcr*` anywhere. Comment at: lib/Driver/ToolChains/MinGW.cpp:161 if (TC.getArch() == llvm::Triple::x86) -CmdArgs.push_back("_DllMainCRTStartup@12"); +CmdArgs.push_back("DllMainCRTStartup@12"); else I guess ld.bfd for COFF does some wacky name mangling. =/ https://reviews.llvm.org/D37530 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
rnk added inline comments. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:12 + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] inglorion wrote: > rnk wrote: > > This is pretty painful to test. :( > > > > If we let ourselves do an asm test, .cv_loc is printed with some nice > > assembly comments that make this testing easy. > Would you like me to write an asm test in addition to / instead of this one? Oops, I thought I wrote this comment and deleted it before hitting send, but apparently not. No, let's stick with the IR test. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
rnk added a subscriber: echristo. rnk added inline comments. Comment at: clang/lib/CodeGen/CGStmt.cpp:38 +InhibitDebugLocation CodeGenFunction::EmitStmtStopPoint(const Stmt *S) { + InhibitDebugLocation IDL; "Stop point" is a hold-over from the llvm.dbg.stoppoint, which doesn't exist anymore: http://releases.llvm.org/2.6/docs/SourceLevelDebugging.html#format_common_stoppoint @echristo renamed CGDebugInfo::EmitStopPoint to EmitLocation long ago, and we should do the same for CodeGenFunction::EmitStopPoint. I'd like to have something like `EmitStmtLocation` and `EmitExprLocation`. Comment at: clang/lib/CodeGen/CGStmt.cpp:45 + } + return IDL; +} Does MSVC accept this? I think it will emit the copy ctor call in an -O0 build. Comment at: clang/lib/CodeGen/CGStmt.cpp:145 case Stmt::IfStmtClass: EmitIfStmt(cast(*S)); break; case Stmt::WhileStmtClass:EmitWhileStmt(cast(*S)); break; Doesn't this end up recursing? Won't InhibitDebugLocation prevent us from applying the inner statement locations? Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:12 + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] This is pretty painful to test. :( If we let ourselves do an asm test, .cv_loc is printed with some nice assembly comments that make this testing easy. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:48 + (y * z); +} I'd like to see some compound statement tests: for, while, if, regular braces, etc. https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion added inline comments. Comment at: clang/lib/CodeGen/CGStmt.cpp:45 + } + return IDL; +} rnk wrote: > Does MSVC accept this? I think it will emit the copy ctor call in an -O0 > build. I wrote this thinking that the right thing would happen under copy elision (there is only one object, move constructor isn't called, and the destructor only runs once) and without copy elision (there are two objects, move constructor is called, destructor is run for both objects but is a no-op for the moved-from object). If that's not the case, how would you rewrite this to do the right thing? Comment at: clang/lib/CodeGen/CGStmt.cpp:145 case Stmt::IfStmtClass: EmitIfStmt(cast(*S)); break; case Stmt::WhileStmtClass:EmitWhileStmt(cast(*S)); break; rnk wrote: > Doesn't this end up recursing? Won't InhibitDebugLocation prevent us from > applying the inner statement locations? Yeah, this looks wrong. Let me get back to you with fixed code or an explanation of why it actually does the right thing. Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:12 + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] rnk wrote: > This is pretty painful to test. :( > > If we let ourselves do an asm test, .cv_loc is printed with some nice > assembly comments that make this testing easy. Would you like me to write an asm test in addition to / instead of this one? Comment at: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp:44 + int a = bar(x, y) + + baz(x, z) + + qux(y, z); zturner wrote: > Can you make a function called `int foo()` and make this `int a = bar(foo(), > y) + ...` Yes. Why? To test an additional level of nesting? https://reviews.llvm.org/D37529 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37530: [MinGW] Allow overriding which version of msvcrt to link to
mstorsjo created this revision. This allows linking to e.g. msvcr120.dll or ucrtbase.dll instead of the unversioned (and officially unsupported) msvcrt.dll. In GCC setups, this can be overridden by using custom spec files, but this isn't supported in clang. This is just an initial attempt at implementing this - suggestions are most welcome. https://reviews.llvm.org/D37530 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/MinGW.cpp test/Driver/mingw-msvcrt.c Index: test/Driver/mingw-msvcrt.c === --- /dev/null +++ test/Driver/mingw-msvcrt.c @@ -0,0 +1,5 @@ +// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s +// RUN: %clang -v -target i686-pc-windows-gnu -mmsvcrt=msvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s + +// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" +// CHECK_MSVCR120: "-lmingwex" "-lmsvcr120" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -82,7 +82,8 @@ CmdArgs.push_back("-lmoldname"); CmdArgs.push_back("-lmingwex"); - CmdArgs.push_back("-lmsvcrt"); + CmdArgs.push_back(Args.MakeArgString( + "-l" + Args.getLastArgValue(options::OPT_mmsvcrt_EQ, "msvcrt"))); } void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -157,7 +158,7 @@ if (Args.hasArg(options::OPT_mdll) || Args.hasArg(options::OPT_shared)) { CmdArgs.push_back("-e"); if (TC.getArch() == llvm::Triple::x86) -CmdArgs.push_back("_DllMainCRTStartup@12"); +CmdArgs.push_back("DllMainCRTStartup@12"); else CmdArgs.push_back("DllMainCRTStartup"); CmdArgs.push_back("--enable-auto-image-base"); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1710,6 +1710,7 @@ def mdll : Joined<["-"], "mdll">, Group, Flags<[DriverOption]>; def municode : Joined<["-"], "municode">, Group, Flags<[DriverOption]>; def mthreads : Joined<["-"], "mthreads">, Group, Flags<[DriverOption]>; +def mmsvcrt_EQ : Joined<["-"], "mmsvcrt=">, Group, Flags<[DriverOption]>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group; def mmcu_EQ : Joined<["-"], "mmcu=">, Group; def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group; Index: test/Driver/mingw-msvcrt.c === --- /dev/null +++ test/Driver/mingw-msvcrt.c @@ -0,0 +1,5 @@ +// RUN: %clang -v -target i686-pc-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_DEFAULT %s +// RUN: %clang -v -target i686-pc-windows-gnu -mmsvcrt=msvcr120 -### %s 2>&1 | FileCheck -check-prefix=CHECK_MSVCR120 %s + +// CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" +// CHECK_MSVCR120: "-lmingwex" "-lmsvcr120" Index: lib/Driver/ToolChains/MinGW.cpp === --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -82,7 +82,8 @@ CmdArgs.push_back("-lmoldname"); CmdArgs.push_back("-lmingwex"); - CmdArgs.push_back("-lmsvcrt"); + CmdArgs.push_back(Args.MakeArgString( + "-l" + Args.getLastArgValue(options::OPT_mmsvcrt_EQ, "msvcrt"))); } void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -157,7 +158,7 @@ if (Args.hasArg(options::OPT_mdll) || Args.hasArg(options::OPT_shared)) { CmdArgs.push_back("-e"); if (TC.getArch() == llvm::Triple::x86) -CmdArgs.push_back("_DllMainCRTStartup@12"); +CmdArgs.push_back("DllMainCRTStartup@12"); else CmdArgs.push_back("DllMainCRTStartup"); CmdArgs.push_back("--enable-auto-image-base"); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1710,6 +1710,7 @@ def mdll : Joined<["-"], "mdll">, Group, Flags<[DriverOption]>; def municode : Joined<["-"], "municode">, Group, Flags<[DriverOption]>; def mthreads : Joined<["-"], "mthreads">, Group, Flags<[DriverOption]>; +def mmsvcrt_EQ : Joined<["-"], "mmsvcrt=">, Group, Flags<[DriverOption]>; def mcpu_EQ : Joined<["-"], "mcpu=">, Group; def mmcu_EQ : Joined<["-"], "mmcu=">, Group; def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37529: [codeview] omit debug locations for nested exprs unless column info enabled
inglorion updated this revision to Diff 114060. inglorion added a comment. removed accidentally left in include and reformatted mangled comment https://reviews.llvm.org/D37529 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CGStmt.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenModule.h clang/test/CodeGenCXX/debug-info-nested-exprs.cpp Index: clang/test/CodeGenCXX/debug-info-nested-exprs.cpp === --- /dev/null +++ clang/test/CodeGenCXX/debug-info-nested-exprs.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -emit-llvm -o - %s | FileCheck -check-prefix=NONEST %s +// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \ +// RUN:-gcodeview -dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=NESTED %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s +// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \ +// RUN:-dwarf-column-info -emit-llvm -o - %s \ +// RUN:| FileCheck -check-prefix=NESTED %s + +// NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]] +// NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]] +// NONEST: store i32 {{.*}}, !dbg ![[LOC]] +// NONEST: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]] +// NONEST: sub nsw i32 {{.*}}, !dbg ![[RETLOC]] +// NONEST: ret i32 {{.*}}, !dbg ![[RETLOC]] + +// NESTED: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]] +// NESTED: call i32 @{{.*}}baz{{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: call i32 @{{.*}}qux{{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: store i32 {{.*}}, !dbg ! +// NESTED-NOT: [[LOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: mul nsw i32 {{.*}}, !dbg ![[RETLOC:[0-9]+]] +// NESTED: sub nsw i32 {{.*}}, !dbg ! +// NESTED-NOT: [[RETLOC]] +// NESTED-SAME: {{[0-9]+}} +// NESTED: ret i32 {{.*}}, !dbg ! +// NESTED-NOT: [[RETLOC]] +// NESTED-SAME: {{[0-9]+}} + +int bar(int x, int y); +int baz(int x, int y); +int qux(int x, int y); + +int foo(int x, int y, int z) { + int a = bar(x, y) + + baz(x, z) + + qux(y, z); + return a - + (y * z); +} Index: clang/lib/CodeGen/CodeGenModule.h === --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -29,6 +29,7 @@ #include "clang/Basic/Module.h" #include "clang/Basic/SanitizerBlacklist.h" #include "clang/Basic/XRayLists.h" +#include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" @@ -70,7 +71,6 @@ class ValueDecl; class VarDecl; class LangOptions; -class CodeGenOptions; class HeaderSearchOptions; class PreprocessorOptions; class DiagnosticsEngine; @@ -513,6 +513,11 @@ /// Finalize LLVM code generation. void Release(); + /// Return true if we should emit location information for nested expressions. + bool getNestedExpressionLocationsEnabled() const { +return !CodeGenOpts.EmitCodeView || CodeGenOpts.DebugColumnInfo; + } + /// Return a reference to the configured Objective-C runtime. CGObjCRuntime &getObjCRuntime() { if (!ObjCRuntime) createObjCRuntime(); Index: clang/lib/CodeGen/CodeGenFunction.h === --- clang/lib/CodeGen/CodeGenFunction.h +++ clang/lib/CodeGen/CodeGenFunction.h @@ -87,6 +87,7 @@ class BlockByrefInfo; class BlockFlags; class BlockFieldFlags; +class InhibitDebugLocation; class RegionCodeGenTy; class TargetCodeGenInfo; struct OMPTaskDataTy; @@ -2525,6 +2526,12 @@ // Statement Emission //======// + /// EmitStmtStopPoint - Emit a statement stoppoint if we are emitting debug + /// info. If getNestedExpressionLocationsEnabled() returns false, this also + /// inhibits the emission of debug location information until the returned + /// InhibitDebugLocation object is destroyed. + InhibitDebugLocation EmitStmtStopPoint(const Stmt *S); + /// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info. void EmitStopPoint(const Stmt *S); Index: clang/lib/CodeGen/CGStmt.cpp === --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -35,8 +35,19 @@ // Statement Emission //===--===// +InhibitDebugLocation CodeGenFunction::EmitStmtStopPoint(const Stmt *S) { + InhibitDebugLocation IDL; + if (HaveInsertPoint()) { +Emit
r312665 - [modules ts] Emit global variables in a module interface unit as part of that unit, not in importers.
Author: rsmith Date: Wed Sep 6 13:01:14 2017 New Revision: 312665 URL: http://llvm.org/viewvc/llvm-project?rev=312665&view=rev Log: [modules ts] Emit global variables in a module interface unit as part of that unit, not in importers. Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=312665&r1=312664&r2=312665&view=diff == --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Sep 6 13:01:14 2017 @@ -1133,7 +1133,7 @@ private: /// predefines buffer may contain additional definitions. std::string SuggestedPredefines; - llvm::DenseMap BodySource; + llvm::DenseMap DefinitionSource; /// \brief Reads a statement from the specified cursor. Stmt *ReadStmtFromStream(ModuleFile &F); Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=312665&r1=312664&r2=312665&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Sep 6 13:01:14 2017 @@ -8908,7 +8908,7 @@ static GVALinkage basicGVALinkageForFunc } static GVALinkage adjustGVALinkageForAttributes(const ASTContext &Context, -GVALinkage L, const Decl *D) { +const Decl *D, GVALinkage L) { // See http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx // dllexport/dllimport on inline functions. if (D->hasAttr()) { @@ -8927,25 +8927,37 @@ static GVALinkage adjustGVALinkageForAtt return L; } -GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const { - auto L = adjustGVALinkageForAttributes( - *this, basicGVALinkageForFunction(*this, FD), FD); - auto EK = ExternalASTSource::EK_ReplyHazy; - if (auto *Ext = getExternalSource()) -EK = Ext->hasExternalDefinitions(FD); - switch (EK) { +/// Adjust the GVALinkage for a declaration based on what an external AST source +/// knows about whether there can be other definitions of this declaration. +static GVALinkage +adjustGVALinkageForExternalDefinitionKind(const ASTContext &Ctx, const Decl *D, + GVALinkage L) { + ExternalASTSource *Source = Ctx.getExternalSource(); + if (!Source) +return L; + + switch (Source->hasExternalDefinitions(D)) { case ExternalASTSource::EK_Never: +// Other translation units rely on us to provide the definition. if (L == GVA_DiscardableODR) return GVA_StrongODR; break; + case ExternalASTSource::EK_Always: return GVA_AvailableExternally; + case ExternalASTSource::EK_ReplyHazy: break; } return L; } +GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const { + return adjustGVALinkageForExternalDefinitionKind(*this, FD, + adjustGVALinkageForAttributes(*this, FD, + basicGVALinkageForFunction(*this, FD))); +} + static GVALinkage basicGVALinkageForVariable(const ASTContext &Context, const VarDecl *VD) { if (!VD->isExternallyVisible()) @@ -9024,8 +9036,9 @@ static GVALinkage basicGVALinkageForVari } GVALinkage ASTContext::GetGVALinkageForVariable(const VarDecl *VD) { - return adjustGVALinkageForAttributes( - *this, basicGVALinkageForVariable(*this, VD), VD); + return adjustGVALinkageForExternalDefinitionKind(*this, VD, + adjustGVALinkageForAttributes(*this, VD, + basicGVALinkageForVariable(*this, VD))); } bool ASTContext::DeclMustBeEmitted(const Decl *D) { @@ -9108,9 +9121,14 @@ bool ASTContext::DeclMustBeEmitted(const return false; // Variables that can be needed in other TUs are required. - if (!isDiscardableGVALinkage(GetGVALinkageForVariable(VD))) + auto Linkage = GetGVALinkageForVariable(VD); + if (!isDiscardableGVALinkage(Linkage)) return true; + // We never need to emit a variable that is available in another TU. + if (Linkage == GVA_AvailableExternally) +return false; + // Variables that have destruction with side-effects are required. if (VD->getType().isDestructedType()) return true; Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=312665&r1=312664&r2=312665&view=diff ==
[PATCH] D36150: [clangd] LSP extension to switch between source/header file
Nebiroth updated this revision to Diff 114054. Nebiroth added a comment. Some more code cleanup. https://reviews.llvm.org/D36150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd/ProtocolHandlers.h @@ -48,6 +48,8 @@ JSONOutput &Out) = 0; virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, JSONOutput &Out) = 0; + virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID, +JSONOutput &Out) = 0; }; void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, Index: clangd/ProtocolHandlers.cpp === --- clangd/ProtocolHandlers.cpp +++ clangd/ProtocolHandlers.cpp @@ -204,6 +204,23 @@ ProtocolCallbacks &Callbacks; }; +struct SwitchSourceHeaderHandler : Handler { + SwitchSourceHeaderHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks) + : Handler(Output), Callbacks(Callbacks) {} + + void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override { +auto TDPP = TextDocumentIdentifier::parse(Params); +if (!TDPP) { + return; +} + +Callbacks.onSwitchSourceHeader(*TDPP, ID, Output); + } + +private: + ProtocolCallbacks &Callbacks; +}; + } // namespace void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, @@ -239,4 +256,7 @@ llvm::make_unique(Out, Callbacks)); Dispatcher.registerHandler("textDocument/definition", llvm::make_unique(Out, Callbacks)); + Dispatcher.registerHandler( + "textDocument/switchSourceHeader", + llvm::make_unique(Out, Callbacks)); } Index: clangd/ClangdServer.h === --- clangd/ClangdServer.h +++ clangd/ClangdServer.h @@ -182,6 +182,12 @@ /// Get definition of symbol at a specified \p Line and \p Column in \p File. Tagged> findDefinitions(PathRef File, Position Pos); + /// If an extension hasn't been found in the lowercase array, try with uppercase. + bool checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt); + + /// Helper function that returns a path to the corresponding source file when given a header file and vice versa. + llvm::Optional switchSourceHeader(PathRef Path); + /// Run formatting for \p Rng inside \p File. std::vector formatRange(PathRef File, Range Rng); /// Run formatting for the whole \p File. Index: clangd/ClangdServer.cpp === --- clangd/ClangdServer.cpp +++ clangd/ClangdServer.cpp @@ -15,9 +15,11 @@ #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +using namespace llvm; using namespace clang; using namespace clang::clangd; @@ -286,3 +288,89 @@ }); return make_tagged(std::move(Result), TaggedFS.Tag); } + + +bool ClangdServer::checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt) +{ + std::string UpperExtensions[ArraySize]; + for(int i = 0; i < ArraySize; i++) + { +UpperExtensions[i] = BaseArray[i]; + } + // Uppercase the whole array + for (std::string & s : UpperExtensions) + std::transform(s.begin(), s.end(), s.begin(), + [](unsigned char c) { return std::toupper(c); }); + + bool isUpperCase = false; + // Iterator such as std::begin won't work here so we use a standard loop + for(int i = 0; i < ArraySize; i++) + { +if (UpperExtensions[i] == PathExt.str()) +{ + isUpperCase = true; +} + } + return isUpperCase; +} + +llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) { + + StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx", ".c++", ".m", ".mm"}; + StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"}; + + StringRef PathExt = llvm::sys::path::extension(Path); + + // Lookup in a list of known extensions. + auto SourceIter = std::find(std::begin(SourceExtensions), std::end(SourceExtensions), PathExt); + bool IsSource = SourceIter != std::end(SourceExtensions); + + if (!IsSource) + { +IsSource = checkUpperCaseExtensions(SourceExtensions, llvm::array_lengthof(SourceExtensions), PathExt); + } + + auto HeaderIter = std::find(std::begin(HeaderExtensions), std::end(HeaderExtensions), PathExt); + bool IsHeader = HeaderIter != std::end(HeaderExtensions); + + if (!IsHeader) + { +IsHeader = checkUpperCaseExtensions(HeaderExtensions, llvm::array_lengthof(HeaderExtensions), PathExt); + } + + // We can only switch between extensions known extensions. + if (!IsSource && !IsHeader) +ret
[PATCH] D36150: [clangd] LSP extension to switch between source/header file
Nebiroth updated this revision to Diff 114048. Nebiroth added a comment. Remove unintentional file addition Updating D36150: [clangd] LSP extension to switch between source/header file ll# https://reviews.llvm.org/D36150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd/ProtocolHandlers.h @@ -48,6 +48,8 @@ JSONOutput &Out) = 0; virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, JSONOutput &Out) = 0; + virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID, +JSONOutput &Out) = 0; }; void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, Index: clangd/ProtocolHandlers.cpp === --- clangd/ProtocolHandlers.cpp +++ clangd/ProtocolHandlers.cpp @@ -204,6 +204,23 @@ ProtocolCallbacks &Callbacks; }; +struct SwitchSourceHeaderHandler : Handler { + SwitchSourceHeaderHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks) + : Handler(Output), Callbacks(Callbacks) {} + + void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override { +auto TDPP = TextDocumentIdentifier::parse(Params); +if (!TDPP) { + return; +} + +Callbacks.onSwitchSourceHeader(*TDPP, ID, Output); + } + +private: + ProtocolCallbacks &Callbacks; +}; + } // namespace void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, @@ -239,4 +256,7 @@ llvm::make_unique(Out, Callbacks)); Dispatcher.registerHandler("textDocument/definition", llvm::make_unique(Out, Callbacks)); + Dispatcher.registerHandler( + "textDocument/switchSourceHeader", + llvm::make_unique(Out, Callbacks)); } Index: clangd/ClangdServer.h === --- clangd/ClangdServer.h +++ clangd/ClangdServer.h @@ -182,6 +182,12 @@ /// Get definition of symbol at a specified \p Line and \p Column in \p File. Tagged> findDefinitions(PathRef File, Position Pos); + /// If an extension hasn't been found in the lowercase array, try with uppercase. + bool checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt); + + /// Helper function that returns a path to the corresponding source file when given a header file and vice versa. + llvm::Optional switchSourceHeader(PathRef Path); + /// Run formatting for \p Rng inside \p File. std::vector formatRange(PathRef File, Range Rng); /// Run formatting for the whole \p File. Index: clangd/ClangdServer.cpp === --- clangd/ClangdServer.cpp +++ clangd/ClangdServer.cpp @@ -15,9 +15,11 @@ #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +using namespace llvm; using namespace clang; using namespace clang::clangd; @@ -286,3 +288,84 @@ }); return make_tagged(std::move(Result), TaggedFS.Tag); } + + +bool ClangdServer::checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt) +{ + std::string UpperExtensions[ArraySize]; + for(int i = 0; i < ArraySize; i++) + { +UpperExtensions[i] = BaseArray[i]; + } + // Uppercase the whole array + for (std::string & s : UpperExtensions) + std::transform(s.begin(), s.end(), s.begin(), + [](unsigned char c) { return std::toupper(c); }); + + bool isUpperCase = false; + // Iterator such as std::begin won't work here so we use a standard loop + for(int i = 0; i < ArraySize; i++) + { +if (UpperExtensions[i] == PathExt.str()) +{ + isUpperCase = true; +} + } + return isUpperCase; +} + +llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) { + + StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx", ".c++", ".m", ".mm"}; + StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"}; + + StringRef PathExt = llvm::sys::path::extension(Path); + + // Lookup in a list of known extensions. + auto SourceIter = std::find(std::begin(SourceExtensions), std::end(SourceExtensions), PathExt); + bool IsSource = SourceIter != std::end(SourceExtensions); + + if (!IsSource) + { +IsSource = checkUpperCaseExtensions(SourceExtensions, llvm::array_lengthof(SourceExtensions), PathExt); + } + + auto HeaderIter = std::find(std::begin(HeaderExtensions), std::end(HeaderExtensions), PathExt); + bool IsHeader = HeaderIter != std::end(HeaderExtensions); + + if (!IsHeader) + { +IsHeader = checkUpperCaseExtensions(Heade
[PATCH] D36150: [clangd] LSP extension to switch between source/header file
Nebiroth updated this revision to Diff 114046. Nebiroth added a comment. Refactored switchSourceHeader function help from ilya Added helper function to check for uppercase on current file. https://reviews.llvm.org/D36150 Files: clangd/ClangdLSPServer.cpp clangd/ClangdServer.cpp clangd/ClangdServer.h clangd/ProtocolHandlers.cpp clangd/ProtocolHandlers.h test/clangd/hover.test Index: test/clangd/hover.test === --- /dev/null +++ test/clangd/hover.test @@ -0,0 +1,26 @@ +# RUN: clangd -run-synchronously < %s | FileCheck %s +# It is absolutely vital that this file has CRLF line endings. +# +Content-Length: 125 + +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +Content-Length: 172 + +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}} + +Content-Length: 143 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":5}}} +# Go to local variable +# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int main() {\nint a;\na;\n}"}, "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3, "character": 1 + +Content-Length: 143 + +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":5}}} +# Go to local variable +# CHECK: {"jsonrpc":"2.0","id":1,"result":{"contents": {"language": "C++", "value": "int a"}, "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1, "character": 5 + +Content-Length: 44 + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} Index: clangd/ProtocolHandlers.h === --- clangd/ProtocolHandlers.h +++ clangd/ProtocolHandlers.h @@ -48,6 +48,8 @@ JSONOutput &Out) = 0; virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID, JSONOutput &Out) = 0; + virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID, +JSONOutput &Out) = 0; }; void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out, Index: clangd/ProtocolHandlers.cpp === --- clangd/ProtocolHandlers.cpp +++ clangd/ProtocolHandlers.cpp @@ -204,6 +204,23 @@ ProtocolCallbacks &Callbacks; }; +struct SwitchSourceHeaderHandler : Handler { + SwitchSourceHeaderHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks) + : Handler(Output), Callbacks(Callbacks) {} + + void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override { +auto TDPP = TextDocumentIdentifier::parse(Params); +if (!TDPP) { + return; +} + +Callbacks.onSwitchSourceHeader(*TDPP, ID, Output); + } + +private: + ProtocolCallbacks &Callbacks; +}; + } // namespace void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, @@ -239,4 +256,7 @@ llvm::make_unique(Out, Callbacks)); Dispatcher.registerHandler("textDocument/definition", llvm::make_unique(Out, Callbacks)); + Dispatcher.registerHandler( + "textDocument/switchSourceHeader", + llvm::make_unique(Out, Callbacks)); } Index: clangd/ClangdServer.h === --- clangd/ClangdServer.h +++ clangd/ClangdServer.h @@ -182,6 +182,12 @@ /// Get definition of symbol at a specified \p Line and \p Column in \p File. Tagged> findDefinitions(PathRef File, Position Pos); + /// If an extension hasn't been found in the lowercase array, try with uppercase. + bool checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt); + + /// Helper function that returns a path to the corresponding source file when given a header file and vice versa. + llvm::Optional switchSourceHeader(PathRef Path); + /// Run formatting for \p Rng inside \p File. std::vector formatRange(PathRef File, Range Rng); /// Run formatting for the whole \p File. Index: clangd/ClangdServer.cpp === --- clangd/ClangdServer.cpp +++ clangd/ClangdServer.cpp @@ -15,9 +15,11 @@ #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include +using namespace llvm; using namespace clang; using namespace clang::clangd; @@ -286,3 +288,84 @@ }); return make_tagged(std::move(Result), TaggedFS.Tag); } + + +bool ClangdServer::checkUpperCaseExtensions(StringRef BaseArray[], int ArraySize, StringRef PathExt) +{ + std::string UpperExtensions[A
[PATCH] D37231: Add half load and store builtins
jvesely marked 2 inline comments as done. jvesely added inline comments. Comment at: test/CodeGenOpenCL/no-half.cl:27 + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float Anastasia wrote: > jvesely wrote: > > Anastasia wrote: > > > Minor thing: any reason you are not checking the load fully? > > just my laziness, I've added full check. > Could we do the same for the above examples too? I don't understand. if you mean test_store_*, those functions do not generate any load instructions. the full generated code is: test_store_double: ``` entry: %0 = fptrunc double %foo to half store half %0, half addrspace(1)* %bar, align 2 ret void ``` Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37231: Add half load and store builtins
Anastasia added inline comments. Comment at: test/CodeGenOpenCL/no-half.cl:27 + foo[0] = __builtin_load_halff(bar); +// CHECK: [[HALF_VAL:%.*]] = load +// CHECK: [[FULL_VAL:%.*]] = fpext half [[HALF_VAL]] to float jvesely wrote: > Anastasia wrote: > > Minor thing: any reason you are not checking the load fully? > just my laziness, I've added full check. Could we do the same for the above examples too? Repository: rL LLVM https://reviews.llvm.org/D37231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36410: [OpenCL] Handle taking address of block captures
Anastasia added a comment. In https://reviews.llvm.org/D36410#856907, @bader wrote: > In https://reviews.llvm.org/D36410#856716, @yaxunl wrote: > > > The captured variable is still passed by value. The address taking is on > > the duplicate of the captured variable, not on the original variable. > > > In this case address of captured variables should point to the private > address space, as function parameters reside in private address space (see > "6.5 Address Space Qualifiers" paragraph 3). This will only apply to blocks used as lambda functions though. But if they are enqueued using `enqueue_kernel` the captures should be accessible from the areas outside current thread too. https://reviews.llvm.org/D36410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37400: [StaticAnalyzer] Fix failures due to the iteration order of ExplodedNode
mgrang added a comment. Ping for reviews please. https://reviews.llvm.org/D37400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34512: Add preliminary Cross Translation Unit support library
dcoughlin added a comment. Thanks Gabor! Some additional comments in line. Comment at: include/clang/CrossTU/CrossTranslationUnit.h:118 + /// + /// \return Returns a map with the loaded AST Units and the declarations + /// with the definitions. Is this comment correct? Does it return a map? Comment at: include/clang/CrossTU/CrossTranslationUnit.h:128 + /// \brief This function merges a definition from a separate AST Unit into + ///the current one. + /// I found this comment confusing. Is 'Unit' the separate ASTUnit or it the current one? Comment at: include/clang/CrossTU/CrossTranslationUnit.h:134 + + std::string getLookupName(const NamedDecl *ND); + If this is public API, it deserves a comment. If not, can we make it private? Comment at: lib/CrossTU/CrossTranslationUnit.cpp:35 +namespace { +// FIXME: This class is will be removed after the transition to llvm::Error. +class IndexErrorCategory : public std::error_category { Is this FIXME still relevant? What will need to be transitioned to llvm::Error for it to be removed? Can you make the comment a bit more specific so that future maintainers will know when/how to address the FIXME? Comment at: lib/CrossTU/CrossTranslationUnit.cpp:194 +handleAllErrors(IndexOrErr.takeError(), [&](const IndexError &IE) { + (bool)PropagatedErr; + PropagatedErr = What is this cast for? Is it to suppress an analyzer dead store false positive? I thought we got all those! Comment at: lib/CrossTU/CrossTranslationUnit.cpp:199 + case index_error_code::missing_index_file: +Context.getDiagnostics().Report(diag::err_fe_error_opening) +<< ExternalFunctionMap If I understand correctly, there is no way to call loadExternalAST() without the potential for a diagnostic showing up to the user. Can this diagnostic emission be moved to the client? Comment at: lib/CrossTU/CrossTranslationUnit.cpp:249 +CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD, + ASTUnit *Unit) { + ASTImporter &Importer = getOrCreateASTImporter(Unit->getASTContext()); Does this method need to take the unit? Can it just get the ASTContext from 'FD'? If not, can we add an assertion that FD has the required relationship to Unit? (And document it in the header doc.) Comment at: tools/clang-func-mapping/ClangFnMapGen.cpp:56 +private: + std::string getLookupName(const FunctionDecl *FD); + void handleDecl(const Decl *D); Is getLookupName() here used? Comment at: tools/clang-func-mapping/ClangFnMapGen.cpp:72 +SmallString<128> LookupName; +bool Res = index::generateUSRForDecl(D, LookupName); +assert(!Res); Should this instead reuse the logic for generating a lookup name from CrossTranslationUnitContext::getLookupName()? That way if we change how the lookup name is generated we only have to do it in one place. https://reviews.llvm.org/D34512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37493: Fix ARM bare metal driver to support atomics
jroelofs closed this revision. jroelofs added a comment. r312651 https://reviews.llvm.org/D37493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312651 - Fix ARM bare metal driver to support atomics
Author: jroelofs Date: Wed Sep 6 10:09:25 2017 New Revision: 312651 URL: http://llvm.org/viewvc/llvm-project?rev=312651&view=rev Log: Fix ARM bare metal driver to support atomics The new bare metal support only supports the single thread model. This causes the builtin atomic functions (e.g.: __atomic_fetch_add) to not generate thread-safe assembly for these operations, which breaks our firmware. We target bare metal, and need to atomically modify variables in our interrupt routines, and task threads. Internally, the -mthread-model flag determines whether to lower or expand atomic operations (see D4984). This change removes the overridden thread model methods, and instead relies on the base ToolChain class to validate the thread model (which already includes logic to validate single thread model support). If the single thread model is required, the -mthread-model flag will have to be provided. As a workaround "-mthread-model posix" could be provided, but it only works due to a bug in the validation of the -mthread-model flag (separate patch coming to fix this). https://reviews.llvm.org/D37493 Patch by: Ian Tessier! Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp cfe/trunk/lib/Driver/ToolChains/BareMetal.h cfe/trunk/test/Driver/baremetal.cpp Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp?rev=312651&r1=312650&r2=312651&view=diff == --- cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/BareMetal.cpp Wed Sep 6 10:09:25 2017 @@ -65,14 +65,6 @@ Tool *BareMetal::buildLinker() const { return new tools::baremetal::Linker(*this); } -std::string BareMetal::getThreadModel() const { - return "single"; -} - -bool BareMetal::isThreadModelSupported(const StringRef Model) const { - return Model == "single"; -} - std::string BareMetal::getRuntimesDir() const { SmallString<128> Dir(getDriver().ResourceDir); llvm::sys::path::append(Dir, "lib", "baremetal"); Modified: cfe/trunk/lib/Driver/ToolChains/BareMetal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/BareMetal.h?rev=312651&r1=312650&r2=312651&view=diff == --- cfe/trunk/lib/Driver/ToolChains/BareMetal.h (original) +++ cfe/trunk/lib/Driver/ToolChains/BareMetal.h Wed Sep 6 10:09:25 2017 @@ -38,8 +38,6 @@ public: bool isPICDefaultForced() const override { return false; } bool SupportsProfiling() const override { return false; } bool SupportsObjCGC() const override { return false; } - std::string getThreadModel() const override; - bool isThreadModelSupported(const StringRef Model) const override; RuntimeLibType GetDefaultRuntimeLibType() const override { return ToolChain::RLT_CompilerRT; Modified: cfe/trunk/test/Driver/baremetal.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/baremetal.cpp?rev=312651&r1=312650&r2=312651&view=diff == --- cfe/trunk/test/Driver/baremetal.cpp (original) +++ cfe/trunk/test/Driver/baremetal.cpp Wed Sep 6 10:09:25 2017 @@ -74,4 +74,12 @@ // RUN: %clangxx -target arm-none-eabi -v 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL -// CHECK-THREAD-MODEL: Thread model: single +// CHECK-THREAD-MODEL: Thread model: posix + +// RUN: %clangxx -target arm-none-eabi -mthread-model single -v 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL-SINGLE +// CHECK-THREAD-MODEL-SINGLE: Thread model: single + +// RUN: %clangxx -target arm-none-eabi -mthread-model posix -v 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL-POSIX +// CHECK-THREAD-MODEL-POSIX: Thread model: posix ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
hamzasood added a comment. Ping https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37496: Fix validation of the -mthread-model flag in the Clang driver
itessier added a comment. In https://reviews.llvm.org/D37496#861746, @compnerd wrote: > The change looks good. Can you please add some test cases for this? Or do > existing test cases cover this already? Should have added this to the description, but yes there are existing tests that cover this flag (test/Driver/thread-model.c). https://reviews.llvm.org/D37493 removes the only overridden thread model methods so we can't test the fix in this CL. https://reviews.llvm.org/D37496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37493: Fix ARM bare metal driver to support atomics
jroelofs added a comment. Sure. I'll commit it for you once this build/test cycle is finished. https://reviews.llvm.org/D37493 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37521: [Sema][Typo correction] Assertion failure in typo correction if chain of member function calls has multiple typos
iid_iunknown created this revision. This is a patch proposal for PR34507. Typo resolution can create new TypoExprs while transforming an expression. These TypoExprs are not transformed, they are present in the resulting expression and cause the `DelayedTypos.empty() && "Uncorrected typos!"` assertion failure in `clang::Sema::~Sema()`. If clang is built without assertions, these TypoExprs are not reported causing incomplete diagnostics. The patch checks the transformed expression for new TypoExprs and, if any found, transforms the expression again until either all TypoExprs are handled or the result becomes invalid. Repository: rL LLVM https://reviews.llvm.org/D37521 Files: lib/Sema/SemaExprCXX.cpp test/Sema/typo-correction-multiple-typos.cpp Index: test/Sema/typo-correction-multiple-typos.cpp === --- test/Sema/typo-correction-multiple-typos.cpp +++ test/Sema/typo-correction-multiple-typos.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// This file contains typo correction test which ensures that +// multiple typos in a single member calls chain are correctly +// diagnosed. + +class X +{ +public: + void foo() const; // expected-note {{'foo' declared here}} +}; + +class Y +{ +public: + const X& getX() const { return m_x; } // expected-note {{'getX' declared here}} + int getN() const { return m_n; } +private: + X m_x; + int m_n; +}; + +class Z +{ +public: + const Y& getY0() const { return m_y0; } // expected-note {{'getY0' declared here}} + const Y& getY1() const { return m_y1; } + +private: + Y m_y0; + Y m_y1; +}; + +Z z_obj; + +void test() +{ + z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}} +getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}} +foe(); // expected-error {{no member named 'foe' in 'X'; did you mean 'foo'}} +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -7362,6 +7362,30 @@ break; } +// The transform is able to produce new TypoExprs while resolving the typos. +// These new TypoExprs are not resolved by the transform, they do not get +// into the TypoExprs container and are not reported, so they need to be +// handled separately. +// If the transform result is valid and contains newly created TypoExprs, +// transform the result expression again until no new TypoExprs get created +// or the result becomes an invalid expression. Return the longest valid +// expression to report as many typos as possible. +if (!Res.isInvalid()) { + while (true) { +unsigned TyposCount = TypoExprs.size(); +FindTypoExprs(TypoExprs).TraverseStmt(Res.get()); +if (TypoExprs.size() == TyposCount) + // No new TypoExprs created by the transform + break; +ExprResult TmpRes = TryTransform(Res.get()); +if (TmpRes.isInvalid()) + // Further transform prodices an invalid Expr. + // Stop with the last valid result. + break; +Res = TmpRes; + } +} + // Ensure none of the TypoExprs have multiple typo correction candidates // with the same edit length that pass all the checks and filters. // TODO: Properly handle various permutations of possible corrections when Index: test/Sema/typo-correction-multiple-typos.cpp === --- test/Sema/typo-correction-multiple-typos.cpp +++ test/Sema/typo-correction-multiple-typos.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// This file contains typo correction test which ensures that +// multiple typos in a single member calls chain are correctly +// diagnosed. + +class X +{ +public: + void foo() const; // expected-note {{'foo' declared here}} +}; + +class Y +{ +public: + const X& getX() const { return m_x; } // expected-note {{'getX' declared here}} + int getN() const { return m_n; } +private: + X m_x; + int m_n; +}; + +class Z +{ +public: + const Y& getY0() const { return m_y0; } // expected-note {{'getY0' declared here}} + const Y& getY1() const { return m_y1; } + +private: + Y m_y0; + Y m_y1; +}; + +Z z_obj; + +void test() +{ + z_obj.getY2(). // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}} +getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}} +foe(); // expected-error {{no member named 'foe' in 'X'; did you mean 'foo'}} +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -7362,6 +7362,30 @@ break; } +// The transform is able to produce new TypoExprs while resolving the typos. +// These new TypoExprs
[PATCH] D37310: [Atomic] Merge alignment information from Decl and from Type when emit atomic expression.
wmi added a comment. Ping Repository: rL LLVM https://reviews.llvm.org/D37310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37302: [Headers] Define *_HAS_SUBNORM for FLT, DBL, LDBL
pirama added a comment. Ping... https://reviews.llvm.org/D37302 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312642 - [OPENMP] Fix for PR33922: New ident_t flags for
Author: abataev Date: Wed Sep 6 09:17:35 2017 New Revision: 312642 URL: http://llvm.org/viewvc/llvm-project?rev=312642&view=rev Log: [OPENMP] Fix for PR33922: New ident_t flags for __kmpc_for_static_fini(). Added special flags for calls of __kmpc_for_static_fini(), like previous ly for __kmpc_for_static_init(). Added flag OMP_IDENT_WORK_DISTRIBUTE for distribute cnstruct, OMP_IDENT_WORK_SECTIONS for sections-based constructs and OMP_IDENT_WORK_LOOP for loop-based constructs in location flags. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp cfe/trunk/test/OpenMP/distribute_codegen.cpp cfe/trunk/test/OpenMP/for_codegen.cpp cfe/trunk/test/OpenMP/parallel_for_codegen.cpp cfe/trunk/test/OpenMP/sections_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=312642&r1=312641&r2=312642&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Sep 6 09:17:35 2017 @@ -3059,11 +3059,19 @@ void CGOpenMPRuntime::emitDistributeStat } void CGOpenMPRuntime::emitForStaticFinish(CodeGenFunction &CGF, - SourceLocation Loc) { + SourceLocation Loc, + OpenMPDirectiveKind DKind) { if (!CGF.HaveInsertPoint()) return; // Call __kmpc_for_static_fini(ident_t *loc, kmp_int32 tid); - llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)}; + llvm::Value *Args[] = { + emitUpdateLocation(CGF, Loc, + isOpenMPDistributeDirective(DKind) + ? OMP_IDENT_WORK_DISTRIBUTE + : isOpenMPLoopDirective(DKind) + ? OMP_IDENT_WORK_LOOP + : OMP_IDENT_WORK_SECTIONS), + getThreadID(CGF, Loc)}; CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_for_static_fini), Args); } Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=312642&r1=312641&r2=312642&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed Sep 6 09:17:35 2017 @@ -883,8 +883,10 @@ public: /// /// \param CGF Reference to current CodeGenFunction. /// \param Loc Clang source location. + /// \param DKind Kind of the directive for which the static finish is emitted. /// - virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc); + virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc, + OpenMPDirectiveKind DKind); /// Call __kmpc_dispatch_next( /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter, Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=312642&r1=312641&r2=312642&view=diff == --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Sep 6 09:17:35 2017 @@ -1692,7 +1692,8 @@ void CodeGenFunction::EmitOMPOuterLoop( // Tell the runtime we are done. auto &&CodeGen = [DynamicOrOrdered, &S](CodeGenFunction &CGF) { if (!DynamicOrOrdered) - CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd()); + CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(), + S.getDirectiveKind()); }; OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen); } @@ -2256,7 +2257,8 @@ bool CodeGenFunction::EmitOMPWorksharing EmitBlock(LoopExit.getBlock()); // Tell the runtime we are done. auto &&CodeGen = [&S](CodeGenFunction &CGF) { - CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd()); + CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(), + S.getDirectiveKind()); }; OMPCancelStack.emitExit(*this, S.getDirectiveKind(), CodeGen); } else { @@ -2487,7 +2489,8 @@ void CodeGenFunction::EmitSections(const [](CodeGenFunction &) {}); // Tell the runtime we are done. auto &&CodeGen = [&S](CodeGenFunction &CGF) { - CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd()); + CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, S.getLocEnd(), + S.getDire
[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files
cameron314 updated this revision to Diff 114016. cameron314 added a comment. Here's an updated patch that allows only the PCH to be accessed from the real FS when a VSF is present. Tests still pass. https://reviews.llvm.org/D37474 Files: lib/Frontend/ASTUnit.cpp unittests/Frontend/CMakeLists.txt unittests/Frontend/PchPreambleTest.cpp Index: unittests/Frontend/PchPreambleTest.cpp === --- /dev/null +++ unittests/Frontend/PchPreambleTest.cpp @@ -0,0 +1,156 @@ +//-- unittests/Frontend/PchPreambleTest.cpp - FrontendAction tests ---// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Frontend/ASTUnit.h" +#include "clang/Frontend/CompilerInvocation.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/Frontend/FrontendOptions.h" +#include "clang/Lex/PreprocessorOptions.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/FileManager.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" +#include "gtest/gtest.h" + +using namespace llvm; +using namespace clang; + +namespace { + +class ReadCountingInMemoryFileSystem : public vfs::InMemoryFileSystem +{ + std::map ReadCounts; + +public: + ErrorOr> openFileForRead(const Twine &Path) override + { +SmallVector PathVec; +Path.toVector(PathVec); +llvm::sys::path::remove_dots(PathVec, true); +++ReadCounts[std::string(PathVec.begin(), PathVec.end())]; +return InMemoryFileSystem::openFileForRead(Path); + } + + unsigned GetReadCount(const Twine &Path) const + { +auto it = ReadCounts.find(Path.str()); +return it == ReadCounts.end() ? 0 : it->second; + } +}; + +class PchPreambleTest : public ::testing::Test { + IntrusiveRefCntPtr VFS; + StringMap RemappedFiles; + std::shared_ptr PCHContainerOpts; + FileSystemOptions FSOpts; + +public: + void SetUp() override { +VFS = new ReadCountingInMemoryFileSystem(); +// We need the working directory to be set to something absolute, +// otherwise it ends up being inadvertently set to the current +// working directory in the real file system due to a series of +// unfortunate conditions interacting badly. +// What's more, this path *must* be absolute on all (real) +// filesystems, so just '/' won't work (e.g. on Win32). +VFS->setCurrentWorkingDirectory("//./"); + } + + void TearDown() override { + } + + void AddFile(const std::string &Filename, const std::string &Contents) { +::time_t now; +::time(&now); +VFS->addFile(Filename, now, MemoryBuffer::getMemBufferCopy(Contents, Filename)); + } + + void RemapFile(const std::string &Filename, const std::string &Contents) { +RemappedFiles[Filename] = Contents; + } + + std::unique_ptr ParseAST(const std::string &EntryFile) { +PCHContainerOpts = std::make_shared(); +std::shared_ptr CI(new CompilerInvocation); +CI->getFrontendOpts().Inputs.push_back( + FrontendInputFile(EntryFile, FrontendOptions::getInputKindForExtension( +llvm::sys::path::extension(EntryFile).substr(1; + +CI->getTargetOpts().Triple = "i386-unknown-linux-gnu"; + +CI->getPreprocessorOpts().RemappedFileBuffers = GetRemappedFiles(); + +PreprocessorOptions &PPOpts = CI->getPreprocessorOpts(); +PPOpts.RemappedFilesKeepOriginalName = true; + +IntrusiveRefCntPtr + Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, new DiagnosticConsumer)); + +FileManager *FileMgr = new FileManager(FSOpts, VFS); + +std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation( + CI, PCHContainerOpts, Diags, FileMgr, false, false, + /*PrecompilePreambleAfterNParses=*/1); +return AST; + } + + bool ReparseAST(const std::unique_ptr &AST) { +bool reparseFailed = AST->Reparse(PCHContainerOpts, GetRemappedFiles(), VFS); +return !reparseFailed; + } + + unsigned GetFileReadCount(const std::string &Filename) const { +return VFS->GetReadCount(Filename); + } + +private: + std::vector> + GetRemappedFiles() const { +std::vector> Remapped; +for (const auto &RemappedFile : RemappedFiles) { + std::unique_ptr buf = MemoryBuffer::getMemBufferCopy( +RemappedFile.second, RemappedFile.first()); + Remapped.emplace_back(RemappedFile.first(), buf.release()); +} +return Remapped; + } +}; + +TEST_F(PchPreambleTest, ReparseWithOverriddenFileDoesNotInvalidatePreamble) { + std::string Header1 = "//./header1.h"; + std::string Header2 = "//./header2.h"; + std::string MainName = "//./main.cpp"; + AddFile(Header1, ""); + AddFile(Header2, "#pragma once"); + AddFile(MainName, +"#include \"//./foo/../header1.h\"\n" +
[PATCH] D33719: Add _Float16 as a C/C++ source language type
SjoerdMeijer added a comment. I am going to commit this within a few days. That looks reasonable to me given that the comments in the last reviews were very minor (which I have of course addressed already). Also, in case of issues, I am guessing fixes and/or addition can be easily done post-commit, and if not a revert is cheap. Committing this allows me to make some progress on the FP16 work. I have mostly fixed up the AArch64 back-end, and will now focus on ARM and the remaining Clang patches (documentation). Comments are still welcome of course, which I then will address before committing. https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
On Wed, Sep 6, 2017 at 11:22 AM, Philip Douglas via Phabricator via cfe-commits wrote: > pdouglas added a comment. > > Hi, > > This change is not building on Windows, because the Visual C++ compiler > doesn't support `or` (instead of `||`) by default. (See > https://msdn.microsoft.com/en-us/library/f355wky8.aspx#Operator%20Keyword%20for%20||) > > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): > error C2146: syntax error: missing ')' before identifier 'or' > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): > error C2065: 'or': undeclared identifier > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): > error C2143: syntax error: missing ';' before '' > > C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(73): > fatal error C1075: the left brace '{' was unmatched at the end of the file > > Full log: > http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/6980/steps/ninja%20check%201/logs/stdio I corrected this in r312639. ~Aaron > > > Repository: > rL LLVM > > https://reviews.llvm.org/D36998 > > > > ___ > 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] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
pdouglas added a comment. Hi, This change is not building on Windows, because the Visual C++ compiler doesn't support `or` (instead of `||`) by default. (See https://msdn.microsoft.com/en-us/library/f355wky8.aspx#Operator%20Keyword%20for%20||) C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): error C2146: syntax error: missing ')' before identifier 'or' C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): error C2065: 'or': undeclared identifier C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(86): error C2143: syntax error: missing ';' before '' C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\llvm\tools\clang\unittests\Tooling\LexicallyOrderedRecursiveASTVisitorTest.cpp(73): fatal error C1075: the left brace '{' was unmatched at the end of the file Full log: http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/6980/steps/ninja%20check%201/logs/stdio Repository: rL LLVM https://reviews.llvm.org/D36998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312639 - Replacing "or" with "||" to appease MSVC.
Author: aaronballman Date: Wed Sep 6 08:12:05 2017 New Revision: 312639 URL: http://llvm.org/viewvc/llvm-project?rev=312639&view=rev Log: Replacing "or" with "||" to appease MSVC. Modified: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Modified: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp?rev=312639&r1=312638&r2=312639&view=diff == --- cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp (original) +++ cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Wed Sep 6 08:12:05 2017 @@ -83,7 +83,7 @@ bool LexicallyOrderedDeclVisitor::VisitN OS << ND->getNameAsString(); else OS << "???"; -if (isa(D) or isa(D)) +if (isa(D) || isa(D)) OS << "/"; } if (EmitDeclIndices) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] Add support for snippet completions
rwols marked an inline comment as done. rwols added inline comments. Comment at: clangd/tool/ClangdMain.cpp:33 + "present plaintext completions."), +llvm::cl::init(false)); + ilya-biryukov wrote: > After putting some thought into it, let's disable snippets by default. Sorry > for driving this in a wrong direction in my previous comments. > Instead of using flag, LSP servers should look at initial `initialize` > request and a value of > `TextDocumentClientCapabilities.completion.completionItem.snippetSupport`. > (see > https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize-request). > And it seems bad from clangd side to break clients that don't support > snippets **by default**. It's probably ok if user passed custom command-line > arguments, overriding the defaults. > > The problem is that we don't parse the `ClientCapabilities` now. It's not > hard to add parsing of it, but that should probably be done in a separate > commit and I can do this work if you want. > I think it's fine to commit this as is, **defaulting to not return > snippets**, and add parsing of `ClientCapabilities` with a follow-up commit. Yes, I agree snippets should be enabled/disabled by reading the client's capabilities. This command line flag should be a temporary solution. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] Add support for snippet completions
ilya-biryukov added inline comments. Comment at: clangd/ClangdUnit.cpp:376 + +CompletionItem Item{InsertTextFormat::PlainText}; + rwols wrote: > ilya-biryukov wrote: > > Implementations of this function in `PlainTextCompletionItemsCollector` and > > `SnippetCompletionItemsCollector` are the same. > > Maybe make `ProcessChunks` virtual instead? > > > > Or maybe consider replacing inheritance with a `bool` flag. Inheritance > > does not seem to buy us much here. This looks simpler: > > ``` > > if (EnableSnippets) > > ProcessChunksWithSnippets(CCS, Item); > > else > > ProcessChunksWithoutSnippets(CCS, Item); > > > > ``` > > > > > I went with the "make ProcessChunks virtual" approach, wouldn't your > suggestion have an impact on performance? There'd be a check for every > completion item now. Oh, that should not make any difference performance-wise. There is many more branching on each completion item even if we assume all the function calls are inlined. And virtual calls are not free either. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312638 - [OPENMP] Fix for PR34445: Reduction initializer segfaults at runtime in
Author: abataev Date: Wed Sep 6 07:49:58 2017 New Revision: 312638 URL: http://llvm.org/viewvc/llvm-project?rev=312638&view=rev Log: [OPENMP] Fix for PR34445: Reduction initializer segfaults at runtime in move constructor. Previously user-defined reduction initializer was considered as an assignment expression, not as initializer. Fixed this by treating the initializer expression as an initializer. Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/DeclPrinter.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/test/OpenMP/declare_reduction_messages.cpp Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=312638&r1=312637&r2=312638&view=diff == --- cfe/trunk/include/clang/AST/DeclOpenMP.h (original) +++ cfe/trunk/include/clang/AST/DeclOpenMP.h Wed Sep 6 07:49:58 2017 @@ -100,12 +100,22 @@ public: /// /// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an initializer. class OMPDeclareReductionDecl final : public ValueDecl, public DeclContext { +public: + enum InitKind { +CallInit, // Initialized by function call. +DirectInit, // omp_priv() +CopyInit// omp_priv = + }; + private: friend class ASTDeclReader; /// \brief Combiner for declare reduction construct. Expr *Combiner; /// \brief Initializer for declare reduction construct. Expr *Initializer; + /// Kind of initializer - function call or omp_priv initializtion. + InitKind InitializerKind = CallInit; + /// \brief Reference to the previous declare reduction construct in the same /// scope with the same name. Required for proper templates instantiation if /// the declare reduction construct is declared inside compound statement. @@ -117,7 +127,8 @@ private: DeclarationName Name, QualType Ty, OMPDeclareReductionDecl *PrevDeclInScope) : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr), -Initializer(nullptr), PrevDeclInScope(PrevDeclInScope) {} +Initializer(nullptr), InitializerKind(CallInit), +PrevDeclInScope(PrevDeclInScope) {} void setPrevDeclInScope(OMPDeclareReductionDecl *Prev) { PrevDeclInScope = Prev; @@ -142,8 +153,13 @@ public: /// construct. Expr *getInitializer() { return Initializer; } const Expr *getInitializer() const { return Initializer; } + /// Get initializer kind. + InitKind getInitializerKind() const { return InitializerKind; } /// \brief Set initializer expression for the declare reduction construct. - void setInitializer(Expr *E) { Initializer = E; } + void setInitializer(Expr *E, InitKind IK) { +Initializer = E; +InitializerKind = IK; + } /// \brief Get reference to previous declare reduction construct in the same /// scope with the same name. Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=312638&r1=312637&r2=312638&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Wed Sep 6 07:49:58 2017 @@ -2613,6 +2613,9 @@ private: Decl *TagDecl = nullptr); /// \brief Parse 'omp declare reduction' construct. DeclGroupPtrTy ParseOpenMPDeclareReductionDirective(AccessSpecifier AS); + /// Parses initializer for provided omp_priv declaration inside the reduction + /// initializer. + void ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm); /// \brief Parses simple list of variables. /// Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=312638&r1=312637&r2=312638&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 6 07:49:58 2017 @@ -8588,9 +8588,11 @@ public: /// \brief Finish current declare reduction construct initializer. void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner); /// \brief Initialize declare reduction construct initializer. - void ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D); + /// \return omp_priv variable. + VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D); /// \brief Finish current declare reduction construct initializer. - void ActOnOpenMPDecla
[PATCH] D37474: [PCH] Allow VFS to be used for tests that generate PCH files
cameron314 added a comment. I'll change the overlay to only allow access to the PCH. I agree that it would be nice to only read the PCH using real filesystem APIs in order to be symmetrical, but this seems non-trivial. It also feels like a step in the wrong direction -- ideally the VFS would hold the PCH too instead of putting it on disk, in my opinion. I'm not sure adding a remapped file buffer would work, since it's unclear to me exactly at which point the PCH is written relative to the multiple places it's read. Additionally, there's code that does directory traversal in the current VFS to find a PCH when given a directory name instead of a file name; this only works if the VFS is aware of the PCH, or if the code is rewritten to use the underlying file system. https://reviews.llvm.org/D37474 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)
cameron314 added a comment. Thanks for the response! > How are various preprocessor offests (and SourceLocation offsets) are > calculated? Do they account for BOM presence and ignore it? Everything is in byte offsets; the `SourceLocation` after the BOM is not the same as before the BOM. The lexer automatically skips the BOM at the beginning of the file if it sees one (`Lexer::InitLexer`), and everything else works normally after that. The start of the first line is after the BOM, if any, which means it doesn't affect line/column numbers. > Are there potential problems we may run into because of the changing offsets? > Could we add tests checking changing the offsets does not matter? That's a good point; I've looked into it and the PCH for the preamble is parsed using just the buffer slice that contains the preamble, excluding any BOM. That means that when we resume parsing later on a main buffer with a BOM, the `SourceLocation`s within the preamble itself will be off. However, normally this doesn't matter since the only things in the preamble are preprocessor directives, whose positions are very rarely used. (I should note at this point that we've been using a variant of this patch in production for a few years without any problem.) So, we have two choices: Either parse the preamble with the BOM and throw out the preamble/PCH when the BOM presence changes from the main buffer, or slice the buffer when using a preamble PCH so that it never has a BOM during parsing. I'm leaning towards the second option, since it's a little cleaner and lets the preamble be reused more easily; the only downside is that an external consumer would not be able to use any absolute offsets from the AST (note that line/column offsets would be identical) in the original buffer if it has a BOM -- but in any case, absolute offsets are usually useless without the buffer itself, which if obtained from clang would always be the correct buffer. > Should we add checks that BOM was removed or added, but not changed? I would > not expect preamble to be reusable "as is" if BOM (and therefore, input > encoding) changed. I'm not sure I understand this point. Clang only understands UTF-8; the BOM is either present or not, but the encoding never changes. (And the BOM itself is always the same byte sequence too.) It has no impact on the file contents. Comment at: include/clang/Frontend/PrecompiledPreamble.h:102 + /// appears or disappears between parses). + void UpdateOffset(unsigned NewOffset); + ilya-biryukov wrote: > Let's leave this class's interface immutable. It is used concurrently in > clangd and having a mutable method like this would break the code. > > Passing new `PreambleBounds` to `AddImplicitPreamble` and setting the offsets > accordingly would do the trick, leave the interface immutable and make the > fact that offsets might change more evident. Fair point, I'll change this. Comment at: include/clang/Frontend/PrecompiledPreamble.h:191 bool PreambleEndsAtStartOfLine; + /// The start offset of the bounds used to build the preamble. + unsigned PreambleOffset; ilya-biryukov wrote: > Let's store original `PreambleBounds` instead of `PreambleEndsAtStartOfLine` > and `PreambleOffset`. > It would make the code easier to read. Again, good point, I'll change this. Comment at: include/clang/Lex/Lexer.h:50 + /// \brief Start offset of the preamble, in bytes. + unsigned StartOffset; + /// \brief Size of the preamble in bytes. ilya-biryukov wrote: > Maybe pick a name that clearly states that it's a `BOM` size? > Or add a comment indicating that it's a `BOM` offset. I can see how this might be confusing. I'll add a comment. Comment at: include/clang/Lex/Lexer.h:639 - void SkipBytes(unsigned Bytes, bool StartOfLine); + void SetByteOffset(unsigned Offset, bool StartOfLine); ilya-biryukov wrote: > Maybe leave the old name? Doesn't `SkipBytes` captures the new semantics just > as good? `SkipBytes` moves relative to the current position, but the lexer skips the BOM implicitly on construction; I don't want to skip it twice. `SetByteOffset` is absolute, which makes it simple and clear to use without having to reason about implicit past state. Comment at: lib/Frontend/PrecompiledPreamble.cpp:195 PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts, llvm::MemoryBuffer *Buffer, ilya-biryukov wrote: > Could you inline usages of this function and remove it? > I could; I think it makes sense to leave the wrapper, though, since the `ASTUnit` deals with the `PrecompiledPreamble` at its level of abstraction, and the `PrecompiledPreamble` deals with the lexer at its level of abstraction. Comment at: unittests/Frontend/PchPreambleTest.cpp:19
[PATCH] D37479: run-clang-tidy: Report progress
Eugene.Zelenko added a comment. I think CMake output is good model for run-clang-tidy. https://reviews.llvm.org/D37479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35533: [Basic] Update CMakeLists.txt to handle Repo with git
hintonda added a comment. Now that 36971 has been committed, I believe you can just remove the `find_first_existing_file` and `find_first_existing_vc_file` macro definitions from this file. https://reviews.llvm.org/D35533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37150: [clangd] Command line arg to specify compile_commands.json path
ilya-biryukov added a comment. See my comments. Could you also `clang-format` the code please? Comment at: clangd/ClangdServer.cpp:150 bool RunSynchronously, + std::string CompileCommands, llvm::Optional ResourceDir) Could you pass `llvm::Optional` instead (`Path` is just a descriptive typedef that we use in place of `std::string`) and check for empty string in `main()`? Comment at: clangd/GlobalCompilationDatabase.cpp:30 +static cl::opt CompileCommands("compileCommands", + cl::desc("Start with absolute path to compile_commands.json")); +} ilya-biryukov wrote: > A description is somewhat vague. What is the intention of this flag? > - Always look for `compile_commands.json` only inside specified directory? > - First look inside specified directory, then proceed as normal (i.e. looking > at the parent paths of each source file)? > > It looks like the code also looks at the parent directories of > `compile-commands`. Is that the original intention? Maybe consider making it > look only inside the directory itself and not its parents? How about chaning semantics of the flag to **only** look inside `"--compile-commands-dir"` and not its parent paths? I think it makes the behavior much less surprising. The whole point of looking in parent paths is that typically `compile_commands.json` is put inside the project root. The flag that you propose seems to have a different purpose of providing `clangd` with custom compilation flags. Comment at: clangd/GlobalCompilationDatabase.cpp:14 #include "llvm/Support/Path.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" There are definitely unneeded includes here. Remove most of them and leave only the required ones? Comment at: clangd/GlobalCompilationDatabase.cpp:93 + namespace path = llvm::sys::path; + if (llvm::sys::fs::exists(CompileCommands)) +File = CompileCommands; Let's simply lookup **only** inside `CompileCommandsDir` if it was set. Otherwise, fallback into looking at `parent_path`s of the file. Comment at: clangd/GlobalCompilationDatabase.h:38 getCompileCommands(PathRef File) = 0; + std::string CompileCommands; `GlobalCompilationDatabase` is an interface class and is designed specifically to not contain any fields. Could you please do the following? - Move this field into `DirectoryBasedGlobalCompilationDatabase`. - Make it private and initialize it in constructor. Comment at: clangd/tool/ClangdMain.cpp:29 +static llvm::cl::opt +CompileCommands("compile-commands-dir", Could you use descriptive `Path` typedef instead of `std::string` here and in other places? Comment at: clangd/tool/ClangdMain.cpp:30 +static llvm::cl::opt +CompileCommands("compile-commands-dir", + llvm::cl::desc("Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file.")); Maybe rename this (and other occurences) to `CompileCommandsDir`? Comment at: clangd/tool/ClangdMain.cpp:43 + namespace path = llvm::sys::path; + if (!llvm::sys::path::is_absolute(CompileCommands) || CompileCommands.empty()) +Logs << "Path specified for compilation database must be absolute. Verifying current folder instead."; - `CompileCommands` is empty by default, don't show the error message in that case. - If value of `CompileCommands` is not absolute or the path does not exist, set `CompileCommands` to empty string after reporting an error. Comment at: clangd/tool/ClangdMain.cpp:44 + if (!llvm::sys::path::is_absolute(CompileCommands) || CompileCommands.empty()) +Logs << "Path specified for compilation database must be absolute. Verifying current folder instead."; + Maybe rephrase the message a little bit, mentioning the name of the flag. Something like: `"Value of --compile-commands-dir must be an absolute path. The argument will be ignored."` https://reviews.llvm.org/D37150 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37513: [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
djasper added a comment. Note that these changes need to be made to the corresponding comments in include/clang/Format/Format.h and then this file is auto-generated with docs/tools/dump_format_style.py. Comment at: docs/ClangFormatStyleOptions.rst:274 **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line Much better phrasing, thank you. Comment at: docs/ClangFormatStyleOptions.rst:278 + + This applies to declaration, whose parameters fit on a single line. I think this sentence does not add value. Comment at: docs/ClangFormatStyleOptions.rst:283 +true: +int SomeFunctionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { I think we should keep the example as short as it was previously (it is reproducible with a very short column limit), but you are right that the example was broken. So I suggest making this: void myFunction( int a, int b, int c); vs. void myFunction( int a, int b, int c); https://reviews.llvm.org/D37513 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
This revision was automatically updated to reflect the committed changes. Closed by commit rL312634: [AST] Add TableGen for StmtDataCollectors (authored by krobelus). Changed prior to commit: https://reviews.llvm.org/D37383?vs=113547&id=114000#toc Repository: rL LLVM https://reviews.llvm.org/D37383 Files: cfe/trunk/include/clang/AST/CMakeLists.txt cfe/trunk/include/clang/AST/StmtDataCollectors.td cfe/trunk/lib/AST/StmtDataCollectors.inc cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/unittests/AST/DataCollectionTest.cpp cfe/trunk/utils/TableGen/CMakeLists.txt cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp cfe/trunk/utils/TableGen/TableGen.cpp cfe/trunk/utils/TableGen/TableGenBackends.h Index: cfe/trunk/include/clang/AST/CMakeLists.txt === --- cfe/trunk/include/clang/AST/CMakeLists.txt +++ cfe/trunk/include/clang/AST/CMakeLists.txt @@ -50,3 +50,6 @@ SOURCE CommentCommands.td TARGET ClangCommentCommandList) +clang_tablegen(StmtDataCollectors.inc -gen-clang-data-collectors + SOURCE StmtDataCollectors.td + TARGET StmtDataCollectors) Index: cfe/trunk/include/clang/AST/StmtDataCollectors.td === --- cfe/trunk/include/clang/AST/StmtDataCollectors.td +++ cfe/trunk/include/clang/AST/StmtDataCollectors.td @@ -0,0 +1,242 @@ +class Stmt { + code Code = [{ +addData(S->getStmtClass()); +// This ensures that non-macro-generated code isn't identical to +// macro-generated code. +addData(data_collection::getMacroStack(S->getLocStart(), Context)); +addData(data_collection::getMacroStack(S->getLocEnd(), Context)); + }]; +} + +class Expr { + code Code = [{ +addData(S->getType()); + }]; +} + +//--- Builtin functionality --// +class ArrayTypeTraitExpr { + code Code = [{ +addData(S->getTrait()); + }]; +} +class ExpressionTraitExpr { + code Code = [{ +addData(S->getTrait()); + }]; +} +class PredefinedExpr { + code Code = [{ +addData(S->getIdentType()); + }]; +} +class TypeTraitExpr { + code Code = [{ +addData(S->getTrait()); +for (unsigned i = 0; i < S->getNumArgs(); ++i) + addData(S->getArg(i)->getType()); + }]; +} + +//--- Calls --// +class CallExpr { + code Code = [{ +// Function pointers don't have a callee and we just skip hashing it. +if (const FunctionDecl *D = S->getDirectCallee()) { + // If the function is a template specialization, we also need to handle + // the template arguments as they are not included in the qualified name. + if (auto Args = D->getTemplateSpecializationArgs()) { +std::string ArgString; + +// Print all template arguments into ArgString +llvm::raw_string_ostream OS(ArgString); +for (unsigned i = 0; i < Args->size(); ++i) { + Args->get(i).print(Context.getLangOpts(), OS); + // Add a padding character so that 'foo()' != 'foo()'. + OS << '\n'; +} +OS.flush(); + +addData(ArgString); + } + addData(D->getQualifiedNameAsString()); +} + }]; +} + +//--- Value references ---// +class DeclRefExpr { + code Code = [{ +addData(S->getDecl()->getQualifiedNameAsString()); + }]; +} +class MemberExpr { + code Code = [{ +addData(S->getMemberDecl()->getName()); + }]; +} + +//--- Literals ---// +class IntegerLiteral { + code Code = [{ +addData(llvm::hash_value(S->getValue())); + }]; +} +class FloatingLiteral { + code Code = [{ +addData(llvm::hash_value(S->getValue())); + }]; +} +class StringLiteral { + code Code = [{ +addData(S->getString()); +}]; +} +class CXXBoolLiteralExpr { + code Code = [{ +addData(S->getValue()); + }]; +} +class CharacterLiteral { + code Code = [{ +addData(S->getValue()); + }]; +} + +//--- Exceptions -// +class CXXCatchStmt { + code Code = [{ +addData(S->getCaughtType()); + }]; +} + +//--- C++ OOP Stmts --// +class CXXDeleteExpr { + code Code = [{ +addData(S->isArrayFormAsWritten()); addData(S->isGlobalDelete()); + }]; +} + +//--- Casts --// +class ObjCBridgedCastExpr { + code Code = [{ +addData(S->getBridgeKind()); + }]; +} + +//--- Miscellaneous Exprs // +class BinaryOperator { + code Code = [{ +addData(S->getOpcode()); + }]; +} +class UnaryOperator { + code Code = [{ +addData(S->getOpcode()); + }]; +} + +//--- Control flow ---// +class GotoStmt { + code Code = [{ +addData(S->getLabel()->getName()); +
r312634 - [AST] Add TableGen for StmtDataCollectors
Author: krobelus Date: Wed Sep 6 06:20:51 2017 New Revision: 312634 URL: http://llvm.org/viewvc/llvm-project?rev=312634&view=rev Log: [AST] Add TableGen for StmtDataCollectors Summary: This adds an option "-gen-clang-data-collectors" to the Clang TableGen that is used to generate StmtDataCollectors.inc. Reviewers: arphaman, teemperor! Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D37383 Added: cfe/trunk/include/clang/AST/StmtDataCollectors.td cfe/trunk/utils/TableGen/ClangDataCollectorsEmitter.cpp Removed: cfe/trunk/lib/AST/StmtDataCollectors.inc Modified: cfe/trunk/include/clang/AST/CMakeLists.txt cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/unittests/AST/DataCollectionTest.cpp cfe/trunk/utils/TableGen/CMakeLists.txt cfe/trunk/utils/TableGen/TableGen.cpp cfe/trunk/utils/TableGen/TableGenBackends.h Modified: cfe/trunk/include/clang/AST/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CMakeLists.txt?rev=312634&r1=312633&r2=312634&view=diff == --- cfe/trunk/include/clang/AST/CMakeLists.txt (original) +++ cfe/trunk/include/clang/AST/CMakeLists.txt Wed Sep 6 06:20:51 2017 @@ -50,3 +50,6 @@ clang_tablegen(CommentCommandList.inc -g SOURCE CommentCommands.td TARGET ClangCommentCommandList) +clang_tablegen(StmtDataCollectors.inc -gen-clang-data-collectors + SOURCE StmtDataCollectors.td + TARGET StmtDataCollectors) Added: cfe/trunk/include/clang/AST/StmtDataCollectors.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtDataCollectors.td?rev=312634&view=auto == --- cfe/trunk/include/clang/AST/StmtDataCollectors.td (added) +++ cfe/trunk/include/clang/AST/StmtDataCollectors.td Wed Sep 6 06:20:51 2017 @@ -0,0 +1,242 @@ +class Stmt { + code Code = [{ +addData(S->getStmtClass()); +// This ensures that non-macro-generated code isn't identical to +// macro-generated code. +addData(data_collection::getMacroStack(S->getLocStart(), Context)); +addData(data_collection::getMacroStack(S->getLocEnd(), Context)); + }]; +} + +class Expr { + code Code = [{ +addData(S->getType()); + }]; +} + +//--- Builtin functionality --// +class ArrayTypeTraitExpr { + code Code = [{ +addData(S->getTrait()); + }]; +} +class ExpressionTraitExpr { + code Code = [{ +addData(S->getTrait()); + }]; +} +class PredefinedExpr { + code Code = [{ +addData(S->getIdentType()); + }]; +} +class TypeTraitExpr { + code Code = [{ +addData(S->getTrait()); +for (unsigned i = 0; i < S->getNumArgs(); ++i) + addData(S->getArg(i)->getType()); + }]; +} + +//--- Calls --// +class CallExpr { + code Code = [{ +// Function pointers don't have a callee and we just skip hashing it. +if (const FunctionDecl *D = S->getDirectCallee()) { + // If the function is a template specialization, we also need to handle + // the template arguments as they are not included in the qualified name. + if (auto Args = D->getTemplateSpecializationArgs()) { +std::string ArgString; + +// Print all template arguments into ArgString +llvm::raw_string_ostream OS(ArgString); +for (unsigned i = 0; i < Args->size(); ++i) { + Args->get(i).print(Context.getLangOpts(), OS); + // Add a padding character so that 'foo()' != 'foo()'. + OS << '\n'; +} +OS.flush(); + +addData(ArgString); + } + addData(D->getQualifiedNameAsString()); +} + }]; +} + +//--- Value references ---// +class DeclRefExpr { + code Code = [{ +addData(S->getDecl()->getQualifiedNameAsString()); + }]; +} +class MemberExpr { + code Code = [{ +addData(S->getMemberDecl()->getName()); + }]; +} + +//--- Literals ---// +class IntegerLiteral { + code Code = [{ +addData(llvm::hash_value(S->getValue())); + }]; +} +class FloatingLiteral { + code Code = [{ +addData(llvm::hash_value(S->getValue())); + }]; +} +class StringLiteral { + code Code = [{ +addData(S->getString()); +}]; +} +class CXXBoolLiteralExpr { + code Code = [{ +addData(S->getValue()); + }]; +} +class CharacterLiteral { + code Code = [{ +addData(S->getValue()); + }]; +} + +//--- Exceptions -// +class CXXCatchStmt { + code Code = [{ +addData(S->getCaughtType()); + }]; +} + +//--- C++ OOP Stmts --// +class CXXDeleteExpr { + code Code = [{ +addData(S->isArrayFormAsWritten()); addData(S->isGlobalDelete()); + }]; +} + +//--- Casts --
[PATCH] D37513: [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
LuMa updated this revision to Diff 113998. https://reviews.llvm.org/D37513 Files: docs/ClangFormatStyleOptions.rst Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFunctionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFunctionWithVeryLongName(int a, + int b, + int c, + int d, + int e, + int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFunctionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFunctionWithVeryLongName(int a, + int b, + int c, + int d, + int e, + int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37479: run-clang-tidy: Report progress
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: clang-tidy/tool/run-clang-tidy.py:155 args.quiet) -sys.stdout.write(' '.join(invocation) + '\n') +sys.stdout.write('[%s/%s] Running: %s' % (index+1, total_file_count, ' '.join(invocation) + '\n')) subprocess.call(invocation) 1. Can we have these messages printed on the same line when run in a terminal? Progress display is better when it doesn't fill the whole terminal scrollback. Changing '\n' to '\r' should be a good start, but we also need to insure reasonable interaction with other messages. 2. The whole invocation may be quite a large line. Maybe just print the filename? (the rest would be repeated anyway) https://reviews.llvm.org/D37479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312633 - [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor
Author: krobelus Date: Wed Sep 6 06:12:11 2017 New Revision: 312633 URL: http://llvm.org/viewvc/llvm-project?rev=312633&view=rev Log: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor Summary: This affects overloaded operators, which are represented by a CXXOperatorCallExpr whose first child is always a DeclRefExpr referring to the operator. For infix, postfix and call operators we want the first argument to be traversed before the operator. Reviewers: arphaman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37200 Modified: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Modified: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h?rev=312633&r1=312632&r2=312633&view=diff == --- cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h Wed Sep 6 06:12:11 2017 @@ -113,6 +113,33 @@ public: bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } + + SmallVector getStmtChildren(CXXOperatorCallExpr *CE) { +SmallVector Children(CE->children()); +bool Swap; +// Switch the operator and the first operand for all infix and postfix +// operations. +switch (CE->getOperator()) { +case OO_Arrow: +case OO_Call: +case OO_Subscript: + Swap = true; + break; +case OO_PlusPlus: +case OO_MinusMinus: + // These are postfix unless there is exactly one argument. + Swap = Children.size() != 2; + break; +default: + Swap = CE->isInfixBinaryOp(); + break; +} +if (Swap && Children.size() > 1) + std::swap(Children[0], Children[1]); +return Children; + } + private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=312633&r1=312632&r2=312633&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Sep 6 06:12:11 2017 @@ -315,6 +315,8 @@ public: // Methods on Stmts + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } + private: template struct has_same_member_pointer_type : std::false_type {}; @@ -2084,7 +2086,7 @@ DEF_TRAVERSE_DECL(ParmVarDecl, { TRY_TO(WalkUpFrom##STMT(S)); \ { CODE; } \ if (ShouldVisitChildren) { \ - for (Stmt *SubStmt : S->children()) { \ + for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \ } \ } \ Modified: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp?rev=312633&r1=312632&r2=312633&view=diff == --- cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp (original) +++ cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Wed Sep 6 06:12:11 2017 @@ -21,9 +21,10 @@ class LexicallyOrderedDeclVisitor : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM, bool EmitIndices) + const SourceManager &SM, bool EmitDeclIndices, + bool EmitStmtIndices) : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), -EmitIndices(EmitIndices) {} +EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -32,31 +33,43 @@ public: return true; } + bool TraverseStmt(Stmt *S); + bool VisitNamedDecl(const NamedDecl *D); + bool VisitDeclRefExpr(const DeclRefExpr *D); private: DummyMatchVisitor
[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor
This revision was automatically updated to reflect the committed changes. Closed by commit rL312633: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor (authored by krobelus). Changed prior to commit: https://reviews.llvm.org/D37200?vs=112951&id=113999#toc Repository: rL LLVM https://reviews.llvm.org/D37200 Files: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h @@ -315,6 +315,8 @@ // Methods on Stmts + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } + private: template struct has_same_member_pointer_type : std::false_type {}; @@ -2084,7 +2086,7 @@ TRY_TO(WalkUpFrom##STMT(S)); \ { CODE; } \ if (ShouldVisitChildren) { \ - for (Stmt *SubStmt : S->children()) {\ + for (Stmt * SubStmt : getDerived().getStmtChildren(S)) { \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \ }\ } \ Index: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h @@ -113,6 +113,33 @@ bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } + Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } + + SmallVector getStmtChildren(CXXOperatorCallExpr *CE) { +SmallVector Children(CE->children()); +bool Swap; +// Switch the operator and the first operand for all infix and postfix +// operations. +switch (CE->getOperator()) { +case OO_Arrow: +case OO_Call: +case OO_Subscript: + Swap = true; + break; +case OO_PlusPlus: +case OO_MinusMinus: + // These are postfix unless there is exactly one argument. + Swap = Children.size() != 2; + break; +default: + Swap = CE->isInfixBinaryOp(); + break; +} +if (Swap && Children.size() > 1) + std::swap(Children[0], Children[1]); +return Children; + } + private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the Index: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp === --- cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp +++ cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp @@ -21,42 +21,55 @@ : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM, bool EmitIndices) + const SourceManager &SM, bool EmitDeclIndices, + bool EmitStmtIndices) : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), -EmitIndices(EmitIndices) {} +EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); LexicallyOrderedRecursiveASTVisitor::TraverseDecl(D); TraversalStack.pop_back(); return true; } + bool TraverseStmt(Stmt *S); + bool VisitNamedDecl(const NamedDecl *D); + bool VisitDeclRefExpr(const DeclRefExpr *D); private: DummyMatchVisitor &Matcher; - bool EmitIndices; + bool EmitDeclIndices, EmitStmtIndices; unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { - bool EmitIndices; + bool EmitDeclIndices, EmitStmtIndices; public: - DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} + DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false) + : EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices); +LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices, + Emit
[PATCH] D36998: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
This revision was automatically updated to reflect the committed changes. Closed by commit rL312631: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor (authored by krobelus). Repository: rL LLVM https://reviews.llvm.org/D36998 Files: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Index: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp === --- cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp +++ cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp @@ -21,8 +21,9 @@ : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM) - : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {} + const SourceManager &SM, bool EmitIndices) + : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), +EmitIndices(EmitIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -35,15 +36,20 @@ private: DummyMatchVisitor &Matcher; + bool EmitIndices; + unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { + bool EmitIndices; + public: + DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM); +LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices); SubVisitor.TraverseDecl(TU); return false; } @@ -64,9 +70,11 @@ OS << ND->getNameAsString(); else OS << "???"; -if (isa(D)) +if (isa(D) or isa(D)) OS << "/"; } + if (EmitIndices) +OS << "@" << Index++; Matcher.match(OS.str(), D); return true; } @@ -138,4 +146,18 @@ EXPECT_TRUE(Visitor.runOver(Source, DummyMatchVisitor::Lang_OBJC)); } +TEST(LexicallyOrderedRecursiveASTVisitor, VisitTemplateDecl) { + StringRef Source = R"( +template T f(); +template class Class {}; +)"; + DummyMatchVisitor Visitor(/*EmitIndices=*/true); + Visitor.ExpectMatch("/f/T@1", 2, 11); + Visitor.ExpectMatch("/f/f/@2", 2, 20); + Visitor.ExpectMatch("/Class/U@4", 3, 11); + Visitor.ExpectMatch("/Class/@5", 3, 20); + Visitor.ExpectMatch("/Class/Class/@6", 3, 34); + EXPECT_TRUE(Visitor.runOver(Source)); +} + } // end anonymous namespace Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h @@ -535,6 +535,7 @@ bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); bool PostVisitStmt(Stmt *S); + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return false; } }; template @@ -1688,8 +1689,13 @@ // template declarations. #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \ DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \ -TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ -TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +if (getDerived().shouldTraverseTemplateArgumentsBeforeDecl()) {\ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ +} else { \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +} \ \ /* By default, we do not traverse the instantiations of\ class templates since they do not appear in the user code. The \ Index: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h === --- cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h +++ cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h @@ -111,6 +111,8 @@ return true; } + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } + private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the _
r312631 - [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor
Author: krobelus Date: Wed Sep 6 06:11:13 2017 New Revision: 312631 URL: http://llvm.org/viewvc/llvm-project?rev=312631&view=rev Log: [AST] Traverse templates in LexicallyOrderedRecursiveASTVisitor Summary: We need to specialize this because RecursiveASTVisitor visits template template parameters after the templated declaration, unlike the order in which they appear in the source code. Reviewers: arphaman Reviewed By: arphaman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36998 Modified: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Modified: cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h?rev=312631&r1=312630&r2=312631&view=diff == --- cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h Wed Sep 6 06:11:13 2017 @@ -111,6 +111,8 @@ public: return true; } + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return true; } + private: bool TraverseAdditionalLexicallyNestedDeclarations() { // FIXME: Ideally the gathered declarations and the declarations in the Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=312631&r1=312630&r2=312631&view=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Sep 6 06:11:13 2017 @@ -535,6 +535,7 @@ private: bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue); bool PostVisitStmt(Stmt *S); + bool shouldTraverseTemplateArgumentsBeforeDecl() const { return false; } }; template @@ -1688,8 +1689,13 @@ bool RecursiveASTVisitor::Trave // template declarations. #define DEF_TRAVERSE_TMPL_DECL(TMPLDECLKIND) \ DEF_TRAVERSE_DECL(TMPLDECLKIND##TemplateDecl, { \ -TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ -TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +if (getDerived().shouldTraverseTemplateArgumentsBeforeDecl()) { \ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ +} else { \ + TRY_TO(TraverseDecl(D->getTemplatedDecl())); \ + TRY_TO(TraverseTemplateParameterListHelper(D->getTemplateParameters())); \ +} \ \ /* By default, we do not traverse the instantiations of \ class templates since they do not appear in the user code. The \ Modified: cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp?rev=312631&r1=312630&r2=312631&view=diff == --- cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp (original) +++ cfe/trunk/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Wed Sep 6 06:11:13 2017 @@ -21,8 +21,9 @@ class LexicallyOrderedDeclVisitor : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM) - : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher) {} + const SourceManager &SM, bool EmitIndices) + : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), +EmitIndices(EmitIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -35,15 +36,20 @@ public: private: DummyMatchVisitor &Matcher; + bool EmitIndices; + unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { + bool EmitIndices; + public: + DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM); +LexicallyOrd
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
teemperor accepted this revision. teemperor added a comment. This revision is now accepted and ready to land. @johannes The blocking reviewer is because it touches clone detection code :) Fine with me, I have some comments on things but nothing that affects this review. LGTM! https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37513: [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
LuMa updated this revision to Diff 113995. https://reviews.llvm.org/D37513 Files: docs/ClangFormatStyleOptions.rst Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFunctionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFunctionWithVeryLongName(int a, +int b, +int c, +int d, +int e, +int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFunctionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFunctionWithVeryLongName(int a, +int b, +int c, +int d, +int e, +int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37383: [AST] Add TableGen for StmtDataCollectors
johannes added a comment. @teemperor ok for you? did phabricator make you a blocking reviewer because of the affected code, or did I do that somehow? https://reviews.llvm.org/D37383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants
r.stahl added a comment. To be honest I was quite surprised that this change in behavior didn't cause more test failures, because for detecting null dereferences the old behavior is definitely more useful. Since it did not, I was convinced that this change is desired. We use the analyzer for finding dereferences to fixed addresses - very similar to the FixedAddressChecker. For this purpose it is crucial that the execution engine works as perfect as possible, without "swallowing" any arithmetic. For the struct example you mentioned you can still get the final address by asking the ASTContext if needed, but with pointer arithmetic the information is lost forever. Information is lost either way here. Either you forget that the arithmetic was based on a null pointer or you lose whatever was added to or subtracted from it. So unless you can somehow tag the information in the SVal when an operation was based on a null pointer, this is pretty difficult. You also could introduce a heuristic that defines all dereferences around zero as null dereferences, but it would be very arbitrary and platform dependent. Or maybe the DereferenceChecker should explicitly break early on all statements that do arithmetic on pointers constrained to null. Overall I don't know enough about the analyzer to suggest more here. Thanks for the comments, I will address them soon. https://reviews.llvm.org/D37478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action
ioeric added inline comments. Comment at: tools/clang-refactor/ClangRefactor.cpp:103 +IsSelectionParsed = true; +// FIXME: Support true selection ranges. +StringRef Value = *Selection; arphaman wrote: > ioeric wrote: > > Is the test selection temporary before we have true selection? > > > > I am a bit concerned about having test logic in the production code. It > > makes the code paths a bit complicated, and we might easily end up testing > > the test logic instead of the actual code logic. I'm fine with this if this > > is just a short term solution before we have the actual selection support. > No, both are meant to co-exist. I guess we could introduce a new option > (-selection vs -test-selection and hide -test-selection)? Another approach > that I was thinking about is to have a special hidden subcommand for each > action (e.g. test-local-rename). Alternatively we could use two different > tools (clang-refactor vs clang-refactor-test)? Both will have very similar > code though. > > Note that it's not the first time test logic will exist in the final tool. > For example, llvm-cov has a `convert-for-testing` subcommand that exists in > the production tool. I'm not saying that it's necessarily the best option > though, but I don't think it's the worst one either ;) I guess I am more concerned about mixing production code with testing code than having special options. For example, we have different invocation paths based on `ParsedTestSelection`. IMO, whether selected ranges come from test selection or actual selection should be transparent to clang-refactor. Maybe refactoring the selection handling logic out as a separate interface would help? Repository: rL LLVM https://reviews.llvm.org/D36574 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37513: [clang-format] Fix documentation for AllowAllParametersOfDeclarationOnNextLine
LuMa created this revision. Current description of flag AllowAllParametersOfDeclarationOnNextLine in Clang-Format Style Options guide suggests that it is possible to format function declaration, which fits in a single line (what is not supported in current clang-format version). Also example is not reproducible and makes no sense. I have added valid example and have stressed that flag applies only if declaration doesn't fit in a single line. https://reviews.llvm.org/D37513 Files: docs/ClangFormatStyleOptions.rst Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFuncionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFuncionWithVeryLongName(int a, +int b, +int c, +int d, +int e, +int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. Index: docs/ClangFormatStyleOptions.rst === --- docs/ClangFormatStyleOptions.rst +++ docs/ClangFormatStyleOptions.rst @@ -271,15 +271,29 @@ int b = 2; // comment bint b = 2; // comment about b **AllowAllParametersOfDeclarationOnNextLine** (``bool``) - Allow putting all parameters of a function declaration onto - the next line even if ``BinPackParameters`` is ``false``. + If the function declaration doesn't fit on a line, + allow putting all parameters onto the next line + even if ``BinPackParameters`` is ``false``. + + This applies to declaration, whose parameters fit on a single line. .. code-block:: c++ -true: false: -myFunction(foo, vs. myFunction(foo, bar, plop); - bar, - plop); +true: +int SomeFuncionWithVeryLongName( +int a, int b, int c, int d, int e, int f) { + return 0; +} + +false: +int SomeFuncionWithVeryLongName(int a, +int b, +int c, +int d, +int e, +int f) { + return 0; +} **AllowShortBlocksOnASingleLine** (``bool``) Allows contracting simple braced statements to a single line. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants
NoQ added a comment. I've seen this recently, and while i agree that the fix is correct, i'm not entirely sure that the test cases are correct. As weird as this may sound, null dereference is not an attempt to read from or write to memory address 0. Instead, it is about using a null pointer as if it was pointing to an actual object in memory, even if accessing it by a non-zero offset. For example, in struct S { int x, y; }; void foo() { struct S *s = NULL; s->y = 1; } we're in fact writing into `*(0x4)`, not `*(0x0)`, however it's intuitive that this code has a //null// pointer dereference, because we use a null pointer `s` as if it points to an actual object of type `struct S`. In this sense, i'd actually want the analyzer to warn in `test4`: it seems that the author of this code was expecting to find something useful by offset 1 to the pointer, so he must have made a mistake. Also i'm not entirely sure if i want the analyzer to warn in `test1`, `test2`, `test3` (also this code pattern doesn't look widespread/idiomatic). So the analyzer does this really really weird thing by treating many operations with concrete pointers as no-ops, keeping the pointer null when it was null before, and keeping it non-null when it was non-null before - not just in the place that you've fixed, but also when computing field or element or base-class offsets for null pointers. These are marked as FIXME all over the place, but taking up the fix would require to provide another heuristic to distinguish null dereferences from other fixed-address dereferences (i.e. the experimental `FixedAddressChecker`). I guess there should be more comments on this issue near the FIXMEs you fixed, and more tests covering the intended behavior; adding them is definitely a good thing to do. I do not have any immediate ideas on how to fix the issue as a whole. Comment at: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:938 llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true); + QualType PteeTy = resultTy.getTypePtr()->castAs()->getPointeeType(); + Multiplicand = getContext().getTypeSizeInChars(PteeTy).getQuantity(); xazax.hun wrote: > The rest of the code does not abbreviate the Type. I would prefer to name > this `pointeeType`. Also `resultTy->getPointeeType()`. Note the fancy `operator->()` in `QualType`. https://reviews.llvm.org/D37478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits