[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.
pekka.jaaskelainen requested changes to this revision. pekka.jaaskelainen added inline comments. This revision now requires changes to proceed. Comment at: docs/UsersManual.rst:2065 + + $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl + Is this correct? I cannot make it work: ``` ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang -finclude-default-header -emit-llvm -cc1 -triple spir64-unknown-unknown kernel/test_halfs.cl -c -S -o - clang-4.0: error: unknown argument: '-cc1' clang-4.0: error: unknown argument: '-triple' clang-4.0: error: no such file or directory: 'spir64-unknown-unknown' ``` -target works instead. (But reveals another issue, there's no printf() declaration, should I file a bug?) ``` ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang -finclude-default-header -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o - kernel/test_halfs.cl:10:9: warning: implicit declaration of function 'printf' is invalid in C99 [-Wimplicit-function-declaration] printf("max(a,b)[0] type=uint2 a=0x15b348c9 b=0xf88e7d07 want=0xf88e7d07 got=%x\n", max_[0]); ^ kernel/test_halfs.cl:10:9: error: function with no prototype cannot use the spir_function calling convention 1 warning and 1 error generated. ``` With 3.9 that kernel which calls printf() passes: ``` /local/stow/llvm-3.9-debug/bin/clang -Xclang -finclude-default-header -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o - ; ModuleID = 'kernel/test_halfs.cl' source_filename = "kernel/test_halfs.cl" target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" target triple = "spir64-unknown-unknown" ``` https://reviews.llvm.org/D28080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28774: [clang-move] Ignore using decls which are defined in macros.
hokein updated this revision to Diff 84639. hokein marked 2 inline comments as done. hokein added a comment. Add more tests. https://reviews.llvm.org/D28774 Files: clang-move/ClangMove.cpp test/clang-move/Inputs/macro_helper_test.cpp test/clang-move/Inputs/macro_helper_test.h test/clang-move/no-move-macro-helpers.cpp Index: test/clang-move/no-move-macro-helpers.cpp === --- /dev/null +++ test/clang-move/no-move-macro-helpers.cpp @@ -0,0 +1,43 @@ +// RUN: mkdir -p %T/no-move-macro-helper +// RUN: cp %S/Inputs/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.h +// RUN: cp %S/Inputs/macro_helper_test.cpp %T/no-move-macro-helper/macro_helper_test.cpp +// RUN: cd %T/no-move-macro-helper +// +// - +// Test no moving helpers in macro. +// - +// RUN: clang-move -names="A" -new_cc=%T/no-move-macro-helper/new_test.cpp -new_header=%T/no-move-macro-helper/new_test.h -old_cc=%T/no-move-macro-helper/macro_helper_test.cpp -old_header=%T/no-move-macro-helper/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11 +// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h -check-prefix=CHECK-NEW-TEST-CASE1-H %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.cpp -check-prefix=CHECK-NEW-TEST-CASE1-CPP %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.h -check-prefix=CHECK-OLD-TEST-CASE1-H %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.cpp -check-prefix=CHECK-OLD-TEST-CASE1-CPP %s + +// CHECK-NEW-TEST-CASE1-H: class A {}; + +// CHECK-OLD-TEST-CASE1-H-NOT: class A {}; + +// CHECK-OLD-TEST-CASE1-CPP: DEFINE(test) + +// CHECK-NEW-TEST-CASE1-CPP-NOT: DEFINE(test) + + +// - +// Test moving all. +// - +// RUN: cp %S/Inputs/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.h +// RUN: cp %S/Inputs/macro_helper_test.cpp %T/no-move-macro-helper/macro_helper_test.cpp +// RUN: clang-move -names="A, f1" -new_cc=%T/no-move-macro-helper/new_test.cpp -new_header=%T/no-move-macro-helper/new_test.h -old_cc=%T/no-move-macro-helper/macro_helper_test.cpp -old_header=%T/no-move-macro-helper/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11 +// +// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h -check-prefix=CHECK-NEW-TEST-CASE2-H %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.cpp -check-prefix=CHECK-NEW-TEST-CASE2-CPP %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.h -allow-empty -check-prefix=CHECK-EMPTY %s +// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.cpp -allow-empty -check-prefix=CHECK-EMPTY %s + +// CHECK-NEW-TEST-CASE2-H: class A {}; +// CHECK-NEW-TEST-CASE2-H-NEXT:void f1(); + + +// CHECK-NEW-TEST-CASE2-CPP: DEFINE(test) +// CHECK-NEW-TEST-CASE2-CPP: void f1() {} + +// CHECK-EMPTY: {{^}}{{$}} Index: test/clang-move/Inputs/macro_helper_test.h === --- /dev/null +++ test/clang-move/Inputs/macro_helper_test.h @@ -0,0 +1,2 @@ +class A {}; +void f1(); Index: test/clang-move/Inputs/macro_helper_test.cpp === --- /dev/null +++ test/clang-move/Inputs/macro_helper_test.cpp @@ -0,0 +1,13 @@ +#include "macro_helper_test.h" + +#define DEFINE(name) \ + namespace ns { \ + static const bool t1 = false; \ + bool t2_##name = t1; \ + bool t3_##name = t1; \ + } \ + using ns::t2_##name; + +DEFINE(test) + +void f1() {} Index: clang-move/ClangMove.cpp === --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -31,6 +31,8 @@ // FIXME: Move to ASTMatchers. AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); } +AST_MATCHER(NamedDecl, notInMacro) { return !Node.getLocation().isMacroID(); } + AST_MATCHER_P(Decl, hasOutermostEnclosingClass, ast_matchers::internal::Matcher, InnerMatcher) { const auto *Context = Node.getDeclContext(); @@ -525,12 +527,12 @@ // Matching using decls/type alias decls which are in named/anonymous/global // namespace, these decls are always copied to new.h/cc. Those in classes, // functions are covered in other matchers. - Finder->addMatcher( - namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), - usingDirectiveDecl(IsOldCCTopLevelDecl), - typeAliasDecl(IsOldCCTopLevelDecl))) - .bind("using_decl"), - this); + Finder->addMatcher(namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), +
[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes
smeenai added a comment. I really like the cleanup, but I'm not the biggest fan of taking more Microsoft dependencies than necessary. I don't see any way around `operator new`/`operator delete` (since replacement in COFF can only work with a static library with one function per object file, the way `msvcrt.lib` does it, and it doesn't seem to be worth the trouble to provide our own corresponding static library), but I think the rest are avoidable (though it's entirely possible I'm missing something, of course). Comment at: include/exception:85 +#if defined(_LIBCPP_ABI_MICROSOFT) +#include What's the rationale for relying on Microsoft's exception implementation rather than libc++'s? Comment at: include/new:96 +#if defined(_LIBCPP_ABI_MICROSOFT) +#include +#endif `new.h` will pull in `new` unless you define certain macros. Is that desirable? Comment at: include/new:138 +typedef void (*new_handler)(); +_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT; Again, why defer these to Microsoft's STL? In particular, `set_new_handler` and `get_new_handler` seem to be part of `msvcprt`, which means we would take a runtime dependency on Microsoft's C++ library, which doesn't seem great. These functions should map pretty well to `_query_new_handler` and `_set_new_handler` (apart from the different function pointer signature, which can be thunked around), right? Comment at: include/new:177 +#if !defined(_LIBCPP_ABI_MICROSOFT) + Might be helpful to have a comment explaining why we wanna defer these to msvcrt on Windows? Also, VS 2015 doesn't seem to have the sized and aligned allocation and deallocation functions. I haven't checked 2017. https://reviews.llvm.org/D28785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
Prazek accepted this revision. Prazek added a comment. This revision is now accepted and ready to land. Do you have some results from running it on LLVM? If nothing crashes and all fixit are correct then LGTM. Comment at: clang-tidy/modernize/ReturnBracedInitListCheck.cpp:27-32 + auto soughtConstructExpr = + cxxConstructExpr(unless(isListInitialization())).bind("ctor"); + + auto hasConstructExpr = has(ignoringImplicit(soughtConstructExpr)); + + auto ctorAsArgument = materializeTemporaryExpr( Prazek wrote: > Uppercase Is it worth adding new variable to save 2 characters? Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:106 +Bar f8 () { + return {}; +} Also add test like: return Bar{}; (If this construct is valid) Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:122 +Foo f10() { + return f9(Bar()); +} also make one like return f9(Foo()); Repository: rL LLVM https://reviews.llvm.org/D28768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D28548: Improve include fixer's ranking by taking the paths into account.
It's by design. Do we want to change this? I always had the impression turning on the state changes for the list is a bit noisy, but I'm happy if that's not the general sentiment. On Mon, Jan 16, 2017, 11:07 PM Benjamin Kramer wrote: I got an email where it says that I accepted the revision. Looks like phab didn't add cfe-commits to the list of recipients though :( On Mon, Jan 16, 2017 at 6:43 PM, David Blaikie wrote: > Looks like Ben signed off on this on Phab - but the email didn't go to the > list (making this look like code was sent for review, then committed, > without review/approval happening) > > Ben: I think Phab doesn't send mail for an approval with no text, so at > least as a workaround you can write something in the comments section when > approving (people often write "LGTM" or similar) to ensure the approval is > reflected on the mailing list. > > On Wed, Jan 11, 2017 at 1:59 AM Manuel Klimek via Phabricator via > cfe-commits wrote: >> >> klimek created this revision. >> klimek added a reviewer: bkramer. >> klimek added a subscriber: cfe-commits. >> >> Instead of just using popularity, we also take into account how similar >> the >> path of the current file is to the path of the header. >> Our first approach is to get popularity into a reasonably small scale by >> taking >> log2 (which is roughly intuitive to how humans would bucket popularity), >> and >> multiply that with the number of matching prefix path fragments of the >> included >> header with the current file. >> Note that currently we do not take special care for unclean paths >> containing >> "../" or "./". >> >> >> https://reviews.llvm.org/D28548 >> >> Files: >> include-fixer/IncludeFixer.cpp >> include-fixer/SymbolIndexManager.cpp >> include-fixer/SymbolIndexManager.h >> include-fixer/tool/ClangIncludeFixer.cpp >> test/include-fixer/Inputs/fake_yaml_db.yaml >> test/include-fixer/ranking.cpp >> >> ___ >> 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] D16135: Macro Debug Info support in Clang
aaboud added a comment. Richard, can you please review the new patch? https://reviews.llvm.org/D16135 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
JDevlieghere added a comment. In https://reviews.llvm.org/D28768#647949, @Prazek wrote: > Do you have some results from running it on LLVM? If nothing crashes and all > fixit are correct then LGTM. There's still an issue with type narrowing, which is allowed in regular constructor but not in braced initializer lists. I'd like to skip cases where narrowing occurs, either in the matcher or in the check method, but I haven't figured out how yet. Repository: rL LLVM https://reviews.llvm.org/D28768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes
EricWF added inline comments. Comment at: include/exception:85 +#if defined(_LIBCPP_ABI_MICROSOFT) +#include smeenai wrote: > What's the rationale for relying on Microsoft's exception implementation > rather than libc++'s? `vcruntime_new.h` brings in `vcruntime_exception.h` which defines all of the `exception` symbols as inline. We have no choice but to cede to them. Comment at: include/new:96 +#if defined(_LIBCPP_ABI_MICROSOFT) +#include +#endif smeenai wrote: > `new.h` will pull in `new` unless you define certain macros. Is that > desirable? That's not how I read the `new.h` header. In MSVC 2015 `new.h` pulls in `vcruntime_new.h` but it also declares `std::new_handler` and `std::set_new_handler`. `` actually avoid declaring certain things if `new.h` has already been included. `std::get_new_handler` is the only function declared in `` that is not declared in ``, however using this function also requires linking to the MSVC C++ STL which we can't do. It's not a great situation to be in, but I don't see how to avoid it. Comment at: include/new:138 +typedef void (*new_handler)(); +_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT; smeenai wrote: > Again, why defer these to Microsoft's STL? In particular, `set_new_handler` > and `get_new_handler` seem to be part of `msvcprt`, which means we would take > a runtime dependency on Microsoft's C++ library, which doesn't seem great. > > These functions should map pretty well to `_query_new_handler` and > `_set_new_handler` (apart from the different function pointer signature, > which can be thunked around), right? We have to assume these declarations/definitions have already been included via a user including `new.h`, so we can't redefine them. `std::set_new_handler` seem to actually be a part of the CRT startup files, so we can't avoid using it (AFAIK). > These functions should map pretty well to _query_new_handler and > _set_new_handler Those functions take/return entirely different function types. So IDK how to turn the function pointer returned from `_query_new_handler` into an entirely different function type and return it from `get_new_handler`, at least not in a meaningful way. Comment at: include/new:177 +#if !defined(_LIBCPP_ABI_MICROSOFT) + smeenai wrote: > Might be helpful to have a comment explaining why we wanna defer these to > msvcrt on Windows? > > Also, VS 2015 doesn't seem to have the sized and aligned allocation and > deallocation functions. I haven't checked 2017. You're right that `VS 2015` doesn't have aligned `new/delete`. However until we can correctly implement `get_new_handler` we won't be able to correctly implement the additional aligned `new/delete` overloads. https://reviews.llvm.org/D28785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes
EricWF added inline comments. Comment at: include/new:177 +#if !defined(_LIBCPP_ABI_MICROSOFT) + EricWF wrote: > smeenai wrote: > > Might be helpful to have a comment explaining why we wanna defer these to > > msvcrt on Windows? > > > > Also, VS 2015 doesn't seem to have the sized and aligned allocation and > > deallocation functions. I haven't checked 2017. > You're right that `VS 2015` doesn't have aligned `new/delete`. However until > we can correctly implement `get_new_handler` we won't be able to correctly > implement the additional aligned `new/delete` overloads. I failed to mention that I do plan to re-enable the aligned allocation overloads in the future; But before I do that I need a definition of `std::get_new_handler` which IDK how to provide yet. I've emailed the MSVC team asking for advice about implementing this. https://reviews.llvm.org/D28785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28774: [clang-move] Ignore using decls which are defined in macros.
This revision was automatically updated to reflect the committed changes. Closed by commit rL292207: [clang-move] Ignore using decls which are defined in macros. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D28774?vs=84639&id=84643#toc Repository: rL LLVM https://reviews.llvm.org/D28774 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp === --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -31,6 +31,8 @@ // FIXME: Move to ASTMatchers. AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); } +AST_MATCHER(NamedDecl, notInMacro) { return !Node.getLocation().isMacroID(); } + AST_MATCHER_P(Decl, hasOutermostEnclosingClass, ast_matchers::internal::Matcher, InnerMatcher) { const auto *Context = Node.getDeclContext(); @@ -525,12 +527,12 @@ // Matching using decls/type alias decls which are in named/anonymous/global // namespace, these decls are always copied to new.h/cc. Those in classes, // functions are covered in other matchers. - Finder->addMatcher( - namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), - usingDirectiveDecl(IsOldCCTopLevelDecl), - typeAliasDecl(IsOldCCTopLevelDecl))) - .bind("using_decl"), - this); + Finder->addMatcher(namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), + usingDirectiveDecl(IsOldCCTopLevelDecl), + typeAliasDecl(IsOldCCTopLevelDecl)), + notInMacro()) + .bind("using_decl"), + this); // Match static functions/variable definitions which are defined in named // namespaces. @@ -556,9 +558,11 @@ allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS)); // Match helper classes separately with helper functions/variables since we // want to reuse these matchers in finding helpers usage below. - auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition), - varDecl(IsOldCCHelperDefinition))); - auto HelperClasses = cxxRecordDecl(DefinitionInOldCC, InAnonymousNS); + auto HelperFuncOrVar = + namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition), +varDecl(IsOldCCHelperDefinition))); + auto HelperClasses = + cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS); // Save all helper declarations in old.cc. Finder->addMatcher( namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"), Index: clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h === --- clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h +++ clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h @@ -0,0 +1,2 @@ +class A {}; +void f1(); Index: clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp === --- clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp +++ clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp @@ -0,0 +1,13 @@ +#include "macro_helper_test.h" + +#define DEFINE(name) \ + namespace ns { \ + static const bool t1 = false; \ + bool t2_##name = t1; \ + bool t3_##name = t1; \ + } \ + using ns::t2_##name; + +DEFINE(test) + +void f1() {} Index: clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp === --- clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp +++ clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp @@ -0,0 +1,43 @@ +// RUN: mkdir -p %T/no-move-macro-helper +// RUN: cp %S/Inputs/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.h +// RUN: cp %S/Inputs/macro_helper_test.cpp %T/no-move-macro-helper/macro_helper_test.cpp +// RUN: cd %T/no-move-macro-helper +// +// - +// Test no moving helpers in macro. +// - +// RUN: clang-move -names="A" -new_cc=%T/no-move-macro-helper/new_test.cpp -new_header=%T/no-move-macro-helper/new_test.h -old_cc=%T/no-move-macro-helper/macro_helper_test.cpp -old_header=%T/no-move-macro-helper/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11 +// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h -check-prefix=
[clang-tools-extra] r292207 - [clang-move] Ignore using decls which are defined in macros.
Author: hokein Date: Tue Jan 17 04:08:11 2017 New Revision: 292207 URL: http://llvm.org/viewvc/llvm-project?rev=292207&view=rev Log: [clang-move] Ignore using decls which are defined in macros. Summary: Also ignore helpers which are defined in macro. Currently clang-move doesn't handle macro well enough, especiall for complex macros. This patch will ignore declarations in macros to make the behavior of clang-move more correct. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28774 Added: clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292207&r1=292206&r2=292207&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Jan 17 04:08:11 2017 @@ -31,6 +31,8 @@ namespace { // FIXME: Move to ASTMatchers. AST_MATCHER(VarDecl, isStaticDataMember) { return Node.isStaticDataMember(); } +AST_MATCHER(NamedDecl, notInMacro) { return !Node.getLocation().isMacroID(); } + AST_MATCHER_P(Decl, hasOutermostEnclosingClass, ast_matchers::internal::Matcher, InnerMatcher) { const auto *Context = Node.getDeclContext(); @@ -525,12 +527,12 @@ void ClangMoveTool::registerMatchers(ast // Matching using decls/type alias decls which are in named/anonymous/global // namespace, these decls are always copied to new.h/cc. Those in classes, // functions are covered in other matchers. - Finder->addMatcher( - namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), - usingDirectiveDecl(IsOldCCTopLevelDecl), - typeAliasDecl(IsOldCCTopLevelDecl))) - .bind("using_decl"), - this); + Finder->addMatcher(namedDecl(anyOf(usingDecl(IsOldCCTopLevelDecl), + usingDirectiveDecl(IsOldCCTopLevelDecl), + typeAliasDecl(IsOldCCTopLevelDecl)), + notInMacro()) + .bind("using_decl"), + this); // Match static functions/variable definitions which are defined in named // namespaces. @@ -556,9 +558,11 @@ void ClangMoveTool::registerMatchers(ast allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS)); // Match helper classes separately with helper functions/variables since we // want to reuse these matchers in finding helpers usage below. - auto HelperFuncOrVar = namedDecl(anyOf(functionDecl(IsOldCCHelperDefinition), - varDecl(IsOldCCHelperDefinition))); - auto HelperClasses = cxxRecordDecl(DefinitionInOldCC, InAnonymousNS); + auto HelperFuncOrVar = + namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition), +varDecl(IsOldCCHelperDefinition))); + auto HelperClasses = + cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS); // Save all helper declarations in old.cc. Finder->addMatcher( namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"), Added: clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp?rev=292207&view=auto == --- clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp (added) +++ clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.cpp Tue Jan 17 04:08:11 2017 @@ -0,0 +1,13 @@ +#include "macro_helper_test.h" + +#define DEFINE(name) \ + namespace ns { \ + static const bool t1 = false; \ + bool t2_##name = t1; \ + bool t3_##name = t1; \ + } \ + using ns::t2_##name; + +DEFINE(test) + +void f1() {} Added: clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h?rev=292207&view=auto == --- clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h (added) +++ clang-tools-extra/trunk/test/clang-move/Inputs/macro_helper_test.h Tue Jan 17 04:08:11 2017 @@ -0,0 +1,2 @@ +class A {}; +void f1(); Added: clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp?rev=292207&view=auto
Re: [PATCH] D28548: Improve include fixer's ranking by taking the paths into account.
If we add all state transitions it will only create noise. I will teach myself to always write "lg" into the text field when approving a change instead. On Tue, Jan 17, 2017 at 9:57 AM, Manuel Klimek via cfe-commits wrote: > It's by design. Do we want to change this? I always had the impression > turning on the state changes for the list is a bit noisy, but I'm happy if > that's not the general sentiment. > > > On Mon, Jan 16, 2017, 11:07 PM Benjamin Kramer wrote: >> >> I got an email where it says that I accepted the revision. Looks like >> phab didn't add cfe-commits to the list of recipients though :( >> >> On Mon, Jan 16, 2017 at 6:43 PM, David Blaikie wrote: >> > Looks like Ben signed off on this on Phab - but the email didn't go to >> > the >> > list (making this look like code was sent for review, then committed, >> > without review/approval happening) >> > >> > Ben: I think Phab doesn't send mail for an approval with no text, so at >> > least as a workaround you can write something in the comments section >> > when >> > approving (people often write "LGTM" or similar) to ensure the approval >> > is >> > reflected on the mailing list. >> > >> > On Wed, Jan 11, 2017 at 1:59 AM Manuel Klimek via Phabricator via >> > cfe-commits wrote: >> >> >> >> klimek created this revision. >> >> klimek added a reviewer: bkramer. >> >> klimek added a subscriber: cfe-commits. >> >> >> >> Instead of just using popularity, we also take into account how similar >> >> the >> >> path of the current file is to the path of the header. >> >> Our first approach is to get popularity into a reasonably small scale >> >> by >> >> taking >> >> log2 (which is roughly intuitive to how humans would bucket >> >> popularity), >> >> and >> >> multiply that with the number of matching prefix path fragments of the >> >> included >> >> header with the current file. >> >> Note that currently we do not take special care for unclean paths >> >> containing >> >> "../" or "./". >> >> >> >> >> >> https://reviews.llvm.org/D28548 >> >> >> >> Files: >> >> include-fixer/IncludeFixer.cpp >> >> include-fixer/SymbolIndexManager.cpp >> >> include-fixer/SymbolIndexManager.h >> >> include-fixer/tool/ClangIncludeFixer.cpp >> >> test/include-fixer/Inputs/fake_yaml_db.yaml >> >> test/include-fixer/ranking.cpp >> >> >> >> ___ >> >> 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 > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28799: [llvm-objdump tests] Copy the inputs of tests closer to tests.
krasimir created this revision. Tests under tools/llvm-objdump should not use inputs from Object. Copied the required inputs and aligned the new tests to be more consistent with the existing tests in this respect. https://reviews.llvm.org/D28799 Files: test/tools/llvm-objdump/X86/Inputs/openbsd-phdrs.elf-x86-64 test/tools/llvm-objdump/X86/Inputs/phdr-note.elf-x86-64 test/tools/llvm-objdump/X86/Inputs/phdrs.elf-x86-64 test/tools/llvm-objdump/X86/openbsd-headers.test test/tools/llvm-objdump/X86/phdrs.test Index: test/tools/llvm-objdump/X86/phdrs.test === --- test/tools/llvm-objdump/X86/phdrs.test +++ test/tools/llvm-objdump/X86/phdrs.test @@ -11,7 +11,7 @@ ## d: ## .long 2 ## -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: RELRO off0x1000 vaddr 0x00201000 paddr 0x00201000 align 2**0 @@ -25,7 +25,7 @@ ## .section.note.test,"a",@note ## .quad 42 -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdr-note.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdr-note.elf-x86-64 \ RUN: | FileCheck %s --check-prefix=NOTE NOTE: NOTE off0x0200 vaddr 0x0200 paddr 0x0200 align 2**0 Index: test/tools/llvm-objdump/X86/openbsd-headers.test === --- test/tools/llvm-objdump/X86/openbsd-headers.test +++ test/tools/llvm-objdump/X86/openbsd-headers.test @@ -9,7 +9,7 @@ ## 0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED, ## 0x65a41be6 is the value of PT_OPENBSD_BOOTDATA ## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text } -RUN: llvm-objdump -p %p/../../../Object/Inputs/openbsd-phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/openbsd-phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: OPENBSD_RANDOMIZE off0x vaddr 0x paddr 0x align 2**3 Index: test/tools/llvm-objdump/X86/phdrs.test === --- test/tools/llvm-objdump/X86/phdrs.test +++ test/tools/llvm-objdump/X86/phdrs.test @@ -11,7 +11,7 @@ ## d: ## .long 2 ## -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: RELRO off0x1000 vaddr 0x00201000 paddr 0x00201000 align 2**0 @@ -25,7 +25,7 @@ ## .section.note.test,"a",@note ## .quad 42 -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdr-note.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdr-note.elf-x86-64 \ RUN: | FileCheck %s --check-prefix=NOTE NOTE: NOTE off0x0200 vaddr 0x0200 paddr 0x0200 align 2**0 Index: test/tools/llvm-objdump/X86/openbsd-headers.test === --- test/tools/llvm-objdump/X86/openbsd-headers.test +++ test/tools/llvm-objdump/X86/openbsd-headers.test @@ -9,7 +9,7 @@ ## 0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED, ## 0x65a41be6 is the value of PT_OPENBSD_BOOTDATA ## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text } -RUN: llvm-objdump -p %p/../../../Object/Inputs/openbsd-phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/openbsd-phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: OPENBSD_RANDOMIZE off0x vaddr 0x paddr 0x align 2**3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: test/clang-tidy/modernize-return-braced-init-list.cpp:132 +auto v1 = []() { return vector({1, 2}); }(); +auto v2 = []() -> vector { return vector({1, 2}); }(); Please add tests with the replaced code being inside a template (both for class and function templates) with multiple instantiations. Two interesting variations are when the return expression is type dependent and when it's not. Repository: rL LLVM https://reviews.llvm.org/D28768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28799: [llvm-objdump tests] Copy the inputs of tests closer to tests.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. @davide I think this change makes sense. I'll accept this to unbreak our internal build. Let us know if you have any concern. https://reviews.llvm.org/D28799 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:44 +} else { + /* If a single one is not valid, we cannot apply the fix as we need to + * remove noexcept in all declarations for the fix to be effective. */ Use line comments (`//`). Comment at: clang-tidy/misc/ThrowWithNoexceptCheck.cpp:53 +// FIXME use DiagnosticIDs::Level::Note +diag(NoExceptRange.getBegin(), "In function declared no-throw here:") +<< FixItHint::CreateRemoval(NoExceptRange); nit: no leading capitalization in diagnostic messages needed. Comment at: test/clang-tidy/misc-throw-with-noexcept.cpp:88 +// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept] +// CHECK-FIXES: void with_macro() { Please add test cases where the function in question is a template itself (and another one where it's a member of a template class) and has a few instantiations. https://reviews.llvm.org/D19201 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28801: [clang-move] Handle helpers with forward declarations.
hokein created this revision. https://reviews.llvm.org/D28801 Files: clang-move/ClangMove.cpp clang-move/HelperDeclRefGraph.cpp test/clang-move/Inputs/helper_decls_test.cpp test/clang-move/Inputs/helper_decls_test.h test/clang-move/move-used-helper-decls.cpp Index: test/clang-move/move-used-helper-decls.cpp === --- test/clang-move/move-used-helper-decls.cpp +++ test/clang-move/move-used-helper-decls.cpp @@ -259,12 +259,43 @@ // CHECK-OLD-FUN2-H-NOT: inline void Fun2() {} +// +// Test moving used helper function and its transively used functions. +// +// RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ +// RUN: clang-move -names="b::Fun3" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 +// RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-FUN3-CPP %s +// RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-FUN3-CPP %s + +// CHECK-NEW-FUN3-CPP: #include "{{.*}}new_helper_decls_test.h" +// CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-FUN3-CPP-NEXT: namespace b { +// CHECK-NEW-FUN3-CPP-NEXT: namespace { +// CHECK-NEW-FUN3-CPP-NEXT: void HelperFun7(); +// CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-FUN3-CPP-NEXT: class HelperC4; +// CHECK-NEW-FUN3-CPP-NEXT: } // namespace +// CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-FUN3-CPP-NEXT: void Fun3() { +// CHECK-NEW-FUN3-CPP-NEXT: HelperFun7(); +// CHECK-NEW-FUN3-CPP-NEXT: HelperC4 *t; +// CHECK-NEW-FUN3-CPP-NEXT: } +// CHECK-NEW-FUN3-CPP-NEXT: namespace { +// CHECK-NEW-FUN3-CPP-NEXT: void HelperFun7() {} +// CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-FUN3-CPP-NEXT: class HelperC4 {}; +// CHECK-NEW-FUN3-CPP-NEXT: } // namespace +// CHECK-NEW-FUN3-CPP-NEXT: } // namespace b +// +// CHECK-OLD-FUN3-CPP-NOT: void HelperFun7(); +// CHECK-OLD-FUN3-CPP-NOT: void HelperFun7() {} +// CHECK-OLD-FUN3-CPP-NOT: void Fun3() { HelperFun7(); } // // Test moving all symbols in headers. // // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ -// RUN: clang-move -names="a::Class1, a::Class2, a::Class3, a::Class4, a::Class5, a::Class5, a::Class6, a::Class7, a::Fun1, a::Fun2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 +// RUN: clang-move -names="a::Class1, a::Class2, a::Class3, a::Class4, a::Class5, a::Class5, a::Class6, a::Class7, a::Fun1, a::Fun2, b::Fun3" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.h -check-prefix=CHECK-NEW-H %s // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CPP %s // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.h -allow-empty -check-prefix=CHECK-EMPTY %s @@ -384,5 +415,24 @@ // CHECK-NEW-CPP-NEXT: void Fun1() { HelperFun5(); } // CHECK-NEW-CPP-SAME: {{[[:space:]]}} // CHECK-NEW-CPP-NEXT: } // namespace a +// CHECK-NEW-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-CPP-NEXT: namespace b { +// CHECK-NEW-CPP-NEXT: namespace { +// CHECK-NEW-CPP-NEXT: void HelperFun7(); +// CHECK-NEW-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-CPP-NEXT: class HelperC4; +// CHECK-NEW-CPP-NEXT: } // namespace +// CHECK-NEW-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-CPP-NEXT: void Fun3() { +// CHECK-NEW-CPP-NEXT: HelperFun7(); +// CHECK-NEW-CPP-NEXT: HelperC4 *t; +// CHECK-NEW-CPP-NEXT: } +// CHECK-NEW-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-CPP-NEXT: namespace { +// CHECK-NEW-CPP-NEXT: void HelperFun7() {} +// CHECK-NEW-CPP-SAME: {{[[:space:]]}} +// CHECK-NEW-CPP-NEXT: class HelperC4 {}; +// CHECK-NEW-CPP-NEXT: } // namespace +// CHECK-NEW-CPP-NEXT: } // namespace b // CHECK-EMPTY: {{^}}{{$}} Index: test/clang-move/Inputs/helper_decls_test.h === --- test/clang-move/Inputs/helper_decls_test.h +++ test/clang-move/Inputs/helper_decls_test.h @@ -33,3 +33,7 @@ inline void
[PATCH] D28801: [clang-move] Handle helpers with forward declarations.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. Lgtm. https://reviews.llvm.org/D28801 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r292215 - [clang-move] Handle helpers with forward declarations.
Author: hokein Date: Tue Jan 17 07:22:37 2017 New Revision: 292215 URL: http://llvm.org/viewvc/llvm-project?rev=292215&view=rev Log: [clang-move] Handle helpers with forward declarations. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28801 Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp clang-tools-extra/trunk/test/clang-move/Inputs/helper_decls_test.cpp clang-tools-extra/trunk/test/clang-move/Inputs/helper_decls_test.h clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292215&r1=292214&r2=292215&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Jan 17 07:22:37 2017 @@ -553,16 +553,22 @@ void ClangMoveTool::registerMatchers(ast // Matchers for helper declarations in old.cc. auto InAnonymousNS = hasParent(namespaceDecl(isAnonymous())); - auto DefinitionInOldCC = allOf(isDefinition(), unless(InMovedClass), InOldCC); - auto IsOldCCHelperDefinition = - allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS)); + auto NotInMovedClass= allOf(unless(InMovedClass), InOldCC); + auto IsOldCCHelper = + allOf(NotInMovedClass, anyOf(isStaticStorageClass(), InAnonymousNS)); // Match helper classes separately with helper functions/variables since we // want to reuse these matchers in finding helpers usage below. - auto HelperFuncOrVar = - namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition), -varDecl(IsOldCCHelperDefinition))); + // + // There could be forward declarations usage for helpers, especially for + // classes and functions. We need include these forward declarations. + // + // Forward declarations for variable helpers will be excluded as these + // declarations (with "extern") are not supposed in cpp file. + auto HelperFuncOrVar = + namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelper), +varDecl(isDefinition(), IsOldCCHelper))); auto HelperClasses = - cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS); + cxxRecordDecl(notInMacro(), NotInMovedClass, InAnonymousNS); // Save all helper declarations in old.cc. Finder->addMatcher( namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"), @@ -650,6 +656,8 @@ void ClangMoveTool::run(const ast_matche Result.Nodes.getNodeAs("helper_decls")) { MovedDecls.push_back(ND); HelperDeclarations.push_back(ND); +DEBUG(llvm::dbgs() << "Add helper : " + << ND->getNameAsString() << " (" << ND << ")\n"); } else if (const auto *UD = Result.Nodes.getNodeAs("using_decl")) { MovedDecls.push_back(UD); @@ -703,9 +711,12 @@ void ClangMoveTool::removeDeclsInOldFile // We remove the helper declarations which are not used in the old.cc after // moving the given declarations. for (const auto *D : HelperDeclarations) { - if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(D))) { + DEBUG(llvm::dbgs() << "Check helper is used: " + << D->getNameAsString() << " (" << D << ")\n"); + if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl( + D->getCanonicalDecl( { DEBUG(llvm::dbgs() << "Helper removed in old.cc: " - << D->getNameAsString() << " " << D << "\n"); + << D->getNameAsString() << " (" << D << ")\n"); RemovedDecls.push_back(D); } } @@ -781,7 +792,8 @@ void ClangMoveTool::moveDeclsToNewFiles( // given symbols being moved. for (const auto *D : NewCCDecls) { if (llvm::is_contained(HelperDeclarations, D) && -!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(D))) +!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl( +D->getCanonicalDecl( continue; DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString() Modified: clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp?rev=292215&r1=292214&r2=292215&view=diff == --- clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp (original) +++ clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp Tue Jan 17 07:22:37 2017 @@ -10,8 +10,11 @@ #include "HelperDeclRefGraph.h" #include "ClangMove.h" #include "clang/AST/Decl.h" +#include "llvm/Suppo
[PATCH] D28801: [clang-move] Handle helpers with forward declarations.
This revision was automatically updated to reflect the committed changes. Closed by commit rL292215: [clang-move] Handle helpers with forward declarations. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D28801?vs=84655&id=84659#toc Repository: rL LLVM https://reviews.llvm.org/D28801 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp clang-tools-extra/trunk/test/clang-move/Inputs/helper_decls_test.cpp clang-tools-extra/trunk/test/clang-move/Inputs/helper_decls_test.h clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Index: clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp === --- clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp +++ clang-tools-extra/trunk/clang-move/HelperDeclRefGraph.cpp @@ -10,8 +10,11 @@ #include "HelperDeclRefGraph.h" #include "ClangMove.h" #include "clang/AST/Decl.h" +#include "llvm/Support/Debug.h" #include +#define DEBUG_TYPE "clang-move" + namespace clang { namespace move { @@ -113,13 +116,19 @@ if (const auto *FuncRef = Result.Nodes.getNodeAs("func_ref")) { const auto *DC = Result.Nodes.getNodeAs("dc"); assert(DC); - -RG->addEdge(getOutmostClassOrFunDecl(DC->getCanonicalDecl()), -getOutmostClassOrFunDecl(FuncRef->getDecl())); +DEBUG(llvm::dbgs() << "Find helper function usage: " + << FuncRef->getDecl()->getNameAsString() << " (" + << FuncRef->getDecl() << ")\n"); +RG->addEdge( +getOutmostClassOrFunDecl(DC->getCanonicalDecl()), +getOutmostClassOrFunDecl(FuncRef->getDecl()->getCanonicalDecl())); } else if (const auto *UsedClass = Result.Nodes.getNodeAs("used_class")) { const auto *DC = Result.Nodes.getNodeAs("dc"); assert(DC); +DEBUG(llvm::dbgs() << "Find helper class usage: " + << UsedClass->getNameAsString() << " (" << UsedClass + << ")\n"); RG->addEdge(getOutmostClassOrFunDecl(DC->getCanonicalDecl()), UsedClass); } } Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp === --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -553,16 +553,22 @@ // Matchers for helper declarations in old.cc. auto InAnonymousNS = hasParent(namespaceDecl(isAnonymous())); - auto DefinitionInOldCC = allOf(isDefinition(), unless(InMovedClass), InOldCC); - auto IsOldCCHelperDefinition = - allOf(DefinitionInOldCC, anyOf(isStaticStorageClass(), InAnonymousNS)); + auto NotInMovedClass= allOf(unless(InMovedClass), InOldCC); + auto IsOldCCHelper = + allOf(NotInMovedClass, anyOf(isStaticStorageClass(), InAnonymousNS)); // Match helper classes separately with helper functions/variables since we // want to reuse these matchers in finding helpers usage below. - auto HelperFuncOrVar = - namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelperDefinition), -varDecl(IsOldCCHelperDefinition))); + // + // There could be forward declarations usage for helpers, especially for + // classes and functions. We need include these forward declarations. + // + // Forward declarations for variable helpers will be excluded as these + // declarations (with "extern") are not supposed in cpp file. + auto HelperFuncOrVar = + namedDecl(notInMacro(), anyOf(functionDecl(IsOldCCHelper), +varDecl(isDefinition(), IsOldCCHelper))); auto HelperClasses = - cxxRecordDecl(notInMacro(), DefinitionInOldCC, InAnonymousNS); + cxxRecordDecl(notInMacro(), NotInMovedClass, InAnonymousNS); // Save all helper declarations in old.cc. Finder->addMatcher( namedDecl(anyOf(HelperFuncOrVar, HelperClasses)).bind("helper_decls"), @@ -650,6 +656,8 @@ Result.Nodes.getNodeAs("helper_decls")) { MovedDecls.push_back(ND); HelperDeclarations.push_back(ND); +DEBUG(llvm::dbgs() << "Add helper : " + << ND->getNameAsString() << " (" << ND << ")\n"); } else if (const auto *UD = Result.Nodes.getNodeAs("using_decl")) { MovedDecls.push_back(UD); @@ -703,9 +711,12 @@ // We remove the helper declarations which are not used in the old.cc after // moving the given declarations. for (const auto *D : HelperDeclarations) { - if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(D))) { + DEBUG(llvm::dbgs() << "Check helper is used: " + << D->getNameAsString() << " (" << D << ")\n"); + if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl( + D->getCanonicalDecl( { DEBUG(llvm::dbgs() << "Helper removed in old.cc: " -
[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. A few more comments. Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:153 + const SourceRange FVLoc(DeclStmt->getLocStart(), Location); + std::string UserWrittenType = + Lexer::getSourceText(CharSourceRange::getCharRange(FVLoc), SM, I wonder whether re-lexing the whole range and working on tokens instead would be a better and more robust approach? You wouldn't have to deal with whitespace and comments then. What do you think? Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:163 + // const int *& -> const int + // long **-> long int + size_t Pos = std::string::npos; Why do we want `long int` and not `long`? Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.h:25 +class OneNamePerDeclarationCheck : public ClangTidyCheck { +private: + std::string getUserWrittenType(const DeclStmt *DeclStmt, SourceManager &SM); nit: move the private section to the end. Comment at: clang-tidy/utils/LexerUtils.cpp:41-56 + const auto &SM = Context.getSourceManager(); + const auto &LO = Context.getLangOpts(); + auto StartOfFile = SM.getLocForStartOfFile(SM.getFileID(Location)); + + Token CurrentToken; + CurrentToken.setKind(tok::unknown); + Is it significantly more efficient than Token Tok; do { Tok = getPreviousNonCommentToken(Context, Location); } while (!Tok.isOneOf(tok::unknown, TokenToFind)); return Tok.getLocation(); ? If it's not, then this function might be not so much useful to be here. At least, its interface is rather specific to the use case you have. Why, for example, it returns a location instead of the token itself? https://reviews.llvm.org/D27621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
ABataev added inline comments. Comment at: lib/CodeGen/CGStmtOpenMP.cpp:84-115 +/// Lexical scope for OpenMP parallel construct, that handles correct codegen +/// for captured expressions. +class OMPParallelScope final : public CodeGenFunction::LexicalScope { + void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) { +OpenMPDirectiveKind Kind = S.getDirectiveKind(); +if (!isOpenMPTargetExecutionDirective(Kind) && +isOpenMPParallelDirective(Kind)) { Could you join it with `OMPLexicalScope` somehow? I don't like the idea of adding a different kind of scope for parallel and other directives. Or follow the solution for `OMPLoopScope`, rather than for `OMPLexicalScope`. https://reviews.llvm.org/D28781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r292218 - Remove dead code.
Author: hokein Date: Tue Jan 17 07:46:59 2017 New Revision: 292218 URL: http://llvm.org/viewvc/llvm-project?rev=292218&view=rev Log: Remove dead code. Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=292218&r1=292217&r2=292218&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Jan 17 07:46:59 2017 @@ -650,9 +650,6 @@ void ClangMoveTool::run(const ast_matche MovedDecls.push_back(FWD); } } else if (const auto *ND = - Result.Nodes.getNodeAs("static_decls")) { -MovedDecls.push_back(ND); - } else if (const auto *ND = Result.Nodes.getNodeAs("helper_decls")) { MovedDecls.push_back(ND); HelperDeclarations.push_back(ND); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.h:543 virtual llvm::Value *emitParallelOrTeamsOutlinedFunction( - const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, - OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen); + const OMPExecutableDirective &D, const CapturedStmt *CS, + const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, I don't think you need to pass a new `CS` parameter here, you can use `InnermostKind` param as an arg to `getCapturedStmt()` function https://reviews.llvm.org/D28753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28799: [llvm-objdump tests] Copy the inputs of tests closer to tests.
This revision was automatically updated to reflect the committed changes. Closed by commit rL29: [llvm-objdump tests] Copy the inputs of tests closer to tests. (authored by krasimir). Changed prior to commit: https://reviews.llvm.org/D28799?vs=84653&id=84667#toc Repository: rL LLVM https://reviews.llvm.org/D28799 Files: llvm/trunk/test/tools/llvm-objdump/X86/Inputs/openbsd-phdrs.elf-x86-64 llvm/trunk/test/tools/llvm-objdump/X86/Inputs/phdr-note.elf-x86-64 llvm/trunk/test/tools/llvm-objdump/X86/Inputs/phdrs.elf-x86-64 llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test Index: llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test === --- llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test +++ llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test @@ -9,7 +9,7 @@ ## 0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED, ## 0x65a41be6 is the value of PT_OPENBSD_BOOTDATA ## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text } -RUN: llvm-objdump -p %p/../../../Object/Inputs/openbsd-phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/openbsd-phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: OPENBSD_RANDOMIZE off0x vaddr 0x paddr 0x align 2**3 Index: llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test === --- llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test +++ llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test @@ -11,7 +11,7 @@ ## d: ## .long 2 ## -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: RELRO off0x1000 vaddr 0x00201000 paddr 0x00201000 align 2**0 @@ -25,7 +25,7 @@ ## .section.note.test,"a",@note ## .quad 42 -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdr-note.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdr-note.elf-x86-64 \ RUN: | FileCheck %s --check-prefix=NOTE NOTE: NOTE off0x0200 vaddr 0x0200 paddr 0x0200 align 2**0 Index: llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test === --- llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test +++ llvm/trunk/test/tools/llvm-objdump/X86/openbsd-headers.test @@ -9,7 +9,7 @@ ## 0x65a3dbe7 is the value of PT_OPENBSD_WXNEEDED, ## 0x65a41be6 is the value of PT_OPENBSD_BOOTDATA ## SECTIONS { . = SIZEOF_HEADERS; .all : { *(.*) } : text } -RUN: llvm-objdump -p %p/../../../Object/Inputs/openbsd-phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/openbsd-phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: OPENBSD_RANDOMIZE off0x vaddr 0x paddr 0x align 2**3 Index: llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test === --- llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test +++ llvm/trunk/test/tools/llvm-objdump/X86/phdrs.test @@ -11,7 +11,7 @@ ## d: ## .long 2 ## -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdrs.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdrs.elf-x86-64 \ RUN: | FileCheck %s CHECK: RELRO off0x1000 vaddr 0x00201000 paddr 0x00201000 align 2**0 @@ -25,7 +25,7 @@ ## .section.note.test,"a",@note ## .quad 42 -RUN: llvm-objdump -p %p/../../../Object/Inputs/phdr-note.elf-x86-64 \ +RUN: llvm-objdump -p %p/Inputs/phdr-note.elf-x86-64 \ RUN: | FileCheck %s --check-prefix=NOTE NOTE: NOTE off0x0200 vaddr 0x0200 paddr 0x0200 align 2**0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D28548: Improve include fixer's ranking by taking the paths into account.
On Tue, Jan 17, 2017 at 12:57 AM Manuel Klimek wrote: > It's by design. Do we want to change this? I always had the impression > turning on the state changes for the list is a bit noisy, but I'm happy if > that's not the general sentiment. > For approval it's important that that reaches the mailing list so it's accounted for/visible. Otherwise it looks like code was sent for review and then committed without review being performed which is not generally accepted. - Dave > > On Mon, Jan 16, 2017, 11:07 PM Benjamin Kramer > wrote: > > I got an email where it says that I accepted the revision. Looks like > phab didn't add cfe-commits to the list of recipients though :( > > On Mon, Jan 16, 2017 at 6:43 PM, David Blaikie wrote: > > Looks like Ben signed off on this on Phab - but the email didn't go to > the > > list (making this look like code was sent for review, then committed, > > without review/approval happening) > > > > Ben: I think Phab doesn't send mail for an approval with no text, so at > > least as a workaround you can write something in the comments section > when > > approving (people often write "LGTM" or similar) to ensure the approval > is > > reflected on the mailing list. > > > > On Wed, Jan 11, 2017 at 1:59 AM Manuel Klimek via Phabricator via > > cfe-commits wrote: > >> > >> klimek created this revision. > >> klimek added a reviewer: bkramer. > >> klimek added a subscriber: cfe-commits. > >> > >> Instead of just using popularity, we also take into account how similar > >> the > >> path of the current file is to the path of the header. > >> Our first approach is to get popularity into a reasonably small scale by > >> taking > >> log2 (which is roughly intuitive to how humans would bucket popularity), > >> and > >> multiply that with the number of matching prefix path fragments of the > >> included > >> header with the current file. > >> Note that currently we do not take special care for unclean paths > >> containing > >> "../" or "./". > >> > >> > >> https://reviews.llvm.org/D28548 > >> > >> Files: > >> include-fixer/IncludeFixer.cpp > >> include-fixer/SymbolIndexManager.cpp > >> include-fixer/SymbolIndexManager.h > >> include-fixer/tool/ClangIncludeFixer.cpp > >> test/include-fixer/Inputs/fake_yaml_db.yaml > >> test/include-fixer/ranking.cpp > >> > >> ___ > >> 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] D28807: [Clang] - Update code to match upcoming llvm::zlib API.
grimar created this revision. https://reviews.llvm.org/D28684 changed llvm::zlib to return Error instead of Status. It was accepted and committed in r292214, but then reverted in r292217 because I missed that clang code also needs to be updated. Patch do that. https://reviews.llvm.org/D28807 Files: lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" @@ -1986,6 +1987,30 @@ free(const_cast(SavedStrings[I])); } +static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, + unsigned SLocBufferBlobCompressedAbbrv, + unsigned SLocBufferBlobAbbrv) { + typedef ASTWriter::RecordData::value_type RecordDataType; + + // Compress the buffer if possible. We expect that almost all PCM + // consumers will not want its contents. + SmallString<0> CompressedBuffer; + if (llvm::zlib::isAvailable()) { +llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer); +if (!E) { + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, + Blob.size() - 1}; + Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, +CompressedBuffer); + return; +} +llvm::consumeError(std::move(E)); + } + + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB}; + Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); +} + /// \brief Writes the block containing the serialized form of the /// source manager. /// @@ -2094,20 +2119,8 @@ const llvm::MemoryBuffer *Buffer = Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager()); StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1); - -// Compress the buffer if possible. We expect that almost all PCM -// consumers will not want its contents. -SmallString<0> CompressedBuffer; -if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) == -llvm::zlib::StatusOK) { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, - Blob.size() - 1}; - Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, -CompressedBuffer); -} else { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB}; - Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); -} +emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, + SLocBufferBlobAbbrv); } } else { // The source location entry is a macro expansion. Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -72,6 +72,7 @@ #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Compression.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -1278,10 +1279,15 @@ unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob); if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) { + if (!llvm::zlib::isAvailable()) { +Error("zlib is not available"); +return nullptr; + } SmallString<0> Uncompressed; - if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) != - llvm::zlib::StatusOK) { -Error("could not decompress embedded file contents"); + if (llvm::Error E = + llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) { +Error("could not decompress embedded file contents: " + + llvm::toString(std::move(E))); return nullptr; } return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name); Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" @@ -1986,6 +1987,30 @@ free(const_cast(SavedStrings[I])); } +static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, + unsigned SLocBuffer
Re: [PATCH] D28807: [Clang] - Update code to match upcoming llvm::zlib API.
LGTM George Rimar via Phabricator writes: > grimar created this revision. > > https://reviews.llvm.org/D28684 changed llvm::zlib to return Error instead of > Status. > It was accepted and committed in r292214, but then reverted in r292217 > because I missed that clang code also needs to be updated. > > Patch do that. > > > https://reviews.llvm.org/D28807 > > Files: > lib/Serialization/ASTReader.cpp > lib/Serialization/ASTWriter.cpp > > > Index: lib/Serialization/ASTWriter.cpp > === > --- lib/Serialization/ASTWriter.cpp > +++ lib/Serialization/ASTWriter.cpp > @@ -73,6 +73,7 @@ > #include "llvm/Support/Casting.h" > #include "llvm/Support/Compression.h" > #include "llvm/Support/EndianStream.h" > +#include "llvm/Support/Error.h" > #include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/MemoryBuffer.h" > #include "llvm/Support/OnDiskHashTable.h" > @@ -1986,6 +1987,30 @@ > free(const_cast(SavedStrings[I])); > } > > +static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, > + unsigned SLocBufferBlobCompressedAbbrv, > + unsigned SLocBufferBlobAbbrv) { > + typedef ASTWriter::RecordData::value_type RecordDataType; > + > + // Compress the buffer if possible. We expect that almost all PCM > + // consumers will not want its contents. > + SmallString<0> CompressedBuffer; > + if (llvm::zlib::isAvailable()) { > +llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), > CompressedBuffer); > +if (!E) { > + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, > + Blob.size() - 1}; > + Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, > +CompressedBuffer); > + return; > +} > +llvm::consumeError(std::move(E)); > + } > + > + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB}; > + Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); > +} > + > /// \brief Writes the block containing the serialized form of the > /// source manager. > /// > @@ -2094,20 +2119,8 @@ > const llvm::MemoryBuffer *Buffer = > Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager()); > StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + > 1); > - > -// Compress the buffer if possible. We expect that almost all PCM > -// consumers will not want its contents. > -SmallString<0> CompressedBuffer; > -if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) == > -llvm::zlib::StatusOK) { > - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, > - Blob.size() - 1}; > - Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, > -CompressedBuffer); > -} else { > - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB}; > - Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); > -} > +emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, > + SLocBufferBlobAbbrv); >} > } else { >// The source location entry is a macro expansion. > Index: lib/Serialization/ASTReader.cpp > === > --- lib/Serialization/ASTReader.cpp > +++ lib/Serialization/ASTReader.cpp > @@ -72,6 +72,7 @@ > #include "llvm/Bitcode/BitstreamReader.h" > #include "llvm/Support/Compression.h" > #include "llvm/Support/Compiler.h" > +#include "llvm/Support/Error.h" > #include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/FileSystem.h" > #include "llvm/Support/MemoryBuffer.h" > @@ -1278,10 +1279,15 @@ > unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob); > > if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) { > + if (!llvm::zlib::isAvailable()) { > +Error("zlib is not available"); > +return nullptr; > + } >SmallString<0> Uncompressed; > - if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) != > - llvm::zlib::StatusOK) { > -Error("could not decompress embedded file contents"); > + if (llvm::Error E = > + llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) { > +Error("could not decompress embedded file contents: " + > + llvm::toString(std::move(E))); > return nullptr; >} >return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name); > > > Index: lib/Serialization/ASTWriter.cpp > === > --- lib/Serialization/ASTWriter.cpp > +++ lib/Serialization/ASTWriter.cpp > @@ -73,6 +73,7 @@ > #include "llvm/Support/Casting.h" > #include "llvm/Support/Compression.h" > #include "llvm/Support/EndianStream.h" > +#include "llvm/Support/Error.h" > #includ
[PATCH] D28807: [Clang] - Update code to match upcoming llvm::zlib API.
This revision was automatically updated to reflect the committed changes. Closed by commit rL292227: [Clang] - Update code to match upcoming llvm::zlib API. (authored by grimar). Changed prior to commit: https://reviews.llvm.org/D28807?vs=84669&id=84676#toc Repository: rL LLVM https://reviews.llvm.org/D28807 Files: cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Index: cfe/trunk/lib/Serialization/ASTWriter.cpp === --- cfe/trunk/lib/Serialization/ASTWriter.cpp +++ cfe/trunk/lib/Serialization/ASTWriter.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" @@ -1986,6 +1987,30 @@ free(const_cast(SavedStrings[I])); } +static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, + unsigned SLocBufferBlobCompressedAbbrv, + unsigned SLocBufferBlobAbbrv) { + typedef ASTWriter::RecordData::value_type RecordDataType; + + // Compress the buffer if possible. We expect that almost all PCM + // consumers will not want its contents. + SmallString<0> CompressedBuffer; + if (llvm::zlib::isAvailable()) { +llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer); +if (!E) { + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, + Blob.size() - 1}; + Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, +CompressedBuffer); + return; +} +llvm::consumeError(std::move(E)); + } + + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB}; + Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); +} + /// \brief Writes the block containing the serialized form of the /// source manager. /// @@ -2094,20 +2119,8 @@ const llvm::MemoryBuffer *Buffer = Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager()); StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1); - -// Compress the buffer if possible. We expect that almost all PCM -// consumers will not want its contents. -SmallString<0> CompressedBuffer; -if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) == -llvm::zlib::StatusOK) { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, - Blob.size() - 1}; - Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, -CompressedBuffer); -} else { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB}; - Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); -} +emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, + SLocBufferBlobAbbrv); } } else { // The source location entry is a macro expansion. Index: cfe/trunk/lib/Serialization/ASTReader.cpp === --- cfe/trunk/lib/Serialization/ASTReader.cpp +++ cfe/trunk/lib/Serialization/ASTReader.cpp @@ -72,6 +72,7 @@ #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Compression.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -1278,10 +1279,15 @@ unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob); if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) { + if (!llvm::zlib::isAvailable()) { +Error("zlib is not available"); +return nullptr; + } SmallString<0> Uncompressed; - if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) != - llvm::zlib::StatusOK) { -Error("could not decompress embedded file contents"); + if (llvm::Error E = + llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) { +Error("could not decompress embedded file contents: " + + llvm::toString(std::move(E))); return nullptr; } return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name); Index: cfe/trunk/lib/Serialization/ASTWriter.cpp === --- cfe/trunk/lib/Serialization/ASTWriter.cpp +++ cfe/trunk/lib/Serialization/ASTWriter.cpp @@ -73,6 +73,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" @@ -1986,6 +1987,30 @@ free(const_cast(Save
[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.
arpith-jacob added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.h:543 virtual llvm::Value *emitParallelOrTeamsOutlinedFunction( - const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, - OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen); + const OMPExecutableDirective &D, const CapturedStmt *CS, + const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, ABataev wrote: > I don't think you need to pass a new `CS` parameter here, you can use > `InnermostKind` param as an arg to `getCapturedStmt()` function Hi Alexey, this is tricky. emitParallelOrTeamsOutlinedFunction() is called from emitCommonOMPParallelDirective(...InnermostKind...). Here is how that function is called for 'parallel for'. ``` void CodeGenFunction::EmitOMPParallelForDirective( const OMPParallelForDirective &S) { ... emitCommonOMPParallelDirective(*this, S, /*InnermostKind=*/OMPD_for, CodeGen); } ``` You'll notice that InnermostKind is OMPD_for. OMPD_for does not have a CapturedStmt, only the OMPD_parallel part. So we cannot use the InnermostKind variable. Here is an alternative solution: I will split emitParallelOrTeamsOutlinedFunction() to emitParallelOutlinedFunction() and emitTeamsOutlinedFunction(). I can then use getCapturedStmt(OMPD_parallel) and getCapturedStmt(OMPD_teams) respectively and I don't have to pass the CS parameter. I also think this makes sense because apart from the host, teams and parallel codegen are very different and so they should be in different routines. Let me know if you disagree. https://reviews.llvm.org/D28753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r292229 - [clang-tidy] Fix crash in modernize-use-using (http://llvm.org/PR29135)
Author: alexfh Date: Tue Jan 17 10:14:03 2017 New Revision: 292229 URL: http://llvm.org/viewvc/llvm-project?rev=292229&view=rev Log: [clang-tidy] Fix crash in modernize-use-using (http://llvm.org/PR29135) Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=292229&r1=292228&r2=292229&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Tue Jan 17 10:14:03 2017 @@ -26,44 +26,37 @@ void UseUsingCheck::registerMatchers(Mat // Checks if 'typedef' keyword can be removed - we do it only if // it is the only declaration in a declaration chain. static bool CheckRemoval(SourceManager &SM, const SourceLocation &LocStart, - const SourceLocation &LocEnd, ASTContext &Context, - SourceRange &ResultRange) { - FileID FID = SM.getFileID(LocEnd); - llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, LocEnd); - Lexer DeclLexer(SM.getLocForStartOfFile(FID), Context.getLangOpts(), - Buffer->getBufferStart(), SM.getCharacterData(LocStart), - Buffer->getBufferEnd()); - Token DeclToken; - bool result = false; - int parenthesisLevel = 0; - - while (!DeclLexer.LexFromRawLexer(DeclToken)) { -if (DeclToken.getKind() == tok::TokenKind::l_paren) - parenthesisLevel++; -if (DeclToken.getKind() == tok::TokenKind::r_paren) - parenthesisLevel--; -if (DeclToken.getKind() == tok::TokenKind::semi) + const SourceLocation &LocEnd, ASTContext &Context) { + std::pair LocInfo = SM.getDecomposedLoc(LocStart); + StringRef File = SM.getBufferData(LocInfo.first); + const char *TokenBegin = File.data() + LocInfo.second; + Lexer DeclLexer(SM.getLocForStartOfFile(LocInfo.first), Context.getLangOpts(), + File.begin(), TokenBegin, File.end()); + + Token Tok; + int ParenLevel = 0; + + while (!DeclLexer.LexFromRawLexer(Tok)) { +if (SM.isBeforeInTranslationUnit(LocEnd, Tok.getLocation())) + break; +if (Tok.getKind() == tok::TokenKind::l_paren) + ParenLevel++; +if (Tok.getKind() == tok::TokenKind::r_paren) + ParenLevel--; +if (Tok.getKind() == tok::TokenKind::semi) break; // if there is comma and we are not between open parenthesis then it is // two or more declatarions in this chain -if (parenthesisLevel == 0 && DeclToken.getKind() == tok::TokenKind::comma) +if (ParenLevel == 0 && Tok.getKind() == tok::TokenKind::comma) return false; -if (DeclToken.isOneOf(tok::TokenKind::identifier, - tok::TokenKind::raw_identifier)) { - auto TokenStr = DeclToken.getRawIdentifier().str(); - - if (TokenStr == "typedef") { -ResultRange = -SourceRange(DeclToken.getLocation(), DeclToken.getEndLoc()); -result = true; - } +if (Tok.is(tok::TokenKind::raw_identifier)) { + if (Tok.getRawIdentifier() == "typedef") +return true; } } - // assert if there was keyword 'typedef' in declaration - assert(result && "No typedef found"); - return result; + return false; } void UseUsingCheck::check(const MatchFinder::MatchResult &Result) { @@ -76,12 +69,12 @@ void UseUsingCheck::check(const MatchFin auto Diag = diag(MatchedDecl->getLocStart(), "use 'using' instead of 'typedef'"); - if (MatchedDecl->getLocStart().isMacroID()) { + + if (MatchedDecl->getLocStart().isMacroID()) return; - } - SourceRange RemovalRange; + if (CheckRemoval(SM, MatchedDecl->getLocStart(), MatchedDecl->getLocEnd(), - Context, RemovalRange)) { + Context)) { Diag << FixItHint::CreateReplacement( MatchedDecl->getSourceRange(), "using " + MatchedDecl->getNameAsString() + " = " + Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp?rev=292229&r1=292228&r2=292229&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp Tue Jan 17 10:14:03 2017 @@ -85,3 +85,12 @@ typedef int bla1, bla2, bla3; CODE; // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: #define CODE typedef int INT +// CHECK-FIXES: CODE; + +struct Foo; +#define Bar Baz +typedef Foo Bar; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +
r292227 - [Clang] - Update code to match upcoming llvm::zlib API.
Author: grimar Date: Tue Jan 17 09:45:31 2017 New Revision: 292227 URL: http://llvm.org/viewvc/llvm-project?rev=292227&view=rev Log: [Clang] - Update code to match upcoming llvm::zlib API. D28684 changed llvm::zlib to return Error instead of Status. It was accepted and committed in r292214, but then reverted in r292217 because I missed that clang code also needs to be updated. Patch do that. D28684 recommitted again as r292226 Differential revision: https://reviews.llvm.org/D28807 Modified: cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=292227&r1=292226&r2=292227&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Jan 17 09:45:31 2017 @@ -72,6 +72,7 @@ #include "llvm/Bitcode/BitstreamReader.h" #include "llvm/Support/Compression.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -1278,10 +1279,15 @@ bool ASTReader::ReadSLocEntry(int ID) { unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob); if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) { + if (!llvm::zlib::isAvailable()) { +Error("zlib is not available"); +return nullptr; + } SmallString<0> Uncompressed; - if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) != - llvm::zlib::StatusOK) { -Error("could not decompress embedded file contents"); + if (llvm::Error E = + llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) { +Error("could not decompress embedded file contents: " + + llvm::toString(std::move(E))); return nullptr; } return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name); Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=292227&r1=292226&r2=292227&view=diff == --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original) +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Jan 17 09:45:31 2017 @@ -73,6 +73,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compression.h" #include "llvm/Support/EndianStream.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" @@ -1986,6 +1987,30 @@ void ASTWriter::WriteHeaderSearch(const free(const_cast(SavedStrings[I])); } +static void emitBlob(llvm::BitstreamWriter &Stream, StringRef Blob, + unsigned SLocBufferBlobCompressedAbbrv, + unsigned SLocBufferBlobAbbrv) { + typedef ASTWriter::RecordData::value_type RecordDataType; + + // Compress the buffer if possible. We expect that almost all PCM + // consumers will not want its contents. + SmallString<0> CompressedBuffer; + if (llvm::zlib::isAvailable()) { +llvm::Error E = llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer); +if (!E) { + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, + Blob.size() - 1}; + Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, +CompressedBuffer); + return; +} +llvm::consumeError(std::move(E)); + } + + RecordDataType Record[] = {SM_SLOC_BUFFER_BLOB}; + Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); +} + /// \brief Writes the block containing the serialized form of the /// source manager. /// @@ -2094,20 +2119,8 @@ void ASTWriter::WriteSourceManagerBlock( const llvm::MemoryBuffer *Buffer = Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager()); StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1); - -// Compress the buffer if possible. We expect that almost all PCM -// consumers will not want its contents. -SmallString<0> CompressedBuffer; -if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) == -llvm::zlib::StatusOK) { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED, - Blob.size() - 1}; - Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record, -CompressedBuffer); -} else { - RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB}; - Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob); -} +emitBlob(Stream, Blob, SLocBufferBlobCompressedAbbrv, +
[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
malcolm.parsons added a comment. This fixes PR24967. Repository: rL LLVM https://reviews.llvm.org/D28768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25001: [Module] Merge function prototype with a non-prototype function declaration
ahatanak added a comment. Sorry for the delay in replying. Comment at: lib/Serialization/ASTReaderDecl.cpp:2715 return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal()) && FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType()); } rsmith wrote: > Instead of your change, can we change this to use `typesAreCompatible` > instead of `hasSameType`? Using typesAreCompatible instead of hasSameType fixes the crash in the test case I added. However, if I declare the prototype in merge-non-prototype-fn.c and the non-prototype function in header2.h, the call to func1 in foo1 picks the non-prototype function. It seems to me that we should do something similar to what Sema::MergeFunctionDecl does, which is to copy the ParamDecls of the prototype to the non-prototype function, but I'm not sure how to go about it. Should we duplicate the logic in ASTReaderDecl.cpp? Or perhaps we should change the code that does the lookup for func1 to pick the prototype when we are handling modules (which seems to be what you are suggesting)? https://reviews.llvm.org/D25001 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r292052 - [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function.
Hi Hans, Could this go into the stable branch ? On Sat, Jan 14, 2017 at 10:11 PM, Argyrios Kyrtzidis via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: akirtzidis > Date: Sun Jan 15 00:11:04 2017 > New Revision: 292052 > > URL: http://llvm.org/viewvc/llvm-project?rev=292052&view=rev > Log: > [code-completion] Fix crash when trying to do postfix completion of > instance member inside a static function. > > Modified: > cfe/trunk/lib/Parse/ParseExpr.cpp > cfe/trunk/test/CodeCompletion/member-access.cpp > > Modified: cfe/trunk/lib/Parse/ParseExpr.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ > ParseExpr.cpp?rev=292052&r1=292051&r2=292052&view=diff > > == > --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) > +++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Jan 15 00:11:04 2017 > @@ -1652,9 +1652,10 @@ Parser::ParsePostfixExpressionSuffix(Exp > >if (Tok.is(tok::code_completion)) { > // Code completion for a member access expression. > -Actions.CodeCompleteMemberReferenceExpr( > -getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow, > -ExprStatementTokLoc == LHS.get()->getLocStart()); > +if (Expr *Base = LHS.get()) > + Actions.CodeCompleteMemberReferenceExpr( > + getCurScope(), Base, OpLoc, OpKind == tok::arrow, > + ExprStatementTokLoc == Base->getLocStart()); > > cutOffParsing(); > return ExprError(); > > Modified: cfe/trunk/test/CodeCompletion/member-access.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ > CodeCompletion/member-access.cpp?rev=292052&r1=292051&r2=292052&view=diff > > == > --- cfe/trunk/test/CodeCompletion/member-access.cpp (original) > +++ cfe/trunk/test/CodeCompletion/member-access.cpp Sun Jan 15 00:11:04 > 2017 > @@ -27,6 +27,16 @@ public: > > void test(const Proxy &p) { >p-> > +} > + > +struct Test1 { > + Base1 b; > + > + static void sfunc() { > +b. // expected-error {{invalid use of member 'b' in static member > function}} > + } > +}; > + >// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | > FileCheck -check-prefix=CHECK-CC1 %s >// CHECK-CC1: Base1 : Base1:: >// CHECK-CC1: member1 : [#int#][#Base1::#]member1 > @@ -39,4 +49,6 @@ void test(const Proxy &p) { >// CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) >// CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) >// CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>) > - > + > +// Make sure this doesn't crash > +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:7 %s -verify > > > ___ > 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] D28691: Support synchronisation scope in Clang atomic builtin functions
rjmccall requested changes to this revision. rjmccall added a comment. This revision now requires changes to proceed. This patch changes the language design of the atomic builtins, which is outside the normal scope of patch review. You need to post an RFC to cfe-dev. I've gone ahead and made some material comments, but the concept itself needs debate. Your proposed language design exposes LLVM internals (the specific values used by llvm::SynchronizationScope) directly to users; that is also unacceptable. Comment at: lib/AST/Expr.cpp:3917 case AO__c11_atomic_init: +return 2; case AO__c11_atomic_load: Add an extra newline here, please, to be consistent with the other cases in the switch. Comment at: lib/CodeGen/CGAtomic.cpp:1033 + assert(isa(Scope) && + "Non-constant synchronization scope not supported"); + auto sco = (llvm::SynchronizationScope)( It is not acceptable to test this exclusively with an assertion; you need to be checking that the argument is an integer constant expression in Sema. Comment at: lib/Sema/SemaChecking.cpp:2922 +Scope = IntegerLiteral::Create(Context, + llvm::APInt(Context.getTypeSize(Context.IntTy), (uint64_t) 1), + Context.IntTy, SourceLocation()); 1 is a magic number here. https://reviews.llvm.org/D28691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.h:543 virtual llvm::Value *emitParallelOrTeamsOutlinedFunction( - const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, - OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen); + const OMPExecutableDirective &D, const CapturedStmt *CS, + const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, arpith-jacob wrote: > ABataev wrote: > > I don't think you need to pass a new `CS` parameter here, you can use > > `InnermostKind` param as an arg to `getCapturedStmt()` function > Hi Alexey, this is tricky. > > emitParallelOrTeamsOutlinedFunction() is called from > emitCommonOMPParallelDirective(...InnermostKind...). Here is how that > function is called for 'parallel for'. > > > ``` > void CodeGenFunction::EmitOMPParallelForDirective( > const OMPParallelForDirective &S) { > ... > emitCommonOMPParallelDirective(*this, S, /*InnermostKind=*/OMPD_for, > CodeGen); > } > > ``` > You'll notice that InnermostKind is OMPD_for. OMPD_for does not have a > CapturedStmt, only the OMPD_parallel part. So we cannot use the > InnermostKind variable. > > Here is an alternative solution: > > I will split emitParallelOrTeamsOutlinedFunction() to > emitParallelOutlinedFunction() and emitTeamsOutlinedFunction(). I can then > use getCapturedStmt(OMPD_parallel) and getCapturedStmt(OMPD_teams) > respectively and I don't have to pass the CS parameter. > > I also think this makes sense because apart from the host, teams and parallel > codegen are very different and so they should be in different routines. > > Let me know if you disagree. Arpith, I'm ok with your idea https://reviews.llvm.org/D28753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28691: Support synchronisation scope in Clang atomic builtin functions
yaxunl added a comment. In https://reviews.llvm.org/D28691#648267, @rjmccall wrote: > This patch changes the language design of the atomic builtins, which is > outside the normal scope of patch review. You need to post an RFC to > cfe-dev. I've gone ahead and made some material comments, but the concept > itself needs debate. > > Your proposed language design exposes LLVM internals (the specific values > used by llvm::SynchronizationScope) directly to users; that is also > unacceptable. I sent an RFC to cfe-dev. For the synchronization scope, I will add Clang's enums for synchronization scopes in a similar fashion as memory order. Different languages can have their own specific synchronization scopes. Then clang translates them to synchronization scopes used by LLVM atomic instructions. Comment at: lib/CodeGen/CGAtomic.cpp:1033 + assert(isa(Scope) && + "Non-constant synchronization scope not supported"); + auto sco = (llvm::SynchronizationScope)( rjmccall wrote: > It is not acceptable to test this exclusively with an assertion; you need to > be checking that the argument is an integer constant expression in Sema. Will add diagnostics to Sema. Comment at: lib/Sema/SemaChecking.cpp:2922 +Scope = IntegerLiteral::Create(Context, + llvm::APInt(Context.getTypeSize(Context.IntTy), (uint64_t) 1), + Context.IntTy, SourceLocation()); rjmccall wrote: > 1 is a magic number here. Will change that to enum. https://reviews.llvm.org/D28691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28691: Support synchronisation scope in Clang atomic builtin functions
yaxunl added a comment. The link for the RFC: http://lists.llvm.org/pipermail/cfe-dev/2017-January/052304.html https://reviews.llvm.org/D28691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28753: [OpenMP] Codegen support for 'target parallel' on the host.
arpith-jacob updated this revision to Diff 84689. arpith-jacob added a comment. The patch was updated to split 'emitParallelOrTeamsOutlinedFunction' into 'emitParallelOutlinedFunction' and 'emitTeamsOutlinedFunction' to enable the use of getCapturedStmt(). Also updated an assert statement for correctness and the switch in getCapturedStmt() to not depend on the input argument. https://reviews.llvm.org/D28753 Files: include/clang/AST/StmtOpenMP.h include/clang/Basic/OpenMPKinds.h include/clang/Sema/Sema.h lib/Basic/OpenMPKinds.cpp lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h lib/Sema/SemaOpenMP.cpp lib/Sema/TreeTransform.h test/OpenMP/target_parallel_codegen.cpp test/OpenMP/target_parallel_codegen_registration.cpp test/OpenMP/target_parallel_codegen_registration_naming.cpp Index: test/OpenMP/target_parallel_codegen_registration_naming.cpp === --- /dev/null +++ test/OpenMP/target_parallel_codegen_registration_naming.cpp @@ -0,0 +1,66 @@ +// Test host codegen. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s + +// Test target parallel codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK + +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +// CHECK: [[CA:%.+]] = type { i32* } + +// CHECK: define {{.*}}i32 @[[NNAME:.+]](i32 {{.*}}%{{.+}}) +int nested(int a){ + // CHECK: call void @__omp_offloading_[[FILEID:[0-9a-f]+_[0-9a-f]+]]_[[NNAME]]_l[[T1L:[0-9]+]]( + #pragma omp target parallel +++a; + + // CHECK: call void @"[[LNAME:.+]]"([[CA]]* + auto F = [&](){ +#pragma omp parallel +{ + #pragma omp target parallel + ++a; +} + }; + + F(); + + return a; +} + +// CHECK: define {{.*}}void @__omp_offloading_[[FILEID]]_[[NNAME]]_l[[T1L]]( +// TCHECK: define {{.*}}void @__omp_offloading_[[FILEID:[0-9a-f]+_[0-9a-f]+]]_[[NNAME:.+]]_l[[T1L:[0-9]+]]( + +// CHECK: define {{.*}}void @"[[LNAME]]"( +// CHECK: call void {{.*}}@__kmpc_fork_call{{.+}}[[PNAME:@.+]] to + +// CHECK: define {{.*}}void [[PNAME]]( +// CHECK: call void @__omp_offloading_[[FILEID]]_[[NNAME]]_l[[T2L:[0-9]+]]( + +// CHECK: define {{.*}}void @__omp_offloading_[[FILEID]]_[[NNAME]]_l[[T2L]]( +// TC
r292234 - Make sure that clang-format input is in the right encoding
Author: phst Date: Tue Jan 17 11:30:55 2017 New Revision: 292234 URL: http://llvm.org/viewvc/llvm-project?rev=292234&view=rev Log: Make sure that clang-format input is in the right encoding Summary: Add unit tests. Reviewers: klimek, massberg Reviewed By: massberg Differential Revision: https://reviews.llvm.org/D28800 Added: cfe/trunk/tools/clang-format/clang-format-test.el Modified: cfe/trunk/tools/clang-format/clang-format.el Added: cfe/trunk/tools/clang-format/clang-format-test.el URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-test.el?rev=292234&view=auto == --- cfe/trunk/tools/clang-format/clang-format-test.el (added) +++ cfe/trunk/tools/clang-format/clang-format-test.el Tue Jan 17 11:30:55 2017 @@ -0,0 +1,110 @@ +;;; clang-format-test.el --- unit tests for clang-format.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2017 Google Inc. + +;; Author: Philipp Stephani + +;; This file is distributed under the University of Illinois Open Source +;; License. See LICENSE.TXT for details. + +;;; Commentary: + +;; Unit tests for clang-format.el. + +;;; Code: + +(require 'clang-format) + +(require 'cl-lib) +(require 'ert) +(require 'pcase) + +(ert-deftest clang-format-buffer--buffer-encoding () + "Tests that encoded text is handled properly." + (cl-letf* ((call-process-args nil) + ((symbol-function 'call-process-region) + (lambda (&rest args) +(push args call-process-args) +(pcase-exhaustive args + (`(,_start ,_end ,_program ,_delete (,stdout ,_stderr) + ,_display . ,_args) + (with-current-buffer stdout + (insert " + + + + +")) + 0) +(with-temp-buffer + (let ((buffer-file-name "foo.cpp") +(buffer-file-coding-system 'utf-8-with-signature-dos) +(default-process-coding-system 'latin-1-unix)) +(insert "ä =ö;\nü= Ã;\n") +(goto-char (point-min)) +(end-of-line) +(clang-format-buffer)) + (should (equal (buffer-string) "ä = ö;\nü = Ã;\n")) + (should (eolp)) + (should (equal (buffer-substring (point) (point-max)) + "\nü = Ã;\n"))) +(should-not (cdr call-process-args)) +(pcase-exhaustive call-process-args + (`((,start ,end ,_program ,delete (,_stdout ,_stderr) ,display . ,args)) + (should-not start) + (should-not end) + (should-not delete) + (should-not display) + (should (equal args + '("-output-replacements-xml" "-assume-filename" "foo.cpp" +"-style" "file" +;; Length of the UTF-8 byte-order mark. +"-offset" "3" +;; We have two lines with 2Ã2 bytes for the umlauts, +;; 2 bytes for the line ending, and 3 bytes for the +;; other ASCII characters each. +"-length" "18" +;; Length of a single line (without line ending) plus +;; BOM. +"-cursor" "10"))) + +(ert-deftest clang-format-buffer--process-encoding () + "Tests that text is sent to the clang-format process in the +right encoding." + (cl-letf* ((hexdump (executable-find "hexdump")) + (original-call-process-region + (symbol-function 'call-process-region)) + (call-process-inputs nil) + ;; We redirect the input to hexdump so that we have guaranteed + ;; ASCII output. + ((symbol-function 'call-process-region) + (lambda (&rest args) +(pcase-exhaustive args + (`(,start ,end ,_program ,_delete (,stdout ,_stderr) +,_display . ,_args) + (with-current-buffer stdout + (insert " + + +")) + (let ((stdin (current-buffer))) + (with-temp-buffer + (prog1 + (let ((stdout (current-buffer))) + (with-current-buffer stdin + (funcall original-call-process-region +start end hexdump nil stdout nil +"-v" "-e" "/1 \"%02x \""))) + (push (buffer-string) call-process-inputs) +(skip-unless hexdump) +(with-temp-buffer + (let ((buffer-file-name "foo.cpp") +(buffer-file-coding-system 'utf-8-with-signature-dos) +(default-process-coding-system 'latin-1-unix)) +(insert "ä\n") +(clang-format-buffer)) + (should (equal (buffer-string) "ä\n")) + (should (eobp))) +(should (equal call-process-inputs '("
[PATCH] D28705: [Sema] Fix bug in handling of designated initializer
rnk accepted this revision. rnk added a comment. lgtm https://reviews.llvm.org/D28705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28349: [Frontend] The macro that describes the Objective-C bool type should be defined in C as well
arphaman added a comment. Ping. Repository: rL LLVM https://reviews.llvm.org/D28349 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28814: [OpenCL] Add missing address spaces in IR generation of Blocks
Anastasia created this revision. ObjC IR generation for Blocks currently: I. Generates local to block variable declaration block literal in case it contains captures. II. Global variable block literal in case it doesn't have any captures. The address spaces are missing however if we use this generation for OpenCL. This patch: - keeps default private address space for blocks generated as local variables (case I from above); - adds global address space for global block literals (case II from the above); - makes the block invoke function and enqueue_kernel prototype with the generic AS block pointer parameter to accommodate both private and global AS cases. - adds block handling into default AS because it's implemented as a special pointer type (BlockPointer) in the frontend and therefore it is used as a pointer everywhere. This is also needed to accommodate both private and global address space blocks for the two cases described above. - removes ObjC RT specific symbols (NSConcreteStackBlock and NSConcreteGlobalBlock) in the OpenCL mode. https://reviews.llvm.org/D28814 Files: lib/AST/Expr.cpp lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBuiltin.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp test/CodeGenOpenCL/cl20-device-side-enqueue.cl test/SemaOpenCL/invalid-block.cl Index: test/SemaOpenCL/invalid-block.cl === --- test/SemaOpenCL/invalid-block.cl +++ test/SemaOpenCL/invalid-block.cl @@ -4,26 +4,34 @@ void f0(int (^const bl)()); // All blocks declarations must be const qualified and initialized. void f1() { - int (^bl1)() = ^() {return 1;}; - int (^const bl2)() = ^(){return 1;}; + int (^bl1)(void) = ^() { +return 1; + }; + int (^const bl2)(void) = ^() { +return 1; + }; f0(bl1); f0(bl2); - bl1 = bl2; // expected-error{{invalid operands to binary expression ('int (^const)()' and 'int (^const)()')}} + bl1 = bl2; // expected-error{{invalid operands to binary expression ('int (__generic ^const)(void)' and 'int (__generic ^const)(void)')}} int (^const bl3)(); // expected-error{{invalid block variable declaration - must be initialized}} } // A block with extern storage class is not allowed. -extern int (^bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} +extern int (^bl)(void) = ^() { + return 1; +}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} void f2() { - extern int (^bl)() = ^(){return 1;}; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} + extern int (^bl)(void) = ^() { +return 1; + }; // expected-error{{invalid block variable declaration - using 'extern' storage class is disallowed}} } // A block cannot be the return value of a function. typedef int (^bl_t)(void); -bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (^const)(void)') is not allowed}} +bl_t f3(bl_t bl); // expected-error{{declaring function return value of type 'bl_t' (aka 'int (__generic ^const)(void)') is not allowed}} struct bl_s { - int (^bl)(void); // expected-error {{the 'int (^const)(void)' type cannot be used to declare a structure or union field}} + int (^bl)(void); // expected-error {{the 'int (__generic ^const)(void)' type cannot be used to declare a structure or union field}} }; void f4() { @@ -45,16 +53,16 @@ bl2_t bl2 = ^(int i) { return 2; }; - bl2_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl2_t' (aka 'int (^const)(int)') type is invalid in OpenCL}} + bl2_t arr[] = {bl1, bl2}; // expected-error {{array of 'bl2_t' (aka 'int (__generic ^const)(int)') type is invalid in OpenCL}} int tmp = i ? bl1(i) // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} : bl2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} } // A block pointer type and all pointer operations are disallowed -void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}} +void f6(bl2_t *bl_ptr) { // expected-error{{pointer to type '__generic bl2_t' (aka 'int (__generic ^const __generic)(int)') is invalid in OpenCL}} bl2_t bl = ^(int i) { return 1; }; - bl2_t *p; // expected-error {{pointer to type '__generic bl2_t' (aka 'int (^const __generic)(int)') is invalid in OpenCL}} - *bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}} - &bl; // expected-error {{invalid argument type 'bl2_t' (aka 'int (^const)(int)') to unary expression}} + bl2_t *p; // expected-error {{pointer to type '__generic bl2_t' (aka 'int (__generic ^const __generic)(int)') is invalid in OpenCL}} + *bl; // expected-error {{invalid argument t
[PATCH] D26649: [CMake] Support lld with LTO bootstrap
beanz added inline comments. Comment at: cfe/trunk/CMakeLists.txt:531 + if(BOOTSTRAP_LLVM_ENABLE_LLD) +add_dependencies(clang-bootstrap-deps lld) + elseif(LLVM_BINUTILS_INCDIR) mehdi_amini wrote: > I come back to this a bit late, sorry, but I'm not sure I understand why this > dependency on the bootstrap happens only when LTO is used? > We should probably separate `LLVM_ENABLE_LTO` and `LLVM_ENABLE_LLD`. You can use LLD without LTO on a wider variety of platforms (including OS X), and you might want to use LLD without LTO. Repository: rL LLVM https://reviews.llvm.org/D26649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28799: [llvm-objdump tests] Copy the inputs of tests closer to tests.
davide added a comment. In https://reviews.llvm.org/D28799#648062, @ioeric wrote: > @davide I think this change makes sense. I'll accept this to unbreak our > internal build. Let us know if you have any concern. Yes, makes sense. Thanks. Repository: rL LLVM https://reviews.llvm.org/D28799 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'
JDevlieghere updated this revision to Diff 84700. JDevlieghere added a comment. - Added test cases suggested by @Prazek - Added test cases suggested by @alexfh I don't match on `CXXUnresolvedConstructExpr` so the template dependent cases are not impacted by this check. This is what I intended, because we cannot make assumptions about the constructor being explicit, narrowing, etc. Repository: rL LLVM https://reviews.llvm.org/D28768 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/ModernizeTidyModule.cpp clang-tidy/modernize/ReturnBracedInitListCheck.cpp clang-tidy/modernize/ReturnBracedInitListCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/modernize-return-braced-init-list.rst test/clang-tidy/modernize-return-braced-init-list.cpp Index: test/clang-tidy/modernize-return-braced-init-list.cpp === --- /dev/null +++ test/clang-tidy/modernize-return-braced-init-list.cpp @@ -0,0 +1,173 @@ +// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- -- +// -std=c++14 + +namespace std { +typedef decltype(sizeof(int)) size_t; + +// libc++'s implementation +template +class initializer_list { + const _E *__begin_; + size_t __size_; + + initializer_list(const _E *__b, size_t __s) + : __begin_(__b), +__size_(__s) {} + +public: + typedef _E value_type; + typedef const _E &reference; + typedef const _E &const_reference; + typedef size_t size_type; + + typedef const _E *iterator; + typedef const _E *const_iterator; + + initializer_list() : __begin_(nullptr), __size_(0) {} + + size_t size() const { return __size_; } + const _E *begin() const { return __begin_; } + const _E *end() const { return __begin_ + __size_; } +}; + +template +class vector { +public: + vector(T){}; + vector(std::initializer_list) {} +}; +} + +class Bar {}; + +class Foo { +public: + Foo(Bar); + explicit Foo(Bar, unsigned int); + Foo(unsigned int); +}; + +class Baz { +public: + Foo m() { +Bar b; +return Foo(b); +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] +// CHECK-FIXES: return {b}; + } +}; + +class Quux : public Foo { +public: + Quux(Bar bar) : Foo(bar){}; +}; + +Foo f() { + Bar b; + return Foo(b); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {b}; +} + +Foo f2() { + Bar b; + return {b}; +} + +auto f3() { + Bar b; + return Foo(b); +} + +#define A(b) Foo(b) + +Foo f4() { + Bar b; + return A(b); +} + +Foo f5() { + Bar b; + return Quux(b); +} + +Foo f6() { + Bar b; + return Foo(b, 1); +} + +std::vector f7() { + int i = 1; + return std::vector(i); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {i}; +} + +Bar f8() { + return {}; +} + +Bar f9() { + return Bar(); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {}; +} + +Bar f10() { + return Bar{}; +} + +Foo f11(Bar b) { + return Foo(b); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {b}; +} + +Foo f12() { + return f11(Bar()); +} + +Foo f13() { + return Foo(Bar()); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {Bar()}; +} + +Foo f14() { + // FIXME: Type narrowing should not occur! + return Foo(-1); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {-1}; +} + +Foo f15() { + return Foo(f10()); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list] + // CHECK-FIXES: return {f10()}; +} + +template +T f16() { + return T(); +} + +template +Foo f17(T t) { + return Foo(t); +} + +template +class BazT { +public: + T m() { +Bar b; +return T(b); + } + + Foo m2(T t) { +return Foo(t); + } +}; + +auto v1 = []() { return std::vector({1, 2}); }(); +auto v2 = []() -> std::vector { return std::vector({1, 2}); }(); Index: docs/clang-tidy/checks/modernize-return-braced-init-list.rst ===
[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
arpith-jacob added inline comments. Comment at: lib/CodeGen/CGStmtOpenMP.cpp:84-115 +/// Lexical scope for OpenMP parallel construct, that handles correct codegen +/// for captured expressions. +class OMPParallelScope final : public CodeGenFunction::LexicalScope { + void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) { +OpenMPDirectiveKind Kind = S.getDirectiveKind(); +if (!isOpenMPTargetExecutionDirective(Kind) && +isOpenMPParallelDirective(Kind)) { ABataev wrote: > Could you join it with `OMPLexicalScope` somehow? I don't like the idea of > adding a different kind of scope for parallel and other directives. > Or follow the solution for `OMPLoopScope`, rather than for `OMPLexicalScope`. Hi Alexey, thanks for looking at this patch. We need a different kind of scope for 'parallel', however, we don't need a different scope for any other directive so the code additions should be limited. Here is my idea for merging it with OMPLexicalScope to reduce code duplication. I can make OMPParallelScope derive from OMPLexicalScope. I'll make emitPreInitStmt a virtual class that can be overridden. ``` class OMPParallelScope final : public OMPLexicalScope { void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) override { OpenMPDirectiveKind Kind = S.getDirectiveKind(); if (!isOpenMPTargetExecutionDirective(Kind) && isOpenMPParallelDirective(Kind)) OMPParallelScope::emitPreInitStmt(CGF, S); } ... } ``` Does that look ok? https://reviews.llvm.org/D28781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
arpith-jacob added inline comments. Comment at: lib/CodeGen/CGStmtOpenMP.cpp:84-115 +/// Lexical scope for OpenMP parallel construct, that handles correct codegen +/// for captured expressions. +class OMPParallelScope final : public CodeGenFunction::LexicalScope { + void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) { +OpenMPDirectiveKind Kind = S.getDirectiveKind(); +if (!isOpenMPTargetExecutionDirective(Kind) && +isOpenMPParallelDirective(Kind)) { arpith-jacob wrote: > ABataev wrote: > > Could you join it with `OMPLexicalScope` somehow? I don't like the idea of > > adding a different kind of scope for parallel and other directives. > > Or follow the solution for `OMPLoopScope`, rather than for > > `OMPLexicalScope`. > Hi Alexey, thanks for looking at this patch. > > We need a different kind of scope for 'parallel', however, we don't need a > different scope for any other directive so the code additions should be > limited. Here is my idea for merging it with OMPLexicalScope to reduce code > duplication. > > I can make OMPParallelScope derive from OMPLexicalScope. I'll make > emitPreInitStmt a virtual class that can be overridden. > > ``` > class OMPParallelScope final : public OMPLexicalScope { > void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) > override { > OpenMPDirectiveKind Kind = S.getDirectiveKind(); > if (!isOpenMPTargetExecutionDirective(Kind) && > isOpenMPParallelDirective(Kind)) > OMPParallelScope::emitPreInitStmt(CGF, S); > } > ... > } > ``` > > Does that look ok? Sorry, the code should read: class OMPParallelScope final : public OMPLexicalScope { void emitPreInitStmt(CodeGenFunction &CGF, const OMPExecutableDirective &S) override { OpenMPDirectiveKind Kind = S.getDirectiveKind(); if (!isOpenMPTargetExecutionDirective(Kind) && isOpenMPParallelDirective(Kind)) //**OMPLexicalScope**//::emitPreInitStmt(CGF, S); } ... } https://reviews.llvm.org/D28781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28080: [Docs][OpenCL] Added OpenCL feature description to user manual.
Anastasia added inline comments. Comment at: docs/UsersManual.rst:2065 + + $ clang -cc1 -triple spir64-unknown-unknown -cl-ext=-cl_khr_fp64 test.cl + pekka.jaaskelainen wrote: > Is this correct? I cannot make it work: > > ``` > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang > -finclude-default-header -emit-llvm -cc1 -triple spir64-unknown-unknown > kernel/test_halfs.cl -c -S -o - > clang-4.0: error: unknown argument: '-cc1' > clang-4.0: error: unknown argument: '-triple' > clang-4.0: error: no such file or directory: 'spir64-unknown-unknown' > ``` > > -target works instead. (But reveals another issue, there's no printf() > declaration, should I file a bug?) > > ``` > ~/local/stow/llvm-4.0-unpatched-Debug/bin/clang -Xclang > -finclude-default-header -emit-llvm -target spir64-unknown-unknown > kernel/test_halfs.cl -c -S -o - > kernel/test_halfs.cl:10:9: warning: implicit declaration of function 'printf' > is invalid in C99 [-Wimplicit-function-declaration] > printf("max(a,b)[0] type=uint2 a=0x15b348c9 b=0xf88e7d07 > want=0xf88e7d07 got=%x\n", max_[0]); > ^ > kernel/test_halfs.cl:10:9: error: function with no prototype cannot use the > spir_function calling convention > 1 warning and 1 error generated. > ``` > > With 3.9 that kernel which calls printf() passes: > ``` > /local/stow/llvm-3.9-debug/bin/clang -Xclang -finclude-default-header > -emit-llvm -target spir64-unknown-unknown kernel/test_halfs.cl -c -S -o - > ; ModuleID = 'kernel/test_halfs.cl' > source_filename = "kernel/test_halfs.cl" > target datalayout = > "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" > target triple = "spir64-unknown-unknown" > > ``` > > > It should be -triple with -cc1 and -target without. clang -cc1 -triple ... clang -target ... We have disabled the C99 builtin functions as per spec v1.2 s6.9.f, but the OpenCL builtins should be available via the header now. As I can see declaration of printf is in the header under CL1.2 and higher. Could you try this command instead: clang -std=CL1.2 test.cl -Xclang -finclude-default-header https://reviews.llvm.org/D28080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28620: Guard __gnuc_va_list typedef
sfertile added a comment. I think the fix/test looks good, but someone with more experience than me should review it before accepting it https://reviews.llvm.org/D28620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28781: [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
arpith-jacob added a comment. Another correction. We'll have to create a similar scope OMPTeamsScope that inherits from OMPLexicalScope for target-teams combined directives. https://reviews.llvm.org/D28781 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28146: [compiler-rt] [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based
dschuff accepted this revision. dschuff added a comment. This revision is now accepted and ready to land. I don't have any particular ownership or knowledge of this file, but the change still LGTM https://reviews.llvm.org/D28146 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28705: [Sema] Fix bug in handling of designated initializer
This revision was automatically updated to reflect the committed changes. Closed by commit rL292245: [Sema] Fix bug in handling of designated initializer. (authored by ahatanak). Changed prior to commit: https://reviews.llvm.org/D28705?vs=84418&id=84714#toc Repository: rL LLVM https://reviews.llvm.org/D28705 Files: cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp Index: cfe/trunk/lib/Sema/SemaInit.cpp === --- cfe/trunk/lib/Sema/SemaInit.cpp +++ cfe/trunk/lib/Sema/SemaInit.cpp @@ -2237,6 +2237,10 @@ } unsigned FieldIndex = 0; + +if (auto *CXXRD = dyn_cast(RT->getDecl())) + FieldIndex = CXXRD->getNumBases(); + for (auto *FI : RT->getDecl()->fields()) { if (FI->isUnnamedBitfield()) continue; Index: cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp === --- cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp +++ cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides +// expected-no-diagnostics + +struct B { + int x; +}; + +struct D : B { + int y; +}; + +void test() { D d = {1, .y = 2}; } Index: cfe/trunk/lib/Sema/SemaInit.cpp === --- cfe/trunk/lib/Sema/SemaInit.cpp +++ cfe/trunk/lib/Sema/SemaInit.cpp @@ -2237,6 +2237,10 @@ } unsigned FieldIndex = 0; + +if (auto *CXXRD = dyn_cast(RT->getDecl())) + FieldIndex = CXXRD->getNumBases(); + for (auto *FI : RT->getDecl()->fields()) { if (FI->isUnnamedBitfield()) continue; Index: cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp === --- cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp +++ cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides +// expected-no-diagnostics + +struct B { + int x; +}; + +struct D : B { + int y; +}; + +void test() { D d = {1, .y = 2}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292245 - [Sema] Fix bug in handling of designated initializer.
Author: ahatanak Date: Tue Jan 17 13:35:54 2017 New Revision: 292245 URL: http://llvm.org/viewvc/llvm-project?rev=292245&view=rev Log: [Sema] Fix bug in handling of designated initializer. CheckDesignatedInitializer wasn't taking into account the base classes when computing the index for the field in the derived class, which caused the test case to crash during IRGen because of a malformed AST. rdar://problem/26795040 Differential Revision: https://reviews.llvm.org/D28705 Added: cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp Modified: cfe/trunk/lib/Sema/SemaInit.cpp Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=292245&r1=292244&r2=292245&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jan 17 13:35:54 2017 @@ -2237,6 +2237,10 @@ InitListChecker::CheckDesignatedInitiali } unsigned FieldIndex = 0; + +if (auto *CXXRD = dyn_cast(RT->getDecl())) + FieldIndex = CXXRD->getNumBases(); + for (auto *FI : RT->getDecl()->fields()) { if (FI->isUnnamedBitfield()) continue; Added: cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp?rev=292245&view=auto == --- cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp (added) +++ cfe/trunk/test/SemaCXX/designated-initializers-base-class.cpp Tue Jan 17 13:35:54 2017 @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify -Winitializer-overrides +// expected-no-diagnostics + +struct B { + int x; +}; + +struct D : B { + int y; +}; + +void test() { D d = {1, .y = 2}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28820: Warn when calling a non interrupt function from an interrupt on ARM
jroelofs created this revision. Herald added a subscriber: aemerson. The idea for this originated from a really tricky bug: ISRs on ARM don't automatically save off the VFP regs, so if say, memcpy gets interrupted and the ISR itself calls memcpy, the regs are left clobbered when the ISR is done. If the equivalent problem is likely to happen on other arches, I'd be happy to extend this to them. Suggestions on a more arch-neutral spelling of the warning itself would be helpful in that case. https://reviews.llvm.org/D28820 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/arm-interrupt-attr.c Index: test/Sema/arm-interrupt-attr.c === --- test/Sema/arm-interrupt-attr.c +++ test/Sema/arm-interrupt-attr.c @@ -17,3 +17,14 @@ __attribute__((interrupt)) void foo8() {} __attribute__((interrupt())) void foo9() {} __attribute__((interrupt(""))) void foo10() {} + +void callee1(); +__attribute__((interrupt("IRQ"))) void callee2(); +void caller1() { + callee1(); + callee2(); +} +__attribute__((interrupt("IRQ"))) void caller2() { + callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}} + callee2(); +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -5395,6 +5395,15 @@ return ExprError(); } + // Interrupt handlers don't save off the VFP regs automatically on ARM, + // so there's some risk when calling out to non-interrupt handler functions + // that the callee might not preserve them. This is easy to diagnose here, + // but can be very challenging to debug. + if (auto *Caller = getCurFunctionDecl()) +if (Caller->hasAttr()) + if (!FDecl->hasAttr()) +Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention); + // Promote the function operand. // We special-case function promotion here because we only allow promoting // builtin functions to function pointers in the callee of a call. Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -259,6 +259,9 @@ "a pointer as the first parameter|a %2 type as the second parameter}1">; def err_anyx86_interrupt_called : Error< "interrupt service routine cannot be called directly">; +def warn_arm_interrupt_calling_convention : Warning< + "call to function without interrupt attribute could clobber interruptee's VFP registers">, + InGroup; def warn_mips_interrupt_attribute : Warning< "MIPS 'interrupt' attribute only applies to functions that have " "%select{no parameters|a 'void' return type}0">, Index: test/Sema/arm-interrupt-attr.c === --- test/Sema/arm-interrupt-attr.c +++ test/Sema/arm-interrupt-attr.c @@ -17,3 +17,14 @@ __attribute__((interrupt)) void foo8() {} __attribute__((interrupt())) void foo9() {} __attribute__((interrupt(""))) void foo10() {} + +void callee1(); +__attribute__((interrupt("IRQ"))) void callee2(); +void caller1() { + callee1(); + callee2(); +} +__attribute__((interrupt("IRQ"))) void caller2() { + callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}} + callee2(); +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -5395,6 +5395,15 @@ return ExprError(); } + // Interrupt handlers don't save off the VFP regs automatically on ARM, + // so there's some risk when calling out to non-interrupt handler functions + // that the callee might not preserve them. This is easy to diagnose here, + // but can be very challenging to debug. + if (auto *Caller = getCurFunctionDecl()) +if (Caller->hasAttr()) + if (!FDecl->hasAttr()) +Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention); + // Promote the function operand. // We special-case function promotion here because we only allow promoting // builtin functions to function pointers in the callee of a call. Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -259,6 +259,9 @@ "a pointer as the first parameter|a %2 type as the second parameter}1">; def err_anyx86_interrupt_called : Error< "interrupt service routine cannot be called directly">; +def warn_arm_interrupt_calling_convention : Warning< + "call to function without interrupt attribute could clobber interruptee's VFP registers">, + InGroup; def warn_mips_interrupt_attribute : Warning< "MIPS 'i
[PATCH] D28821: [CMake] Separate LLVM_ENABLE_LTO and LLVM_ENABLE_LLD
phosek created this revision. Herald added a subscriber: mgorny. These two are options independent: it's possible to use LLD without LTO, and it's possible to do LTO build without LLD. Repository: rL LLVM https://reviews.llvm.org/D28821 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -515,6 +515,10 @@ set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/) set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/) + if(BOOTSTRAP_LLVM_ENABLE_LLD) +add_dependencies(clang-bootstrap-deps lld) + endif() + # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED) if(APPLE) @@ -531,9 +535,7 @@ -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR}) elseif(NOT WIN32) add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib) - if(BOOTSTRAP_LLVM_ENABLE_LLD) -add_dependencies(clang-bootstrap-deps lld) - elseif(LLVM_BINUTILS_INCDIR) + if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR) add_dependencies(clang-bootstrap-deps LLVMgold) endif() set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -515,6 +515,10 @@ set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/) set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/) + if(BOOTSTRAP_LLVM_ENABLE_LLD) +add_dependencies(clang-bootstrap-deps lld) + endif() + # If the next stage is LTO we need to depend on LTO and possibly lld or LLVMgold if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO AND NOT LLVM_BUILD_INSTRUMENTED) if(APPLE) @@ -531,9 +535,7 @@ -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR}) elseif(NOT WIN32) add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib) - if(BOOTSTRAP_LLVM_ENABLE_LLD) -add_dependencies(clang-bootstrap-deps lld) - elseif(LLVM_BINUTILS_INCDIR) + if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR) add_dependencies(clang-bootstrap-deps LLVMgold) endif() set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26649: [CMake] Support lld with LTO bootstrap
phosek added inline comments. Comment at: cfe/trunk/CMakeLists.txt:531 + if(BOOTSTRAP_LLVM_ENABLE_LLD) +add_dependencies(clang-bootstrap-deps lld) + elseif(LLVM_BINUTILS_INCDIR) beanz wrote: > mehdi_amini wrote: > > I come back to this a bit late, sorry, but I'm not sure I understand why > > this dependency on the bootstrap happens only when LTO is used? > > > We should probably separate `LLVM_ENABLE_LTO` and `LLVM_ENABLE_LLD`. You can > use LLD without LTO on a wider variety of platforms (including OS X), and you > might want to use LLD without LTO. Yes, this is unnecessarily restrictive; see D28821. Repository: rL LLVM https://reviews.llvm.org/D26649 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292247 - Fix Python 3 language issues and add an explicit check for Python version == 2.
Author: jbcoe Date: Tue Jan 17 14:03:54 2017 New Revision: 292247 URL: http://llvm.org/viewvc/llvm-project?rev=292247&view=rev Log: Fix Python 3 language issues and add an explicit check for Python version == 2. Summary: Python bindings cannot support Python 3 without work being done to fix Unicode c-string conversion. This was attempted in https://reviews.llvm.org/D26082. That patch was reverted due to memory access issues on Linux. This revision fixes enough language compatibility issues for the clang module to be loaded and raise an error if the Python version is not 2. Reviewers: mgorny, MathieuDuponchelle, rengolin, compnerd Reviewed By: compnerd Differential Revision: https://reviews.llvm.org/D28682 Modified: cfe/trunk/bindings/python/clang/__init__.py cfe/trunk/bindings/python/clang/cindex.py Modified: cfe/trunk/bindings/python/clang/__init__.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/__init__.py?rev=292247&r1=292246&r2=292247&view=diff == --- cfe/trunk/bindings/python/clang/__init__.py (original) +++ cfe/trunk/bindings/python/clang/__init__.py Tue Jan 17 14:03:54 2017 @@ -20,5 +20,13 @@ The available modules are: Bindings for the Clang indexing library. """ + +# Python 3 uses unicode for strings. The bindings, in particular the interaction +# with ctypes, need modifying to handle conversions between unicode and +# c-strings. +import sys +if sys.version_info[0] != 2: +raise Exception("Only Python 2 is supported.") + __all__ = ['cindex'] Modified: cfe/trunk/bindings/python/clang/cindex.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=292247&r1=292246&r2=292247&view=diff == --- cfe/trunk/bindings/python/clang/cindex.py (original) +++ cfe/trunk/bindings/python/clang/cindex.py Tue Jan 17 14:03:54 2017 @@ -554,8 +554,8 @@ class BaseEnumeration(object): if value >= len(self.__class__._kinds): self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1) if self.__class__._kinds[value] is not None: -raise ValueError,'{0} value {1} already loaded'.format( -str(self.__class__), value) +raise ValueError('{0} value {1} already loaded'.format( +str(self.__class__), value)) self.value = value self.__class__._kinds[value] = self self.__class__._name_map = None @@ -577,7 +577,7 @@ class BaseEnumeration(object): @classmethod def from_id(cls, id): if id >= len(cls._kinds) or cls._kinds[id] is None: -raise ValueError,'Unknown template argument kind %d' % id +raise ValueError('Unknown template argument kind %d' % id) return cls._kinds[id] def __repr__(self): @@ -1777,7 +1777,7 @@ class StorageClass(object): if value >= len(StorageClass._kinds): StorageClass._kinds += [None] * (value - len(StorageClass._kinds) + 1) if StorageClass._kinds[value] is not None: -raise ValueError,'StorageClass already loaded' +raise ValueError('StorageClass already loaded') self.value = value StorageClass._kinds[value] = self StorageClass._name_map = None @@ -1798,7 +1798,7 @@ class StorageClass(object): @staticmethod def from_id(id): if id >= len(StorageClass._kinds) or not StorageClass._kinds[id]: -raise ValueError,'Unknown storage class %d' % id +raise ValueError('Unknown storage class %d' % id) return StorageClass._kinds[id] def __repr__(self): @@ -2729,9 +2729,9 @@ class TranslationUnit(ClangObject): # FIXME: It would be great to support an efficient version # of this, one day. value = value.read() -print value +print(value) if not isinstance(value, str): -raise TypeError,'Unexpected unsaved file contents.' +raise TypeError('Unexpected unsaved file contents.') unsaved_files_array[i].name = name unsaved_files_array[i].contents = value unsaved_files_array[i].length = len(value) @@ -2793,9 +2793,9 @@ class TranslationUnit(ClangObject): # FIXME: It would be great to support an efficient version # of this, one day. value = value.read() -print value +print(value) if not isinstance(value, str): -raise TypeError,'Unexpected unsaved file contents.' +raise TypeError('Unexpected unsaved file contents.') unsaved_files_array[i].name = name unsaved_files_array[i].cont
[PATCH] D28821: [CMake] Separate LLVM_ENABLE_LTO and LLVM_ENABLE_LLD
beanz accepted this revision. beanz added a comment. This revision is now accepted and ready to land. Many thanks for the quick cleanup! LGTM! Repository: rL LLVM https://reviews.llvm.org/D28821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28821: [CMake] Separate LLVM_ENABLE_LTO and LLVM_ENABLE_LLD
mehdi_amini added a comment. Yes, thanks! Repository: rL LLVM https://reviews.llvm.org/D28821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls
ahatanak added inline comments. Comment at: lib/Sema/SemaCodeComplete.cpp:961 +// then incorrectly applied to the target declaration. This can be avoided +// by resetting the declaration that's being hidden. +if (Hiding && isa(Hiding)) I'm not sure about this, but is it correct for VisibleDeclsRecord::checkHidden to return the UsingDecl when the UsingShadowDecl is being passed? I'm thinking perhaps the bug is in that function, since it seems like it should just return a nullptr instead if UsingDecl doesn't hide UsingShadowDecl, . Repository: rL LLVM https://reviews.llvm.org/D28514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28146: [compiler-rt] [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based
This revision was automatically updated to reflect the committed changes. Closed by commit rL292257: [test] [builtins] Remove obsolete/UB tests in __fixuns?fdi based (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D28146?vs=82625&id=84737#toc Repository: rL LLVM https://reviews.llvm.org/D28146 Files: compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c Index: compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c === --- compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c +++ compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c @@ -95,9 +95,6 @@ if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL)) return 1; -if (test__fixunsdfdi(0x1.p+64, 0xLL)) -return 1; - #if !TARGET_LIBGCC if (test__fixunsdfdi(-0x1.Fp+62, 0)) return 1; Index: compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c === --- compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c +++ compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c @@ -79,8 +79,6 @@ return 1; if (test__fixunssfdi(0x1.00p+63F, 0x8000LL)) return 1; -if (test__fixunssfdi(0x1.00p+64F, 0xLL)) -return 1; if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL)) return 1; if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL)) Index: compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c === --- compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c +++ compiler-rt/trunk/test/builtins/Unit/fixunsdfdi_test.c @@ -95,9 +95,6 @@ if (test__fixunsdfdi(0x1.Ep+62, 0x7800LL)) return 1; -if (test__fixunsdfdi(0x1.p+64, 0xLL)) -return 1; - #if !TARGET_LIBGCC if (test__fixunsdfdi(-0x1.Fp+62, 0)) return 1; Index: compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c === --- compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c +++ compiler-rt/trunk/test/builtins/Unit/fixunssfdi_test.c @@ -79,8 +79,6 @@ return 1; if (test__fixunssfdi(0x1.00p+63F, 0x8000LL)) return 1; -if (test__fixunssfdi(0x1.00p+64F, 0xLL)) -return 1; if (test__fixunssfdi(0x1.FEp+62F, 0x7F80LL)) return 1; if (test__fixunssfdi(0x1.FCp+62F, 0x7F00LL)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support
dim added inline comments. Comment at: include/__threading_support:43 +#if defined(__clang__) && __has_attribute(acquire_capability) +#define _LIBCPP_THREAD_SAFETY_ATTRIBUTE(x) __attribute__((x)) I think the least intrusive way would be to add a `defined(__FreeBSD__)` here, as that is the only OS with thread annotations for pthread functions, as far as I know. The alternative is to turn off the capability annotations for `__libcpp_mutex_t` again, and use the `no_thread_safety_analysis` annotation for the functions. Any particular preference? https://reviews.llvm.org/D28520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292265 - UsersManual.rst: add missing newline
Author: hans Date: Tue Jan 17 15:31:57 2017 New Revision: 292265 URL: http://llvm.org/viewvc/llvm-project?rev=292265&view=rev Log: UsersManual.rst: add missing newline Modified: cfe/trunk/docs/UsersManual.rst Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=292265&r1=292264&r2=292265&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Tue Jan 17 15:31:57 2017 @@ -1099,6 +1099,7 @@ are listed below. .. option:: -fstrict-vtable-pointers + Enable optimizations based on the strict rules for overwriting polymorphic C++ objects, i.e. the vptr is invariant during an object's lifetime. This enables better devirtualization. Turned off by default, because it is ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292268 - [xray] try to fix thumb buildbot
Author: rengolin Date: Tue Jan 17 15:37:24 2017 New Revision: 292268 URL: http://llvm.org/viewvc/llvm-project?rev=292268&view=rev Log: [xray] try to fix thumb buildbot Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=292268&r1=292267&r2=292268&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 17 15:37:24 2017 @@ -4996,6 +4996,7 @@ void Clang::ConstructJob(Compilation &C, switch (Triple.getArch()) { case llvm::Triple::x86_64: case llvm::Triple::arm: + case llvm::Triple::thumb: case llvm::Triple::aarch64: // Supported. break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292269 - [WebAssembly] Add minimal support for the new wasm object format triple.
Author: djg Date: Tue Jan 17 15:46:38 2017 New Revision: 292269 URL: http://llvm.org/viewvc/llvm-project?rev=292269&view=rev Log: [WebAssembly] Add minimal support for the new wasm object format triple. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=292269&r1=292268&r2=292269&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Jan 17 15:46:38 2017 @@ -8976,11 +8976,19 @@ static TargetInfo *AllocateTarget(const return new SPIR64TargetInfo(Triple, Opts); } case llvm::Triple::wasm32: -if (!(Triple == llvm::Triple("wasm32-unknown-unknown"))) +if (Triple.getSubArch() != llvm::Triple::NoSubArch || +Triple.getVendor() != llvm::Triple::UnknownVendor || +Triple.getOS() != llvm::Triple::UnknownOS || +Triple.getEnvironment() != llvm::Triple::UnknownEnvironment || +!(Triple.isOSBinFormatELF() || Triple.isOSBinFormatWasm())) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); case llvm::Triple::wasm64: -if (!(Triple == llvm::Triple("wasm64-unknown-unknown"))) +if (Triple.getSubArch() != llvm::Triple::NoSubArch || +Triple.getVendor() != llvm::Triple::UnknownVendor || +Triple.getOS() != llvm::Triple::UnknownOS || +Triple.getEnvironment() != llvm::Triple::UnknownEnvironment || +!(Triple.isOSBinFormatELF() || Triple.isOSBinFormatWasm())) return nullptr; return new WebAssemblyOSTargetInfo(Triple, Opts); Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=292269&r1=292268&r2=292269&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Jan 17 15:46:38 2017 @@ -999,6 +999,7 @@ static const char* getSectionNameForBitc return "__LLVM,__bitcode"; case Triple::COFF: case Triple::ELF: + case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmbc"; } @@ -1011,6 +1012,7 @@ static const char* getSectionNameForComm return "__LLVM,__cmdline"; case Triple::COFF: case Triple::ELF: + case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmcmd"; } Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=292269&r1=292268&r2=292269&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 17 15:46:38 2017 @@ -3341,6 +3341,7 @@ CodeGenModule::GetAddrOfConstantCFString llvm_unreachable("unknown file format"); case llvm::Triple::COFF: case llvm::Triple::ELF: + case llvm::Triple::Wasm: GV->setSection("cfstring"); break; case llvm::Triple::MachO: Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=292269&r1=292268&r2=292269&view=diff == --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue Jan 17 15:46:38 2017 @@ -2015,10 +2015,11 @@ void ItaniumCXXABI::EmitGuardedInit(Code // The ABI says: "It is suggested that it be emitted in the same COMDAT // group as the associated data object." In practice, this doesn't work for -// non-ELF object formats, so only do it for ELF. +// non-ELF and non-Wasm object formats, so only do it for ELF and Wasm. llvm::Comdat *C = var->getComdat(); if (!D.isLocalVarDecl() && C && -CGM.getTarget().getTriple().isOSBinFormatELF()) { +(CGM.getTarget().getTriple().isOSBinFormatELF() || + CGM.getTarget().getTriple().isOSBinFormatWasm())) { guard->setComdat(C); // An inline variable's guard function is run from the per-TU // initialization function, not via a dedicated global ctor function, so @@ -3534,8 +3535,9 @@ static StructorCodegen getCodegenToUse(C return StructorCodegen::RAUW; if (llvm::GlobalValue::isWeakForLinker(Linkage)) { -// Only ELF supports COMDATs with arbitrary names (C5/D5). -if (CGM.getTarget().getTriple().isOSBinFormatELF()) +// Only ELF and wasm support COMDATs with arbitrary names (C5/D5). +if (CGM.getTarget().getTriple().isOSBinFormatELF() || +CGM.getTarget().getTriple().isOSBinFormatWasm()) return StructorCodegen::COMDAT; return StructorCodegen::Emit; } __
[PATCH] D27202: [analyzer] Do not conjure a symbol for return value of a conservatively evaluated function
zaks.anna added a comment. From what I recall, it is not clear that this patch is the step in the right direction. At least, it need more investigation. https://reviews.llvm.org/D27202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28793: [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.
tra added inline comments. Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:124 +} +inline long long __nvvm_max_i(long long __a, long long __b) { + return __a >= __b ? __a : __b; Shouldn't that be `_ll` ? That was the name of the max of long long arguments in BuiltinsNVPTX.def. Speaking of which, it would need to have builtins removed, too. Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:127 +} +inline unsigned long long __nvvm_max_ui(unsigned long long __a, +unsigned long long __b) { _ull? Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:135 +} +inline long long __nvvm_min_i(long long __a, long long __b) { + return __a < __b ? __a : __b; _ll Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:138 +} +inline unsigned long long __nvvm_min_ui(unsigned long long __a, +unsigned long long __b) { _ull Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:142 +} +inline float __nvvm_h2f(short __a) __asm("llvm.convert.from.fp16"); + Do we still need int_nvvm_h2f in NVPTXIntrinsics.td ? How about their int_nvvm_f2h* counterparts? https://reviews.llvm.org/D28793 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r292276 - Fix std::string assignment ambiguity from braced initializer lists.
Author: ericwf Date: Tue Jan 17 16:10:32 2017 New Revision: 292276 URL: http://llvm.org/viewvc/llvm-project?rev=292276&view=rev Log: Fix std::string assignment ambiguity from braced initializer lists. When support for `basic_string_view` was added to string it also added new assignment operators from `basic_string_view`. These caused ambiguity when assigning from a braced initializer. This patch fixes that regression by making the basic_string_view assignment operator rank lower in overload resolution by making it a template. Added: libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp Modified: libcxx/trunk/include/string libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=292276&r1=292275&r2=292276&view=diff == --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Tue Jan 17 16:10:32 2017 @@ -818,6 +818,7 @@ public: operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } basic_string& operator=(const basic_string& __str); +template _LIBCPP_INLINE_VISIBILITY basic_string& operator=(__self_view __sv) {return assign(__sv);} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES Added: libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp?rev=292276&view=auto == --- libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp (added) +++ libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp Tue Jan 17 16:10:32 2017 @@ -0,0 +1,36 @@ +//===--===// +// +// 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. +// +//===--===// + +// UNSUPPORTED: c++98, c++03 + +// + +// basic_string& +// operator=(basic_string&& str); + +#include +#include + +#include "test_macros.h" + +int main() +{ + // Test that assignment from {} and {ptr, len} are allowed and are not + // ambiguous. + { +std::string s = "hello world"; +s = {}; +assert(s.empty()); + } + { +std::string s = "hello world"; +s = {"abc", 2}; +assert(s == "ab"); + } +} Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp?rev=292276&r1=292275&r2=292276&view=diff == --- libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp (original) +++ libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp Tue Jan 17 16:10:32 2017 @@ -28,12 +28,23 @@ test(std::basic_string_view sv) typedef std::basic_string, test_allocator > S; typedef typename S::traits_type T; typedef typename S::allocator_type A; + { S s2(sv); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == sv.size()); assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); assert(s2.get_allocator() == A()); assert(s2.capacity() >= s2.size()); + } + { +S s2; +s2 = sv; +LIBCPP_ASSERT(s2.__invariants()); +assert(s2.size() == sv.size()); +assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); +assert(s2.get_allocator() == A()); +assert(s2.capacity() >= s2.size()); + } } template @@ -42,12 +53,23 @@ test(std::basic_string_view sv, c { typedef std::basic_string, A> S; typedef typename S::traits_type T; + { S s2(sv, a); LIBCPP_ASSERT(s2.__invariants()); assert(s2.size() == sv.size()); assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); assert(s2.get_allocator() == a); assert(s2.capacity() >= s2.size()); + } + { +S s2(a); +s2 = sv; +LIBCPP_ASSERT(s2.__invariants()); +assert(s2.size() == sv.size()); +assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); +assert(s2.get_allocator() == a); +assert(s2.capacity() >= s2.size()); + } } int main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r292276 - Fix std::string assignment ambiguity from braced initializer lists.
Hi Marshall, We should merge this fix into the 4.0 release. It fixes a regression which was reported by the FreeBSD maintainers here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216177 Am I OK to merge this? /Eric On Tue, Jan 17, 2017 at 3:10 PM, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ericwf > Date: Tue Jan 17 16:10:32 2017 > New Revision: 292276 > > URL: http://llvm.org/viewvc/llvm-project?rev=292276&view=rev > Log: > Fix std::string assignment ambiguity from braced initializer lists. > > When support for `basic_string_view` was added to string it also > added new assignment operators from `basic_string_view`. These caused > ambiguity when assigning from a braced initializer. This patch fixes > that regression by making the basic_string_view assignment operator > rank lower in overload resolution by making it a template. > > Added: > libcxx/trunk/test/std/strings/basic.string/string.cons/ > brace_assignment.pass.cpp > Modified: > libcxx/trunk/include/string > libcxx/trunk/test/std/strings/basic.string/string.cons/ > string_view.pass.cpp > > Modified: libcxx/trunk/include/string > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ > string?rev=292276&r1=292275&r2=292276&view=diff > > == > --- libcxx/trunk/include/string (original) > +++ libcxx/trunk/include/string Tue Jan 17 16:10:32 2017 > @@ -818,6 +818,7 @@ public: > operator __self_view() const _NOEXCEPT { return __self_view(data(), > size()); } > > basic_string& operator=(const basic_string& __str); > +template > _LIBCPP_INLINE_VISIBILITY > basic_string& operator=(__self_view __sv) {return assign(__sv);} > #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES > > Added: libcxx/trunk/test/std/strings/basic.string/string.cons/ > brace_assignment.pass.cpp > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > strings/basic.string/string.cons/brace_assignment.pass. > cpp?rev=292276&view=auto > > == > --- > libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp > (added) > +++ > libcxx/trunk/test/std/strings/basic.string/string.cons/brace_assignment.pass.cpp > Tue Jan 17 16:10:32 2017 > @@ -0,0 +1,36 @@ > +//===-- > ===// > +// > +// 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. > +// > +//===-- > ===// > + > +// UNSUPPORTED: c++98, c++03 > + > +// > + > +// basic_string& > +// operator=(basic_string&& str); > + > +#include > +#include > + > +#include "test_macros.h" > + > +int main() > +{ > + // Test that assignment from {} and {ptr, len} are allowed and are not > + // ambiguous. > + { > +std::string s = "hello world"; > +s = {}; > +assert(s.empty()); > + } > + { > +std::string s = "hello world"; > +s = {"abc", 2}; > +assert(s == "ab"); > + } > +} > > Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/ > string_view.pass.cpp > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > strings/basic.string/string.cons/string_view.pass.cpp?rev= > 292276&r1=292275&r2=292276&view=diff > > == > --- > libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp > (original) > +++ > libcxx/trunk/test/std/strings/basic.string/string.cons/string_view.pass.cpp > Tue Jan 17 16:10:32 2017 > @@ -28,12 +28,23 @@ test(std::basic_string_view sv) > typedef std::basic_string, > test_allocator > S; > typedef typename S::traits_type T; > typedef typename S::allocator_type A; > + { > S s2(sv); > LIBCPP_ASSERT(s2.__invariants()); > assert(s2.size() == sv.size()); > assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > assert(s2.get_allocator() == A()); > assert(s2.capacity() >= s2.size()); > + } > + { > +S s2; > +s2 = sv; > +LIBCPP_ASSERT(s2.__invariants()); > +assert(s2.size() == sv.size()); > +assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > +assert(s2.get_allocator() == A()); > +assert(s2.capacity() >= s2.size()); > + } > } > > template > @@ -42,12 +53,23 @@ test(std::basic_string_view sv, c > { > typedef std::basic_string, A> S; > typedef typename S::traits_type T; > + { > S s2(sv, a); > LIBCPP_ASSERT(s2.__invariants()); > assert(s2.size() == sv.size()); > assert(T::compare(s2.data(), sv.data(), sv.size()) == 0); > assert(s2.get_allocator() == a); > assert(s2.capacity() >= s2.size()); > + } > + { > +S s2(a); > +s2 = sv; >
[libcxx] r292281 - [libcxx] [test] Don't ask whether Incomplete& can be assigned to.
Author: stl_msft Date: Tue Jan 17 16:24:45 2017 New Revision: 292281 URL: http://llvm.org/viewvc/llvm-project?rev=292281&view=rev Log: [libcxx] [test] Don't ask whether Incomplete& can be assigned to. This is the subject of an active NB comment. Regardless of what the Working Paper currently says, asking this question is morally wrong, because the answer can change when the type is completed. C1XX now detects such precondition violations and complains about them; perhaps Clang should too. Fixes D28591. Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp Modified: libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp?rev=292281&r1=292280&r2=292281&view=diff == --- libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp Tue Jan 17 16:24:45 2017 @@ -82,5 +82,4 @@ int main() // pointer to incomplete template type test_is_assignable*&, X*> (); -test_is_not_assignable(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28520: Disable -Wthread-safety-analysis for some functions in __thread_support
delesley added a comment. Sorry about the slow response. My main concern here is that the thread safety analysis was designed for use with a library that wraps the system mutex in a separate Mutex class. We did that specifically to avoid breaking anything; code has to opt-in to the static checking by defining and using a Mutex class, and the API of that class is restricted to calls that can be easily checked via annotations. Including attributes directly in the standard library has the potential to cause lots of breakage and false positives. Is there some way to control the #ifdefs so that the annotations are turned off by default for everyone except possibly freebsd, but there's still a way to turn them on for users who want to see the warnings? I'm not a libcxx expert. https://reviews.llvm.org/D28520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r292291 - Don't strip -m32 from the user provide command line flags. This fixes the compiler-rt 32 bit sanitizer build
Author: ericwf Date: Tue Jan 17 17:27:56 2017 New Revision: 292291 URL: http://llvm.org/viewvc/llvm-project?rev=292291&view=rev Log: Don't strip -m32 from the user provide command line flags. This fixes the compiler-rt 32 bit sanitizer build Modified: libcxx/trunk/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=292291&r1=292290&r2=292291&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Tue Jan 17 17:27:56 2017 @@ -395,7 +395,7 @@ include(HandleLibCXXABI) # Setup the ABI if (NOT LIBCXX_STANDALONE_BUILD) # Remove flags that may have snuck in. remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG - -lc++abi -m32) + -lc++abi) endif() remove_flags(-stdlib=libc++ -stdlib=libstdc++) @@ -404,7 +404,7 @@ remove_flags(-stdlib=libc++ -stdlib=libs # non-debug DLLs remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") -# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. +# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEqDANTIC. # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors # so they don't get transformed into -Wno and -errors respectivly. remove_flags(-Wno-pedantic -pedantic-errors -pedantic) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28832: Improve redefinition errors pointing to the same header.
bruno created this revision. Diagnostics related to redefinition errors that point to the same header file do not provide much information that helps fixing the issue. In modules context it usually happens because of a non modular include, in non-module context it might happen because of the lack of header guardas. This patch tries to improve this situation by enhancing diagnostics in this particular scenario. If the approach seems reasonable, I can extend it to other relevant redefinition_error diagnostic call sites. Modules --- In file included from x.c:2: Inputs4/C.h:3:5: error: redefinition of 'c' int c = 1; ^ In module 'X' imported from x.c:1: Inputs4/C.h:3:5: note: previous definition is here int c = 1; ^ 1 warning and 1 error generated. After this patch In file included from x.c:2: Inputs4/C.h:3:5: error: redefinition of 'c' int c = 1; ^ In module 'X' imported from x.c:1: Inputs4/B.h:3:10: note: 'Inputs4/C.h' included multiple times, additional (likely non-modular) include site in module 'X.B' #include "C.h" ^ 1 error generated. Inputs4/module.modulemap:6:10: note: consider adding 'Inputs4/C.h' as part of 'X.B' definition in module B { ^ 1 error generated. Without Modules --- In file included from x.c:2: ./a.h:1:5: error: redefinition of 'yyy' int yyy = 42; ^ ./a.h:1:5: note: previous definition is here int yyy = 42; ^ 1 error generated. After this patch In file included from x.c:2: ./a.h:1:5: error: redefinition of 'yyy' int yyy = 42; ^ x.c:1:10: note: './a.h' included multiple times, consider augmenting this header with #ifdef guards #include "a.h" ^ 1 error generated. https://reviews.llvm.org/D28832 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaDecl.cpp test/Modules/Inputs/SameHeader/A.h test/Modules/Inputs/SameHeader/B.h test/Modules/Inputs/SameHeader/C.h test/Modules/Inputs/SameHeader/module.modulemap test/Modules/redefinition-same-header.m test/Sema/redefinition-same-header.c Index: test/Sema/redefinition-same-header.c === --- /dev/null +++ test/Sema/redefinition-same-header.c @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: echo 'int yyy = 42;' > %t/a.h +// RUN: %clang_cc1 -fsyntax-only %s -I%t -verify + +// expected-error@a.h:1 {{redefinition of 'yyy'}} +// expected-note-re@redefinition-same-header.c:9 {{'{{.*}}/a.h' included multiple times, consider augmenting this header with #ifdef guards}} + +#include "a.h" +#include "a.h" + +int foo() { return yyy; } Index: test/Modules/redefinition-same-header.m === --- /dev/null +++ test/Modules/redefinition-same-header.m @@ -0,0 +1,10 @@ +// RUN: rm -rf %t.tmp +// RUN: %clang_cc1 -fsyntax-only -I %S/Inputs/SameHeader -fmodules \ +// RUN: -fimplicit-module-maps -fmodules-cache-path=%t.tmp %s -verify + +// expected-error@Inputs/SameHeader/C.h:3 {{redefinition of 'c'}} +// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}/C.h' included multiple times, additional (likely non-modular) include site in module 'X.B'}} +// expected-note-re@Inputs/SameHeader/module.modulemap:6 {{consider adding '{{.*}}/C.h' as part of 'X.B' definition in}} + +#include "A.h" // maps to a modular +#include "C.h" // textual include Index: test/Modules/Inputs/SameHeader/module.modulemap === --- /dev/null +++ test/Modules/Inputs/SameHeader/module.modulemap @@ -0,0 +1,11 @@ +module X { + module A { +header "A.h" +export * + } + module B { +header "B.h" +export * + } + export * +} Index: test/Modules/Inputs/SameHeader/C.h === --- /dev/null +++ test/Modules/Inputs/SameHeader/C.h @@ -0,0 +1,4 @@ +#ifndef __C_h__ +#define __C_h__ +int c = 1; +#endif Index: test/Modules/Inputs/SameHeader/B.h === --- /dev/null +++ test/Modules/Inputs/SameHeader/B.h @@ -0,0 +1,4 @@ +#ifndef __B_h__ +#define __B_h__ +#include "C.h" +#endif Index: test/Modules/Inputs/SameHeader/A.h === --- /dev/null +++ test/Modules/Inputs/SameHeader/A.h @@ -0,0 +1,3 @@ +#ifndef __A_h__ +#define __A_h__ +#endif Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -3728,6 +3728,49 @@ New->setImplicitlyInline(); } +void Sema::diagnoseRedefinition(SourceLocation Old, SourceLocation New) { + SourceManager &SrcMgr = getSourceManager(); + auto FNewDecLoc = SrcMgr.getDecomposedLoc(New); + auto FOldDecLoc = SrcMgr.getDecomposedLoc(Old); + auto *FNew = SrcMgr.getFileEntryForID(FNewDecLoc.first); + auto *FOld = SrcMgr.getFileEntryForID(FOldDecLoc.first); + // Is it
[libcxx] r292294 - Fix type_info's constructor by making it explicit again.
Author: ericwf Date: Tue Jan 17 17:41:42 2017 New Revision: 292294 URL: http://llvm.org/viewvc/llvm-project?rev=292294&view=rev Log: Fix type_info's constructor by making it explicit again. In recent changes type_info's private constructor was accidentally made implicit. This patch fixes that. Modified: libcxx/trunk/include/typeinfo libcxx/trunk/test/std/language.support/support.rtti/type.info/type_info.pass.cpp Modified: libcxx/trunk/include/typeinfo URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=292294&r1=292293&r2=292294&view=diff == --- libcxx/trunk/include/typeinfo (original) +++ libcxx/trunk/include/typeinfo Tue Jan 17 17:41:42 2017 @@ -95,12 +95,13 @@ protected: uintptr_t __type_name; _LIBCPP_INLINE_VISIBILITY -type_info(const char* __n) : __type_name(reinterpret_cast(__n)) {} +explicit type_info(const char* __n) + : __type_name(reinterpret_cast(__n)) {} #else const char *__type_name; _LIBCPP_INLINE_VISIBILITY -type_info(const char* __n) : __type_name(__n) {} +explicit type_info(const char* __n) : __type_name(__n) {} #endif public: Modified: libcxx/trunk/test/std/language.support/support.rtti/type.info/type_info.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.rtti/type.info/type_info.pass.cpp?rev=292294&r1=292293&r2=292294&view=diff == --- libcxx/trunk/test/std/language.support/support.rtti/type.info/type_info.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.rtti/type.info/type_info.pass.cpp Tue Jan 17 17:41:42 2017 @@ -10,11 +10,16 @@ // test type_info #include +#include #include #include +bool test_constructor_explicit(std::type_info const&) { return false; } +bool test_constructor_explicit(std::string const&) { return true; } + int main() { + { const std::type_info& t1 = typeid(int); const std::type_info& t2 = typeid(int); assert(t1 == t2); @@ -23,4 +28,13 @@ int main() assert(!t1.before(t2)); assert(strcmp(t1.name(), t2.name()) == 0); assert(strcmp(t1.name(), t3.name()) != 0); + } + { +// type_info has a protected constructor taking a string literal. This +// constructor is not intended for users. However it still participates +// in overload resolution, so we need to ensure that it is marked explicit +// to avoid ambiguous conversions. +// See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216201 +assert(test_constructor_explicit("abc")); + } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r292294 - Fix type_info's constructor by making it explicit again.
FYI Once the bots finish checking this commit I'm going to merge this into the 4.0 branch. This fixes a very recently introduced regression. /Eric On Tue, Jan 17, 2017 at 4:41 PM, Eric Fiselier via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ericwf > Date: Tue Jan 17 17:41:42 2017 > New Revision: 292294 > > URL: http://llvm.org/viewvc/llvm-project?rev=292294&view=rev > Log: > Fix type_info's constructor by making it explicit again. > > In recent changes type_info's private constructor was > accidentally made implicit. This patch fixes that. > > Modified: > libcxx/trunk/include/typeinfo > libcxx/trunk/test/std/language.support/support.rtti/ > type.info/type_info.pass.cpp > > Modified: libcxx/trunk/include/typeinfo > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ > typeinfo?rev=292294&r1=292293&r2=292294&view=diff > > == > --- libcxx/trunk/include/typeinfo (original) > +++ libcxx/trunk/include/typeinfo Tue Jan 17 17:41:42 2017 > @@ -95,12 +95,13 @@ protected: > uintptr_t __type_name; > > _LIBCPP_INLINE_VISIBILITY > -type_info(const char* __n) : > __type_name(reinterpret_cast(__n)) > {} > +explicit type_info(const char* __n) > + : __type_name(reinterpret_cast(__n)) {} > #else > const char *__type_name; > > _LIBCPP_INLINE_VISIBILITY > -type_info(const char* __n) : __type_name(__n) {} > +explicit type_info(const char* __n) : __type_name(__n) {} > #endif > > public: > > Modified: libcxx/trunk/test/std/language.support/support.rtti/ > type.info/type_info.pass.cpp > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > language.support/support.rtti/type.info/type_info.pass.cpp? > rev=292294&r1=292293&r2=292294&view=diff > > == > --- libcxx/trunk/test/std/language.support/support.rtti/ > type.info/type_info.pass.cpp (original) > +++ libcxx/trunk/test/std/language.support/support.rtti/ > type.info/type_info.pass.cpp Tue Jan 17 17:41:42 2017 > @@ -10,11 +10,16 @@ > // test type_info > > #include > +#include > #include > #include > > +bool test_constructor_explicit(std::type_info const&) { return false; } > +bool test_constructor_explicit(std::string const&) { return true; } > + > int main() > { > + { > const std::type_info& t1 = typeid(int); > const std::type_info& t2 = typeid(int); > assert(t1 == t2); > @@ -23,4 +28,13 @@ int main() > assert(!t1.before(t2)); > assert(strcmp(t1.name(), t2.name()) == 0); > assert(strcmp(t1.name(), t3.name()) != 0); > + } > + { > +// type_info has a protected constructor taking a string literal. This > +// constructor is not intended for users. However it still > participates > +// in overload resolution, so we need to ensure that it is marked > explicit > +// to avoid ambiguous conversions. > +// See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216201 > +assert(test_constructor_explicit("abc")); > + } > } > > > ___ > 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
[libcxx] r292297 - Allow sym_diff.py to report non-zero for non-breaking ABI changes
Author: ericwf Date: Tue Jan 17 18:05:01 2017 New Revision: 292297 URL: http://llvm.org/viewvc/llvm-project?rev=292297&view=rev Log: Allow sym_diff.py to report non-zero for non-breaking ABI changes Modified: libcxx/trunk/lib/abi/CMakeLists.txt libcxx/trunk/utils/sym_check/sym_check/diff.py libcxx/trunk/utils/sym_check/sym_diff.py Modified: libcxx/trunk/lib/abi/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CMakeLists.txt?rev=292297&r1=292296&r2=292297&view=diff == --- libcxx/trunk/lib/abi/CMakeLists.txt (original) +++ libcxx/trunk/lib/abi/CMakeLists.txt Tue Jan 17 18:05:01 2017 @@ -22,7 +22,8 @@ if (LIBCXX_HAS_ABILIST_CONFIGURATION) set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist") set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_check/sym_diff.py") add_custom_target(check-cxx-abilist -${SYMDIFF_EXE} --only-stdlib-symbols ${ABILIST_FILE} $ +${SYMDIFF_EXE} --only-stdlib-symbols --strict ${ABILIST_FILE} +$ DEPENDS cxx_shared COMMENT "Testing ABI compatibility...") endif() Modified: libcxx/trunk/utils/sym_check/sym_check/diff.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/sym_check/sym_check/diff.py?rev=292297&r1=292296&r2=292297&view=diff == --- libcxx/trunk/utils/sym_check/sym_check/diff.py (original) +++ libcxx/trunk/utils/sym_check/sym_check/diff.py Tue Jan 17 18:05:01 2017 @@ -98,4 +98,6 @@ def report_diff(added_syms, removed_syms report += 'ABI BREAKAGE: SYMBOLS ADDED OR REMOVED!' else: report += 'Symbols match.' -return report, int(abi_break) +is_different = abi_break or bool(len(added_syms)) \ + or bool(len(changed_syms)) +return report, abi_break, is_different Modified: libcxx/trunk/utils/sym_check/sym_diff.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/sym_check/sym_diff.py?rev=292297&r1=292296&r2=292297&view=diff == --- libcxx/trunk/utils/sym_check/sym_diff.py (original) +++ libcxx/trunk/utils/sym_check/sym_diff.py Tue Jan 17 18:05:01 2017 @@ -30,6 +30,10 @@ def main(): parser.add_argument('--only-stdlib-symbols', dest='only_stdlib', help="Filter all symbols not related to the stdlib", action='store_true', default=False) +parser.add_argument('--strict', dest='strict', +help="Exit with a non-zero status if any symbols " + "differ", +action='store_true', default=False) parser.add_argument( '-o', '--output', dest='output', help='The output file. stdout is used if not given', @@ -54,16 +58,16 @@ def main(): added, removed, changed = diff.diff(old_syms_list, new_syms_list) if args.removed_only: added = {} -report, is_break = diff.report_diff(added, removed, changed, -names_only=args.names_only, -demangle=args.demangle) +report, is_break, is_different = diff.report_diff( +added, removed, changed, names_only=args.names_only, +demangle=args.demangle) if args.output is None: print(report) else: with open(args.output, 'w') as f: f.write(report + '\n') -sys.exit(is_break) - +exit_code = 1 if is_break or (args.strict and is_different) else 0 +sys.exit(exit_code) if __name__ == '__main__': main() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r291963 - [clang] Emit `diagnose_if` warnings from system headers
Richard, what do you think? On Fri, Jan 13, 2017 at 3:16 PM, Eric Fiselier wrote: > I would love to see this merged. It would make it easier to write libc++ > tests if the tests didn't have to worry about the old 4.0 behavior. > > CC'ing Richard: Would merging this be OK? > > On Fri, Jan 13, 2017 at 3:46 PM, George Burgess IV > wrote: >> >> Do we want to consider merging this into the release branch? Seems like >> more of a bugfix than a feature to me. >> >> On Fri, Jan 13, 2017 at 2:11 PM, Eric Fiselier via cfe-commits >> wrote: >>> >>> Author: ericwf >>> Date: Fri Jan 13 16:11:40 2017 >>> New Revision: 291963 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=291963&view=rev >>> Log: >>> [clang] Emit `diagnose_if` warnings from system headers >>> >>> Summary: In order for libc++ to meaningfully use `diagnose_if` warnings >>> they need to be emitted from system headers by default. This patch changes >>> the `diagnose_if` warning diagnostic to be shown in system headers. >>> >>> Reviewers: george.burgess.iv, rsmith, aaron.ballman >>> >>> Subscribers: cfe-commits >>> >>> Differential Revision: https://reviews.llvm.org/D28703 >>> >>> Added: >>> cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h >>> Modified: >>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> cfe/trunk/test/Sema/diagnose_if.c >>> >>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291963&r1=291962&r2=291963&view=diff >>> >>> == >>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 >>> 16:11:40 2017 >>> @@ -3380,7 +3380,8 @@ def note_ovl_candidate_has_pass_object_s >>> "candidate address cannot be taken because parameter %0 has " >>> "pass_object_size attribute">; >>> def err_diagnose_if_succeeded : Error<"%0">; >>> -def warn_diagnose_if_succeeded : Warning<"%0">, >>> InGroup; >>> +def warn_diagnose_if_succeeded : Warning<"%0">, >>> InGroup, >>> +ShowInSystemHeader; >>> def note_ovl_candidate_disabled_by_function_cond_attr : Note< >>> "candidate disabled: %0">; >>> def note_ovl_candidate_disabled_by_extension : Note< >>> >>> Added: cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h?rev=291963&view=auto >>> >>> == >>> --- cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h (added) >>> +++ cfe/trunk/test/Sema/Inputs/diagnose-if-warn-system-header.h Fri Jan >>> 13 16:11:40 2017 >>> @@ -0,0 +1,11 @@ >>> +#pragma GCC system_header >>> + >>> +inline int system_header_func(int x) >>> + __attribute__((diagnose_if(x == x, "system header warning", >>> "warning"))) // expected-note {{from 'diagnose_if' attribute}} >>> +{ >>> + return 0; >>> +} >>> + >>> +void test_system_header() { >>> + system_header_func(0); // expected-warning {{system header warning}} >>> +} >>> >>> Modified: cfe/trunk/test/Sema/diagnose_if.c >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/diagnose_if.c?rev=291963&r1=291962&r2=291963&view=diff >>> >>> == >>> --- cfe/trunk/test/Sema/diagnose_if.c (original) >>> +++ cfe/trunk/test/Sema/diagnose_if.c Fri Jan 13 16:11:40 2017 >>> @@ -150,3 +150,6 @@ void alwaysWarnWithArg(int a) _diagnose_ >>> void runAlwaysWarnWithArg(int a) { >>>alwaysWarnWithArg(a); // expected-warning{{alwaysWarn}} >>> } >>> + >>> +// Test that diagnose_if warnings generated in system headers are not >>> ignored. >>> +#include "Inputs/diagnose-if-warn-system-header.h" >>> >>> >>> ___ >>> 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] D28785: Split exception.cpp and new.cpp implementation into different files for different runtimes
EricWF updated this revision to Diff 84770. EricWF added a comment. Herald added a subscriber: mgorny. - Allow standalone libc++ build on OS X to default to using `libc++abi`. https://reviews.llvm.org/D28785 Files: CMakeLists.txt include/exception include/new include/typeinfo src/exception.cpp src/new.cpp src/support/runtime/exception_fallback.ipp src/support/runtime/exception_glibcxx.ipp src/support/runtime/exception_libcxxabi.ipp src/support/runtime/exception_libcxxrt.ipp src/support/runtime/exception_msvc.ipp src/support/runtime/exception_pointer_cxxabi.ipp src/support/runtime/exception_pointer_glibcxx.ipp src/support/runtime/exception_pointer_unimplemented.ipp src/support/runtime/new_handler_fallback.ipp src/typeinfo.cpp Index: src/typeinfo.cpp === --- src/typeinfo.cpp +++ src/typeinfo.cpp @@ -6,74 +6,11 @@ // Source Licenses. See LICENSE.TXT for details. // //===--===// -#include - -#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ -(defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)) -#include -#endif #include "typeinfo" -#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) || \ -defined(_LIBCPP_ABI_MICROSOFT) // FIXME: This is a temporary workaround +#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) std::type_info::~type_info() { } #endif - -#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) - -std::bad_cast::bad_cast() _NOEXCEPT -{ -} - -std::bad_typeid::bad_typeid() _NOEXCEPT -{ -} - -#ifndef __GLIBCXX__ - -std::bad_cast::~bad_cast() _NOEXCEPT -{ -} - -const char* -std::bad_cast::what() const _NOEXCEPT -{ - return "std::bad_cast"; -} - -std::bad_typeid::~bad_typeid() _NOEXCEPT -{ -} - -const char* -std::bad_typeid::what() const _NOEXCEPT -{ - return "std::bad_typeid"; -} - -#if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) - // On Darwin, the cxa_bad_* functions cannot be in the lower level library - // because bad_cast and bad_typeid are defined in his higher level library - void __cxxabiv1::__cxa_bad_typeid() - { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_typeid(); -#else - _VSTD::abort(); -#endif - } - void __cxxabiv1::__cxa_bad_cast() - { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_cast(); -#else - _VSTD::abort(); -#endif - } -#endif - -#endif // !__GLIBCXX__ -#endif // !LIBCXXRT && !_LIBCPPABI_VERSION Index: src/support/runtime/new_handler_fallback.ipp === --- /dev/null +++ src/support/runtime/new_handler_fallback.ipp @@ -0,0 +1,27 @@ +// -*- C++ -*- +//===--===// +// +// 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. +// +//===--===// + +namespace std { + +_LIBCPP_SAFE_STATIC static std::new_handler __new_handler; + +new_handler +set_new_handler(new_handler handler) _NOEXCEPT +{ +return __sync_lock_test_and_set(&__new_handler, handler); +} + +new_handler +get_new_handler() _NOEXCEPT +{ +return __sync_fetch_and_add(&__new_handler, nullptr); +} + +} // namespace std Index: src/support/runtime/exception_pointer_unimplemented.ipp === --- /dev/null +++ src/support/runtime/exception_pointer_unimplemented.ipp @@ -0,0 +1,80 @@ +// -*- C++ -*- +//===--===// +// +// 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 + +namespace std { + +exception_ptr::~exception_ptr() _NOEXCEPT +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT +: __ptr_(other.__ptr_) +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT +{ +# warning exception_ptr not yet implemented + fprintf(stderr, "exception_ptr not yet implemented\n"); + ::abort(); +} + +nested_exception::nested_exception() _NOEXCEPT +: __ptr_(current_exception()) +{ +} + +#if !defined(__GLIBCXX__) + +nested_exception::~nested_exception() _NOEXCEPT +{ +} + +#endif + +_LIBCPP_NORETURN +void +nested_exception::rethrow_nested() const +{ +# warning exception_ptr not yet i
Re: [libcxx] r292013 - Fix last_write_time tests for filesystems that don't support negative and very large times
Yes, go ahead. Apologies for the delay. - Hans On Sat, Jan 14, 2017 at 5:54 AM, Eric Fiselier wrote: > +1 from me. @Hans am I OK to merge this? > > On Sat, Jan 14, 2017 at 4:53 AM, Hahnfeld, Jonas > wrote: >> >> Hi Hans, >> >> can this be merged for 4.0? Eric suggested this in >> https://reviews.llvm.org/D22452 so I think he should be fine. >> >> Thanks, >> Jonas >> >> Am Samstag, den 14.01.2017, 11:35 + schrieb Jonas Hahnfeld via >> cfe-commits: >> >> Author: hahnfeld >> Date: Sat Jan 14 05:35:15 2017 >> New Revision: 292013 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=292013&view=rev >> Log: >> Fix last_write_time tests for filesystems that don't support negative and >> very large times >> >> Seems to be the case for NFS. >> >> Original patch by Eric Fiselier! >> Differential Revision: https://reviews.llvm.org/D22452 >> >> Modified: >> >> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> >> Modified: >> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=292013&r1=292012&r2=292013&view=diff >> >> == >> --- >> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> (original) >> +++ >> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp >> Sat Jan 14 05:35:15 2017 >> @@ -72,13 +72,60 @@ std::pair GetS >> return {st.st_atime, st.st_mtime}; >> } >> >> -inline bool TimeIsRepresentableAsTimeT(file_time_type tp) { >> +namespace { >> +bool TestSupportsNegativeTimes() { >> +using namespace std::chrono; >> +std::error_code ec; >> +std::time_t old_write_time, new_write_time; >> +{ // WARNING: Do not assert in this scope. >> +scoped_test_env env; >> +const path file = env.create_file("file", 42); >> +old_write_time = LastWriteTime(file); >> +file_time_type tp(seconds(-5)); >> +fs::last_write_time(file, tp, ec); >> +new_write_time = LastWriteTime(file); >> +} >> +return !ec && new_write_time <= -5; >> +} >> + >> +bool TestSupportsMaxTime() { >> using namespace std::chrono; >> using Lim = std::numeric_limits; >> -auto sec = duration_cast(tp.time_since_epoch()).count(); >> -return (sec >= Lim::min() && sec <= Lim::max()); >> +auto max_sec = >> duration_cast(file_time_type::max().time_since_epoch()).count(); >> +if (max_sec > Lim::max()) return false; >> +std::error_code ec; >> +std::time_t old_write_time, new_write_time; >> +{ // WARNING: Do not assert in this scope. >> +scoped_test_env env; >> +const path file = env.create_file("file", 42); >> +old_write_time = LastWriteTime(file); >> +file_time_type tp = file_time_type::max(); >> +fs::last_write_time(file, tp, ec); >> +new_write_time = LastWriteTime(file); >> +} >> +return !ec && new_write_time > max_sec - 1; >> } >> >> +static const bool SupportsNegativeTimes = TestSupportsNegativeTimes(); >> +static const bool SupportsMaxTime = TestSupportsMaxTime(); >> + >> +} // end namespace >> + >> +// Check if a time point is representable on a given filesystem. Check >> that: >> +// (A) 'tp' is representable as a time_t >> +// (B) 'tp' is non-negative or the filesystem supports negative times. >> +// (C) 'tp' is not 'file_time_type::max()' or the filesystem supports the >> max >> +// value. >> +inline bool TimeIsRepresentableByFilesystem(file_time_type tp) { >> +using namespace std::chrono; >> +using Lim = std::numeric_limits; >> +auto sec = duration_cast(tp.time_since_epoch()).count(); >> +auto microsec = >> duration_cast(tp.time_since_epoch()).count(); >> +if (sec < Lim::min() || sec > Lim::max()) return false; >> +else if (microsec < 0 && !SupportsNegativeTimes) return false; >> +else if (tp == file_time_type::max() && !SupportsMaxTime) return >> false; >> +return true; >> +} >> >> TEST_SUITE(exists_test_suite) >> >> @@ -214,15 +261,17 @@ TEST_CASE(set_last_write_time_dynamic_en >> >> file_time_type got_time = last_write_time(TC.p); >> >> -TEST_CHECK(got_time != old_time); >> -if (TC.new_time < epoch_time) { >> -TEST_CHECK(got_time <= TC.new_time); >> -TEST_CHECK(got_time > TC.new_time - Sec(1)); >> -} else { >> -TEST_CHECK(got_time <= TC.new_time + Sec(1)); >> -TEST_CHECK(got_time >= TC.new_time - Sec(1)); >> +if (TimeIsRepresentableByFilesystem(TC.new_time)) { >> +TEST_CHECK(got_time != old_time); >> +if (TC.new_time < epoch_time) { >> +TEST_CHECK(got_time <= TC.new_time); >> +
[libcxx] r292309 - Merge r292294: Fix type_info's constructor by making it explicit again.
Author: ericwf Date: Tue Jan 17 18:14:31 2017 New Revision: 292309 URL: http://llvm.org/viewvc/llvm-project?rev=292309&view=rev Log: Merge r292294: Fix type_info's constructor by making it explicit again. In recent changes type_info's private constructor was accidentally made implicit. This patch fixes that. Modified: libcxx/branches/release_40/include/typeinfo libcxx/branches/release_40/test/std/language.support/support.rtti/type.info/type_info.pass.cpp Modified: libcxx/branches/release_40/include/typeinfo URL: http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/typeinfo?rev=292309&r1=292308&r2=292309&view=diff == --- libcxx/branches/release_40/include/typeinfo (original) +++ libcxx/branches/release_40/include/typeinfo Tue Jan 17 18:14:31 2017 @@ -95,12 +95,13 @@ protected: uintptr_t __type_name; _LIBCPP_INLINE_VISIBILITY -type_info(const char* __n) : __type_name(reinterpret_cast(__n)) {} +explicit type_info(const char* __n) + : __type_name(reinterpret_cast(__n)) {} #else const char *__type_name; _LIBCPP_INLINE_VISIBILITY -type_info(const char* __n) : __type_name(__n) {} +explicit type_info(const char* __n) : __type_name(__n) {} #endif public: Modified: libcxx/branches/release_40/test/std/language.support/support.rtti/type.info/type_info.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/test/std/language.support/support.rtti/type.info/type_info.pass.cpp?rev=292309&r1=292308&r2=292309&view=diff == --- libcxx/branches/release_40/test/std/language.support/support.rtti/type.info/type_info.pass.cpp (original) +++ libcxx/branches/release_40/test/std/language.support/support.rtti/type.info/type_info.pass.cpp Tue Jan 17 18:14:31 2017 @@ -10,11 +10,16 @@ // test type_info #include +#include #include #include +bool test_constructor_explicit(std::type_info const&) { return false; } +bool test_constructor_explicit(std::string const&) { return true; } + int main() { + { const std::type_info& t1 = typeid(int); const std::type_info& t2 = typeid(int); assert(t1 == t2); @@ -23,4 +28,13 @@ int main() assert(!t1.before(t2)); assert(strcmp(t1.name(), t2.name()) == 0); assert(strcmp(t1.name(), t3.name()) != 0); + } + { +// type_info has a protected constructor taking a string literal. This +// constructor is not intended for users. However it still participates +// in overload resolution, so we need to ensure that it is marked explicit +// to avoid ambiguous conversions. +// See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216201 +assert(test_constructor_explicit("abc")); + } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r292294 - Fix type_info's constructor by making it explicit again.
Merged into the 4.0 branch in r292309. On Tue, Jan 17, 2017 at 4:55 PM, Eric Fiselier wrote: > FYI Once the bots finish checking this commit I'm going to merge this into > the 4.0 branch. > > This fixes a very recently introduced regression. > > /Eric > > On Tue, Jan 17, 2017 at 4:41 PM, Eric Fiselier via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: ericwf >> Date: Tue Jan 17 17:41:42 2017 >> New Revision: 292294 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=292294&view=rev >> Log: >> Fix type_info's constructor by making it explicit again. >> >> In recent changes type_info's private constructor was >> accidentally made implicit. This patch fixes that. >> >> Modified: >> libcxx/trunk/include/typeinfo >> libcxx/trunk/test/std/language.support/support.rtti/type. >> info/type_info.pass.cpp >> >> Modified: libcxx/trunk/include/typeinfo >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typ >> einfo?rev=292294&r1=292293&r2=292294&view=diff >> >> == >> --- libcxx/trunk/include/typeinfo (original) >> +++ libcxx/trunk/include/typeinfo Tue Jan 17 17:41:42 2017 >> @@ -95,12 +95,13 @@ protected: >> uintptr_t __type_name; >> >> _LIBCPP_INLINE_VISIBILITY >> -type_info(const char* __n) : >> __type_name(reinterpret_cast(__n)) >> {} >> +explicit type_info(const char* __n) >> + : __type_name(reinterpret_cast(__n)) {} >> #else >> const char *__type_name; >> >> _LIBCPP_INLINE_VISIBILITY >> -type_info(const char* __n) : __type_name(__n) {} >> +explicit type_info(const char* __n) : __type_name(__n) {} >> #endif >> >> public: >> >> Modified: libcxx/trunk/test/std/language.support/support.rtti/type. >> info/type_info.pass.cpp >> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/la >> nguage.support/support.rtti/type.info/type_info.pass.cpp?rev >> =292294&r1=292293&r2=292294&view=diff >> >> == >> --- libcxx/trunk/test/std/language.support/support.rtti/type. >> info/type_info.pass.cpp (original) >> +++ libcxx/trunk/test/std/language.support/support.rtti/type. >> info/type_info.pass.cpp Tue Jan 17 17:41:42 2017 >> @@ -10,11 +10,16 @@ >> // test type_info >> >> #include >> +#include >> #include >> #include >> >> +bool test_constructor_explicit(std::type_info const&) { return false; } >> +bool test_constructor_explicit(std::string const&) { return true; } >> + >> int main() >> { >> + { >> const std::type_info& t1 = typeid(int); >> const std::type_info& t2 = typeid(int); >> assert(t1 == t2); >> @@ -23,4 +28,13 @@ int main() >> assert(!t1.before(t2)); >> assert(strcmp(t1.name(), t2.name()) == 0); >> assert(strcmp(t1.name(), t3.name()) != 0); >> + } >> + { >> +// type_info has a protected constructor taking a string literal. >> This >> +// constructor is not intended for users. However it still >> participates >> +// in overload resolution, so we need to ensure that it is marked >> explicit >> +// to avoid ambiguous conversions. >> +// See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216201 >> +assert(test_constructor_explicit("abc")); >> + } >> } >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r292013 - Fix last_write_time tests for filesystems that don't support negative and very large times
@Jonas please go ahead and merge this patch. On Tue, Jan 17, 2017 at 5:24 PM, Hans Wennborg wrote: > Yes, go ahead. > > Apologies for the delay. > > - Hans > > On Sat, Jan 14, 2017 at 5:54 AM, Eric Fiselier wrote: > > +1 from me. @Hans am I OK to merge this? > > > > On Sat, Jan 14, 2017 at 4:53 AM, Hahnfeld, Jonas > > wrote: > >> > >> Hi Hans, > >> > >> can this be merged for 4.0? Eric suggested this in > >> https://reviews.llvm.org/D22452 so I think he should be fine. > >> > >> Thanks, > >> Jonas > >> > >> Am Samstag, den 14.01.2017, 11:35 + schrieb Jonas Hahnfeld via > >> cfe-commits: > >> > >> Author: hahnfeld > >> Date: Sat Jan 14 05:35:15 2017 > >> New Revision: 292013 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=292013&view=rev > >> Log: > >> Fix last_write_time tests for filesystems that don't support negative > and > >> very large times > >> > >> Seems to be the case for NFS. > >> > >> Original patch by Eric Fiselier! > >> Differential Revision: https://reviews.llvm.org/D22452 > >> > >> Modified: > >> > >> libcxx/trunk/test/std/experimental/filesystem/fs.op. > funcs/fs.op.last_write_time/last_write_time.pass.cpp > >> > >> Modified: > >> libcxx/trunk/test/std/experimental/filesystem/fs.op. > funcs/fs.op.last_write_time/last_write_time.pass.cpp > >> URL: > >> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/ > experimental/filesystem/fs.op.funcs/fs.op.last_write_time/ > last_write_time.pass.cpp?rev=292013&r1=292012&r2=292013&view=diff > >> > >> > == > >> --- > >> libcxx/trunk/test/std/experimental/filesystem/fs.op. > funcs/fs.op.last_write_time/last_write_time.pass.cpp > >> (original) > >> +++ > >> libcxx/trunk/test/std/experimental/filesystem/fs.op. > funcs/fs.op.last_write_time/last_write_time.pass.cpp > >> Sat Jan 14 05:35:15 2017 > >> @@ -72,13 +72,60 @@ std::pair GetS > >> return {st.st_atime, st.st_mtime}; > >> } > >> > >> -inline bool TimeIsRepresentableAsTimeT(file_time_type tp) { > >> +namespace { > >> +bool TestSupportsNegativeTimes() { > >> +using namespace std::chrono; > >> +std::error_code ec; > >> +std::time_t old_write_time, new_write_time; > >> +{ // WARNING: Do not assert in this scope. > >> +scoped_test_env env; > >> +const path file = env.create_file("file", 42); > >> +old_write_time = LastWriteTime(file); > >> +file_time_type tp(seconds(-5)); > >> +fs::last_write_time(file, tp, ec); > >> +new_write_time = LastWriteTime(file); > >> +} > >> +return !ec && new_write_time <= -5; > >> +} > >> + > >> +bool TestSupportsMaxTime() { > >> using namespace std::chrono; > >> using Lim = std::numeric_limits; > >> -auto sec = duration_cast(tp.time_since_epoch()).count(); > >> -return (sec >= Lim::min() && sec <= Lim::max()); > >> +auto max_sec = > >> duration_cast(file_time_type::max().time_since_ > epoch()).count(); > >> +if (max_sec > Lim::max()) return false; > >> +std::error_code ec; > >> +std::time_t old_write_time, new_write_time; > >> +{ // WARNING: Do not assert in this scope. > >> +scoped_test_env env; > >> +const path file = env.create_file("file", 42); > >> +old_write_time = LastWriteTime(file); > >> +file_time_type tp = file_time_type::max(); > >> +fs::last_write_time(file, tp, ec); > >> +new_write_time = LastWriteTime(file); > >> +} > >> +return !ec && new_write_time > max_sec - 1; > >> } > >> > >> +static const bool SupportsNegativeTimes = TestSupportsNegativeTimes(); > >> +static const bool SupportsMaxTime = TestSupportsMaxTime(); > >> + > >> +} // end namespace > >> + > >> +// Check if a time point is representable on a given filesystem. Check > >> that: > >> +// (A) 'tp' is representable as a time_t > >> +// (B) 'tp' is non-negative or the filesystem supports negative times. > >> +// (C) 'tp' is not 'file_time_type::max()' or the filesystem supports > the > >> max > >> +// value. > >> +inline bool TimeIsRepresentableByFilesystem(file_time_type tp) { > >> +using namespace std::chrono; > >> +using Lim = std::numeric_limits; > >> +auto sec = duration_cast(tp.time_since_epoch()).count(); > >> +auto microsec = > >> duration_cast(tp.time_since_epoch()).count(); > >> +if (sec < Lim::min() || sec > Lim::max()) return false; > >> +else if (microsec < 0 && !SupportsNegativeTimes) return false; > >> +else if (tp == file_time_type::max() && !SupportsMaxTime) return > >> false; > >> +return true; > >> +} > >> > >> TEST_SUITE(exists_test_suite) > >> > >> @@ -214,15 +261,17 @@ TEST_CASE(set_last_write_time_dynamic_en > >> > >> file_time_type got_time = last_write_time(TC.p); > >> > >> -TEST_CHECK(got_time != old_time); > >> -if (TC.new_time < epoch_time) { > >> -TEST_CHECK(got_time <= TC.new_time); > >> -TEST_CHECK(got_time > TC.new
Re: r292032 - Fix PR31644 introduced by r287138 and add a regression test.
On Sat, Jan 14, 2017 at 1:26 PM, Dimitry Andric wrote: > On 14 Jan 2017, at 22:12, Yaron Keren via cfe-commits > wrote: >> Author: yrnkrn >> Date: Sat Jan 14 15:12:08 2017 >> New Revision: 292032 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=292032&view=rev >> Log: >> Fix PR31644 introduced by r287138 and add a regression test. >> Thanks Dimitry Andric for the report and fix! > > Please merge this to the release_40 branch too. :) Merged in r292311. Thanks, Hans ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r292052 - [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function.
Merged in r292313. Thanks, Hans On Tue, Jan 17, 2017 at 8:56 AM, Argyrios Kyrtzidis wrote: > Hi Hans, > > Could this go into the stable branch ? > > On Sat, Jan 14, 2017 at 10:11 PM, Argyrios Kyrtzidis via cfe-commits > wrote: >> >> Author: akirtzidis >> Date: Sun Jan 15 00:11:04 2017 >> New Revision: 292052 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=292052&view=rev >> Log: >> [code-completion] Fix crash when trying to do postfix completion of >> instance member inside a static function. >> >> Modified: >> cfe/trunk/lib/Parse/ParseExpr.cpp >> cfe/trunk/test/CodeCompletion/member-access.cpp >> >> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=292052&r1=292051&r2=292052&view=diff >> >> == >> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) >> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Jan 15 00:11:04 2017 >> @@ -1652,9 +1652,10 @@ Parser::ParsePostfixExpressionSuffix(Exp >> >>if (Tok.is(tok::code_completion)) { >> // Code completion for a member access expression. >> -Actions.CodeCompleteMemberReferenceExpr( >> -getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow, >> -ExprStatementTokLoc == LHS.get()->getLocStart()); >> +if (Expr *Base = LHS.get()) >> + Actions.CodeCompleteMemberReferenceExpr( >> + getCurScope(), Base, OpLoc, OpKind == tok::arrow, >> + ExprStatementTokLoc == Base->getLocStart()); >> >> cutOffParsing(); >> return ExprError(); >> >> Modified: cfe/trunk/test/CodeCompletion/member-access.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=292052&r1=292051&r2=292052&view=diff >> >> == >> --- cfe/trunk/test/CodeCompletion/member-access.cpp (original) >> +++ cfe/trunk/test/CodeCompletion/member-access.cpp Sun Jan 15 00:11:04 >> 2017 >> @@ -27,6 +27,16 @@ public: >> >> void test(const Proxy &p) { >>p-> >> +} >> + >> +struct Test1 { >> + Base1 b; >> + >> + static void sfunc() { >> +b. // expected-error {{invalid use of member 'b' in static member >> function}} >> + } >> +}; >> + >>// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | >> FileCheck -check-prefix=CHECK-CC1 %s >>// CHECK-CC1: Base1 : Base1:: >>// CHECK-CC1: member1 : [#int#][#Base1::#]member1 >> @@ -39,4 +49,6 @@ void test(const Proxy &p) { >>// CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) >>// CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) >>// CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>) >> - >> + >> +// Make sure this doesn't crash >> +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:7 %s -verify >> >> >> ___ >> 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] D28835: [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.
GorNishanov created this revision. Herald added a subscriber: mehdi_amini. Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters. Instead, CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters. CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement. Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h. And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation). https://reviews.llvm.org/D28835 Files: include/clang/AST/StmtCXX.h include/clang/Sema/ScopeInfo.h lib/AST/StmtCXX.cpp lib/Sema/SemaCoroutine.cpp test/SemaCXX/coroutines.cpp Index: test/SemaCXX/coroutines.cpp === --- test/SemaCXX/coroutines.cpp +++ test/SemaCXX/coroutines.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s +// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions void no_coroutine_traits_bad_arg_await() { co_await a; // expected-error {{include }} Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -487,7 +487,7 @@ static bool buildAllocationAndDeallocation(Sema &S, SourceLocation Loc, FunctionScopeInfo *Fn, Expr *&Allocation, - Stmt *&Deallocation) { + Expr *&Deallocation) { TypeSourceInfo *TInfo = Fn->CoroutinePromise->getTypeSourceInfo(); QualType PromiseType = TInfo->getType(); if (PromiseType->isDependentType()) @@ -564,6 +564,48 @@ return true; } +namespace { +class SubStmtBuilder : public CoroutineBodyStmt::CtorArgs { + Sema &S; + FunctionDecl &FD; + FunctionScopeInfo &Fn; + bool IsValid; + SourceLocation Loc; + QualType RetType; + SmallVector ParamMovesVector; + const bool IsPromiseDependentType; + CXXRecordDecl *PromiseRecordDecl; + +public: + SubStmtBuilder(Sema &S, FunctionDecl &FD, FunctionScopeInfo &Fn, Stmt *Body) + : S(S), FD(FD), Fn(Fn), Loc(FD.getLocation()), +IsPromiseDependentType( +!Fn.CoroutinePromise || +Fn.CoroutinePromise->getType()->isDependentType()) { +this->Body = Body; +if (!IsPromiseDependentType) { + PromiseRecordDecl = Fn.CoroutinePromise->getType()->getAsCXXRecordDecl(); + assert(PromiseRecordDecl && "Type should have already been checked"); +} +this->IsValid = makePromiseStmt() && makeInitialSuspend() && +makeFinalSuspend() && makeOnException() && +makeOnFallthrough() && makeNewAndDeleteExpr() && +makeReturnObject() && makeParamMoves(); + } + + bool isInvalid() const { return !this->IsValid; } + + bool makePromiseStmt(); + bool makeInitialSuspend(); + bool makeFinalSuspend(); + bool makeNewAndDeleteExpr(); + bool makeOnFallthrough(); + bool makeOnException(); + bool makeReturnObject(); + bool makeParamMoves(); +}; +} + void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) { FunctionScopeInfo *Fn = getCurFunction(); assert(Fn && !Fn->CoroutineStmts.empty() && "not a coroutine"); @@ -577,120 +619,159 @@ << (isa(First) ? 0 : isa(First) ? 1 : 2); } + SubStmtBuilder Builder(*this, *FD, *Fn, Body); + if (Builder.isInvalid()) +return FD->setInvalidDecl(); - SourceLocation Loc = FD->getLocation(); + // Build body for the coroutine wrapper statement. + Body = CoroutineBodyStmt::Create(Context, Builder); +} +bool SubStmtBuilder::makePromiseStmt() { // Form a declaration statement for the promise declaration, so that AST // visitors can more easily find it. StmtResult PromiseStmt = - ActOnDeclStmt(ConvertDeclToDeclGroup(Fn->CoroutinePromise), Loc, Loc); + S.ActOnDeclStmt(S.ConvertDeclToDeclGroup(Fn.CoroutinePromise), Loc, Loc); if (PromiseStmt.isInvalid()) -return FD->setInvalidDecl(); +return false; + + this->Promise = PromiseStmt.get(); + return true; +} +bool SubStmtBuilder::makeInitialSuspend() { // Form and check implicit 'co_await p.initial_suspend();' statement. ExprResult InitialSuspend = - buildPromiseCall(*this, Fn, Loc, "initial_suspend", None); + buildPromiseCall(S, &Fn, Loc, "initial_suspend", None); // FIXME: Support operator co_await here. if (!InitialSuspend.isInvalid()) -InitialSuspend = BuildCoawaitExpr(Loc, InitialSuspend.get()); - InitialSuspend = ActOnFinishFullExpr(InitialSuspend.get()); +Initia
[PATCH] D28790: [Modules] Correct test comment from obsolete earlier version of code. NFC
manmanren accepted this revision. manmanren added a comment. This revision is now accepted and ready to land. LGTM Manman https://reviews.llvm.org/D28790 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28779: [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES
manmanren accepted this revision. manmanren added a comment. This revision is now accepted and ready to land. LGTM Manman https://reviews.llvm.org/D28779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r292052 - [code-completion] Fix crash when trying to do postfix completion of instance member inside a static function.
Thank you! > On Jan 17, 2017, at 4:35 PM, Hans Wennborg wrote: > > Merged in r292313. > > Thanks, > Hans > > On Tue, Jan 17, 2017 at 8:56 AM, Argyrios Kyrtzidis wrote: >> Hi Hans, >> >> Could this go into the stable branch ? >> >> On Sat, Jan 14, 2017 at 10:11 PM, Argyrios Kyrtzidis via cfe-commits >> wrote: >>> >>> Author: akirtzidis >>> Date: Sun Jan 15 00:11:04 2017 >>> New Revision: 292052 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=292052&view=rev >>> Log: >>> [code-completion] Fix crash when trying to do postfix completion of >>> instance member inside a static function. >>> >>> Modified: >>>cfe/trunk/lib/Parse/ParseExpr.cpp >>>cfe/trunk/test/CodeCompletion/member-access.cpp >>> >>> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=292052&r1=292051&r2=292052&view=diff >>> >>> == >>> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) >>> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Jan 15 00:11:04 2017 >>> @@ -1652,9 +1652,10 @@ Parser::ParsePostfixExpressionSuffix(Exp >>> >>> if (Tok.is(tok::code_completion)) { >>> // Code completion for a member access expression. >>> -Actions.CodeCompleteMemberReferenceExpr( >>> -getCurScope(), LHS.get(), OpLoc, OpKind == tok::arrow, >>> -ExprStatementTokLoc == LHS.get()->getLocStart()); >>> +if (Expr *Base = LHS.get()) >>> + Actions.CodeCompleteMemberReferenceExpr( >>> + getCurScope(), Base, OpLoc, OpKind == tok::arrow, >>> + ExprStatementTokLoc == Base->getLocStart()); >>> >>> cutOffParsing(); >>> return ExprError(); >>> >>> Modified: cfe/trunk/test/CodeCompletion/member-access.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=292052&r1=292051&r2=292052&view=diff >>> >>> == >>> --- cfe/trunk/test/CodeCompletion/member-access.cpp (original) >>> +++ cfe/trunk/test/CodeCompletion/member-access.cpp Sun Jan 15 00:11:04 >>> 2017 >>> @@ -27,6 +27,16 @@ public: >>> >>> void test(const Proxy &p) { >>> p-> >>> +} >>> + >>> +struct Test1 { >>> + Base1 b; >>> + >>> + static void sfunc() { >>> +b. // expected-error {{invalid use of member 'b' in static member >>> function}} >>> + } >>> +}; >>> + >>> // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | >>> FileCheck -check-prefix=CHECK-CC1 %s >>> // CHECK-CC1: Base1 : Base1:: >>> // CHECK-CC1: member1 : [#int#][#Base1::#]member1 >>> @@ -39,4 +49,6 @@ void test(const Proxy &p) { >>> // CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>) >>> // CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>) >>> // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>) >>> - >>> + >>> +// Make sure this doesn't crash >>> +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:36:7 %s -verify >>> >>> >>> ___ >>> 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
r292324 - [WebAssembly] Update grow_memory's return type.
Author: djg Date: Tue Jan 17 19:03:35 2017 New Revision: 292324 URL: http://llvm.org/viewvc/llvm-project?rev=292324&view=rev Log: [WebAssembly] Update grow_memory's return type. The grow_memory instruction now returns the previous memory size. Add the return type to the clang intrinsic. Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def cfe/trunk/test/CodeGen/builtins-wasm.c Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=292324&r1=292323&r2=292324&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Tue Jan 17 19:03:35 2017 @@ -16,9 +16,9 @@ // The format of this database matches clang/Basic/Builtins.def. -// Note that current_memory is not "c" (readnone) because it must be sequenced with -// respect to grow_memory calls. +// Note that current_memory is not "c" (readnone) because it must be sequenced +// with respect to grow_memory calls. BUILTIN(__builtin_wasm_current_memory, "z", "n") -BUILTIN(__builtin_wasm_grow_memory, "vz", "n") +BUILTIN(__builtin_wasm_grow_memory, "zz", "n") #undef BUILTIN Modified: cfe/trunk/test/CodeGen/builtins-wasm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=292324&r1=292323&r2=292324&view=diff == --- cfe/trunk/test/CodeGen/builtins-wasm.c (original) +++ cfe/trunk/test/CodeGen/builtins-wasm.c Tue Jan 17 19:03:35 2017 @@ -9,8 +9,8 @@ __SIZE_TYPE__ f1(void) { // WEBASSEMBLY64: call {{i.*}} @llvm.wasm.current.memory.i64() } -void f2(long delta) { - __builtin_wasm_grow_memory(delta); -// WEBASSEMBLY32: call void @llvm.wasm.grow.memory.i32(i32 %{{.*}}) -// WEBASSEMBLY64: call void @llvm.wasm.grow.memory.i64(i64 %{{.*}}) +__SIZE_TYPE__ f2(__SIZE_TYPE__ delta) { + return __builtin_wasm_grow_memory(delta); +// WEBASSEMBLY32: call i32 @llvm.wasm.grow.memory.i32(i32 %{{.*}}) +// WEBASSEMBLY64: call i64 @llvm.wasm.grow.memory.i64(i64 %{{.*}}) } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28837: [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.
STL_MSFT created this revision. [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants. MSVC has compiler warnings C4127 "conditional expression is constant" (enabled by /https://reviews.llvm.org/W4) and C6326 "Potential comparison of a constant with another constant" (enabled by /analyze). They're potentially useful, although they're slightly annoying to library devs who know what they're doing. In the latest version of the compiler, C4127 is suppressed when the compiler sees simple tests like "if (name_of_thing)", so extracting comparison expressions into named constants is a workaround. At the same time, using std::integral_constant avoids C6326, which doesn't look at template arguments. test/std/containers/sequences/vector.bool/emplace.pass.cpp Replace 1 == 1 with true, which is the same as far as the library is concerned. https://reviews.llvm.org/D28837 Files: test/std/containers/sequences/vector.bool/emplace.pass.cpp test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp test/std/utilities/function.objects/unord.hash/enum.pass.cpp test/std/utilities/function.objects/unord.hash/integral.pass.cpp test/std/utilities/template.bitset/bitset.members/all.pass.cpp test/std/utilities/template.bitset/bitset.members/any.pass.cpp test/std/utilities/template.bitset/bitset.members/index.pass.cpp test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp test/std/utilities/template.bitset/bitset.members/none.pass.cpp test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp Index: test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp === --- test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp +++ test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp @@ -11,16 +11,18 @@ #include #include +#include #include #include #include template void test_to_ulong() { const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N; -const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; -const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits::max()) >> X; +const bool is_M_zero = std::integral_constant::value; // avoid compiler warnings +const std::size_t X = is_M_zero ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M; +const std::size_t max = is_M_zero ? 0 : std::size_t(std::numeric_limits::max()) >> X; std::size_t tests[] = {0, std::min(1, max), std::min(2, max), Index: test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp === --- test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp +++ test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp @@ -11,15 +11,17 @@ #include #include +#include #include #include template void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; -const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; -const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X; +const bool is_M_zero = std::integral_constant::value; // avoid compiler warnings +const std::size_t X = is_M_zero ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; +const unsigned long long max = is_M_zero ? 0 : (unsigned long long)(-1) >> X; unsigned long long tests[] = {0, std::min(1, max), std::min(2, max), Index: test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp === --- test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp +++ test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp @@ -13,6 +13,7 @@ // bool operator!=(const bitset& rhs) const; #include +#include #include #include @@ -36,7 +37,8 @@ const std::bitset v1 = make_bitset(); std::bitset v2 = v1; assert(v1 == v2); -if (N > 0) +const bool greater_than_0 = std::integral_constant 0)>::value; // avoid compiler warnings +if (greater_than_0) { v2[N/2].flip(); assert(v1 != v2); Index: test/std/utilities/template.bitset/bitset.members/none.pass.cpp === --- test/std/utilities/template.bitset/bitset.members/none.pass.cpp +++ test/std/utilities/template.bitset/bitset.member
[libcxx] r292326 - Add support for running our test suite against MSVC's STL
Author: ericwf Date: Tue Jan 17 19:48:54 2017 New Revision: 292326 URL: http://llvm.org/viewvc/llvm-project?rev=292326&view=rev Log: Add support for running our test suite against MSVC's STL Modified: libcxx/trunk/test/libcxx/test/config.py libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp libcxx/trunk/test/support/MoveOnly.h Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292326&r1=292325&r2=292326&view=diff == --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Tue Jan 17 19:48:54 2017 @@ -274,7 +274,7 @@ class Configuration(object): self.cxx_stdlib_under_test = self.get_lit_conf( 'cxx_stdlib_under_test', 'libc++') if self.cxx_stdlib_under_test not in \ -['libc++', 'libstdc++', 'cxx_default']: +['libc++', 'libstdc++', 'msvc', 'cxx_default']: self.lit_config.fatal( 'unsupported value for "cxx_stdlib_under_test": %s' % self.cxx_stdlib_under_test) @@ -609,6 +609,9 @@ class Configuration(object): self.config.available_features.add('c++experimental') self.cxx.link_flags += ['-lstdc++fs'] self.cxx.link_flags += ['-lm', '-pthread'] +elif self.cxx_stdlib_under_test == 'msvc': +# FIXME: Correctly setup debug/release flags here. +pass elif self.cxx_stdlib_under_test == 'cxx_default': self.cxx.link_flags += ['-pthread'] else: Modified: libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp?rev=292326&r1=292325&r2=292326&view=diff == --- libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp (original) +++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp Tue Jan 17 19:48:54 2017 @@ -9,10 +9,10 @@ // // UNSUPPORTED: libcpp-has-no-threads -// This test hangs forever when built against libstdc++. In order to allow +// This test hangs forever when built against libstdc++ and MSVC. In order to allow // validation of the test suite against other STLs we have to mark it // unsupported. -// UNSUPPORTED: libstdc++ +// UNSUPPORTED: libstdc++, msvc // Modified: libcxx/trunk/test/support/MoveOnly.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/MoveOnly.h?rev=292326&r1=292325&r2=292326&view=diff == --- libcxx/trunk/test/support/MoveOnly.h (original) +++ libcxx/trunk/test/support/MoveOnly.h Tue Jan 17 19:48:54 2017 @@ -41,8 +41,9 @@ namespace std { template <> struct hash -: public std::unary_function { +typedef MoveOnly argument_type; +typedef size_t result_type; std::size_t operator()(const MoveOnly& x) const {return x.get();} }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28837: [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. The changes sure look funny but I have no issue with them. https://reviews.llvm.org/D28837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292329 - [AVX-512] Replace subvector broadcast builtins with shufflevectors and selects.
Author: ctopper Date: Tue Jan 17 20:17:10 2017 New Revision: 292329 URL: http://llvm.org/viewvc/llvm-project?rev=292329&view=rev Log: [AVX-512] Replace subvector broadcast builtins with shufflevectors and selects. Verified that the backend codegens this equally well. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/Headers/avx512dqintrin.h cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/lib/Headers/avx512vldqintrin.h cfe/trunk/lib/Headers/avx512vlintrin.h cfe/trunk/test/CodeGen/avx512dq-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vldq-builtins.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=292329&r1=292328&r2=292329&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Jan 17 20:17:10 2017 @@ -1590,27 +1590,15 @@ TARGET_BUILTIN(__builtin_ia32_cvtq2mask1 TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastmb512, "V8LLiUc","","avx512cd") TARGET_BUILTIN(__builtin_ia32_broadcastmw512, "V16iUs","","avx512cd") -TARGET_BUILTIN(__builtin_ia32_broadcastf32x4_512, "V16fV4fV16fUs","","avx512f") -TARGET_BUILTIN(__builtin_ia32_broadcastf64x4_512, "V8dV4dV8dUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_broadcasti32x4_512, "V16iV4iV16iUs","","avx512f") -TARGET_BUILTIN(__builtin_ia32_broadcasti64x4_512, "V8LLiV4LLiV8LLiUc","","avx512f") TARGET_BUILTIN(__builtin_ia32_broadcastmb128, "V2LLiUc","","avx512cd,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastmb256, "V4LLiUc","","avx512cd,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastmw128, "V4iUs","","avx512cd,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastmw256, "V8iUs","","avx512cd,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcastf32x2_512_mask, "V16fV4fV16fUs","","avx512dq") -TARGET_BUILTIN(__builtin_ia32_broadcastf32x8_512_mask, "V16fV8fV16fUs","","avx512dq") -TARGET_BUILTIN(__builtin_ia32_broadcastf64x2_512_mask, "V8dV2dV8dUc","","avx512dq") TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_512_mask, "V16iV4iV16iUs","","avx512dq") -TARGET_BUILTIN(__builtin_ia32_broadcasti32x8_512_mask, "V16iV8iV16iUs","","avx512dq") -TARGET_BUILTIN(__builtin_ia32_broadcasti64x2_512_mask, "V8LLiV2LLiV8LLiUc","","avx512dq") TARGET_BUILTIN(__builtin_ia32_broadcastf32x2_256_mask, "V8fV4fV8fUc","","avx512dq,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastf64x2_256_mask, "V4dV2dV4dUc","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_128_mask, "V4iV4iV4iUc","","avx512dq,avx512vl") TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_256_mask, "V8iV4iV8iUc","","avx512dq,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcasti64x2_256_mask, "V4LLiV2LLiV4LLiUc","","avx512dq,avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcastf32x4_256_mask, "V8fV4fV8fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_broadcasti32x4_256_mask, "V8iV4iV8iUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_pbroadcastw512_gpr_mask, "V32shV32sUi","","avx512bw") TARGET_BUILTIN(__builtin_ia32_pbroadcastw256_gpr_mask, "V16shV16sUs","","avx512bw,avx512vl") TARGET_BUILTIN(__builtin_ia32_pbroadcastw128_gpr_mask, "V8ssV8sUc","","avx512bw,avx512vl") Modified: cfe/trunk/lib/Headers/avx512dqintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=292329&r1=292328&r2=292329&view=diff == --- cfe/trunk/lib/Headers/avx512dqintrin.h (original) +++ cfe/trunk/lib/Headers/avx512dqintrin.h Tue Jan 17 20:17:10 2017 @@ -995,51 +995,50 @@ _mm512_maskz_broadcast_f32x2 (__mmask16 } static __inline__ __m512 __DEFAULT_FN_ATTRS -_mm512_broadcast_f32x8 (__m256 __A) +_mm512_broadcast_f32x8(__m256 __A) { - return (__m512) __builtin_ia32_broadcastf32x8_512_mask ((__v8sf) __A, -_mm512_undefined_ps(), -(__mmask16) -1); + return (__m512)__builtin_shufflevector((__v8sf)__A, (__v8sf)__A, + 0, 1, 2, 3, 4, 5, 6, 7, + 0, 1, 2, 3, 4, 5, 6, 7); } static __inline__ __m512 __DEFAULT_FN_ATTRS -_mm512_mask_broadcast_f32x8 (__m512 __O, __mmask16 __M, __m256 __A) +_mm512_mask_broadcast_f32x8(__m512 __O, __mmask16 __M, __m256 __A) { - return (__m512) __builtin_ia32_broadcastf32x8_512_mask ((__v8sf) __A, -(__v16sf)__O, -__M); + return (__m512)__builtin_ia32_selectps_512((__mmask8)__M, + (__v16sf)_mm512_broadcast_f32x8(__A), + (__v16sf)__O); } static __inline__ __m512 __DEFAULT_FN_ATTRS -_mm512_maskz_broadcast_f32x8 (__mm
[PATCH] D28843: IRGen: Start using the WriteThinLTOBitcode pass.
pcc created this revision. This is the final change necessary to support CFI with ThinLTO. TODO: avoid breaking Darwin. Depends on https://reviews.llvm.org/D28840 https://reviews.llvm.org/D28843 Files: clang/lib/CodeGen/BackendUtil.cpp clang/test/CodeGenCXX/type-metadata-thinlto.cpp Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp === --- /dev/null +++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s +// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s + +// CHECK: @_ZTV1A = linkonce_odr +class A { + virtual void f() {} +}; + +A *f() { + return new A; +} Index: clang/lib/CodeGen/BackendUtil.cpp === --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -688,9 +688,11 @@ break; case Backend_EmitBC: -PerModulePasses.add(createBitcodeWriterPass( -*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex, -CodeGenOpts.EmitSummaryIndex)); +if (CodeGenOpts.EmitSummaryIndex) + PerModulePasses.add(createWriteThinLTOBitcodePass(*OS)); +else + PerModulePasses.add( + createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists)); break; case Backend_EmitLL: Index: clang/test/CodeGenCXX/type-metadata-thinlto.cpp === --- /dev/null +++ clang/test/CodeGenCXX/type-metadata-thinlto.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -flto=thin -triple x86_64-unknown-linux -fvisibility hidden -emit-llvm-bc -o %t %s +// RUN: llvm-modextract -o - -n 1 %t | llvm-dis | FileCheck %s + +// CHECK: @_ZTV1A = linkonce_odr +class A { + virtual void f() {} +}; + +A *f() { + return new A; +} Index: clang/lib/CodeGen/BackendUtil.cpp === --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -688,9 +688,11 @@ break; case Backend_EmitBC: -PerModulePasses.add(createBitcodeWriterPass( -*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex, -CodeGenOpts.EmitSummaryIndex)); +if (CodeGenOpts.EmitSummaryIndex) + PerModulePasses.add(createWriteThinLTOBitcodePass(*OS)); +else + PerModulePasses.add( + createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists)); break; case Backend_EmitLL: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r292334 - math: Add expm1 builtin function
Author: awatry Date: Tue Jan 17 21:13:37 2017 New Revision: 292334 URL: http://llvm.org/viewvc/llvm-project?rev=292334&view=rev Log: math: Add expm1 builtin function Ported from the amd-builtins branch. Signed-off-by: Aaron Watry Reviewed-by: Matt Arsenault CC: Tom Stellard Added: libclc/trunk/generic/include/clc/math/expm1.h libclc/trunk/generic/lib/math/expm1.cl Modified: libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/lib/SOURCES libclc/trunk/generic/lib/math/tables.cl libclc/trunk/generic/lib/math/tables.h Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=292334&r1=292333&r2=292334&view=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Tue Jan 17 21:13:37 2017 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include Added: libclc/trunk/generic/include/clc/math/expm1.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/expm1.h?rev=292334&view=auto == --- libclc/trunk/generic/include/clc/math/expm1.h (added) +++ libclc/trunk/generic/include/clc/math/expm1.h Tue Jan 17 21:13:37 2017 @@ -0,0 +1,9 @@ +#undef exp + +#define __CLC_BODY +#define __CLC_FUNCTION expm1 + +#include + +#undef __CLC_BODY +#undef __CLC_FUNCTION Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=292334&r1=292333&r2=292334&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Tue Jan 17 21:13:37 2017 @@ -83,6 +83,7 @@ math/erf.cl math/erfc.cl math/exp.cl math/exp_helper.cl +math/expm1.cl math/exp2.cl math/exp10.cl math/fdim.cl Added: libclc/trunk/generic/lib/math/expm1.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/expm1.cl?rev=292334&view=auto == --- libclc/trunk/generic/lib/math/expm1.cl (added) +++ libclc/trunk/generic/lib/math/expm1.cl Tue Jan 17 21:13:37 2017 @@ -0,0 +1,142 @@ +#include + +#include "math.h" +#include "tables.h" +#include "../clcmacro.h" + +/* Refer to the exp routine for the underlying algorithm */ + +_CLC_OVERLOAD _CLC_DEF float expm1(float x) { +const float X_MAX = 0x1.62e42ep+6f; // 128*log2 : 88.722839111673 +const float X_MIN = -0x1.9d1da0p+6f; // -149*log2 : -103.27892990343184 + +const float R_64_BY_LOG2 = 0x1.715476p+6f; // 64/log2 : 92.332482616893657 +const float R_LOG2_BY_64_LD = 0x1.62p-7f; // log2/64 lead: 0.0108032227 +const float R_LOG2_BY_64_TL = 0x1.c85fdep-16f; // log2/64 tail: 0.272020388 + +uint xi = as_uint(x); +int n = (int)(x * R_64_BY_LOG2); +float fn = (float)n; + +int j = n & 0x3f; +int m = n >> 6; + +float r = mad(fn, -R_LOG2_BY_64_TL, mad(fn, -R_LOG2_BY_64_LD, x)); + +// Truncated Taylor series +float z2 = mad(r*r, mad(r, mad(r, 0x1.56p-5f, 0x1.56p-3f), 0.5f), r); + +float m2 = as_float((m + EXPBIAS_SP32) << EXPSHIFTBITS_SP32); +float2 tv = USE_TABLE(exp_tbl_ep, j); + +float two_to_jby64_h = tv.s0 * m2; +float two_to_jby64_t = tv.s1 * m2; +float two_to_jby64 = two_to_jby64_h + two_to_jby64_t; + +z2 = mad(z2, two_to_jby64, two_to_jby64_t) + (two_to_jby64_h - 1.0f); + //Make subnormals work +z2 = x == 0.f ? x : z2; +z2 = x < X_MIN | m < -24 ? -1.0f : z2; +z2 = x > X_MAX ? as_float(PINFBITPATT_SP32) : z2; +z2 = isnan(x) ? x : z2; + +return z2; +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, expm1, float) + +#ifdef cl_khr_fp64 + +#include "exp_helper.h" + +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double expm1(double x) { +const double max_expm1_arg = 709.8; +const double min_expm1_arg = -37.42994775023704; +const double log_OnePlus_OneByFour = 0.22314355131420976; //0x3FCC8FF7C79A9A22 = log(1+1/4) +const double log_OneMinus_OneByFour = -0.28768207245178096; //0xBFD269621134DB93 = log(1-1/4) +const double sixtyfour_by_lnof2 = 92.33248261689366; //0x40571547652b82fe +const double lnof2_by_64_head = 0.010830424696223417; //0x3f862e42fefa +const double lnof2_by_64_tail = 2.5728046223276688e-14; //0x3d1cf79abc9e3b39 + +// First, assume log(1-1/4) < x < log(1+1/4) i.e -0.28768 < x < 0.22314 +double u = as_double(as_ulong(x) & 0xff00UL); +double v = x - u; +double y = u * u * 0.5; +double z = v * (x + u) * 0.5; + +double q = fma(x, + fma(x, + fma(x, + fma(x, +
[libclc] r292335 - math: Add logb builtin
Author: awatry Date: Tue Jan 17 21:14:10 2017 New Revision: 292335 URL: http://llvm.org/viewvc/llvm-project?rev=292335&view=rev Log: math: Add logb builtin Ported from the amd-builtins branch. Signed-off-by: Aaron Watry Reviewed-by: Matt Arsenault CC: Tom Stellard Added: libclc/trunk/generic/include/clc/math/logb.h libclc/trunk/generic/include/clc/math/logb.inc libclc/trunk/generic/lib/math/logb.cl Modified: libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/lib/SOURCES Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=292335&r1=292334&r2=292335&view=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Tue Jan 17 21:14:10 2017 @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include Added: libclc/trunk/generic/include/clc/math/logb.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/logb.h?rev=292335&view=auto == --- libclc/trunk/generic/include/clc/math/logb.h (added) +++ libclc/trunk/generic/include/clc/math/logb.h Tue Jan 17 21:14:10 2017 @@ -0,0 +1,2 @@ +#define __CLC_BODY +#include Added: libclc/trunk/generic/include/clc/math/logb.inc URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/logb.inc?rev=292335&view=auto == --- libclc/trunk/generic/include/clc/math/logb.inc (added) +++ libclc/trunk/generic/include/clc/math/logb.inc Tue Jan 17 21:14:10 2017 @@ -0,0 +1 @@ +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE logb(__CLC_GENTYPE a); Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=292335&r1=292334&r2=292335&view=diff == --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Tue Jan 17 21:14:10 2017 @@ -104,6 +104,7 @@ math/log.cl math/log10.cl math/log1p.cl math/log2.cl +math/logb.cl math/mad.cl math/modf.cl math/native_log.cl Added: libclc/trunk/generic/lib/math/logb.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/logb.cl?rev=292335&view=auto == --- libclc/trunk/generic/lib/math/logb.cl (added) +++ libclc/trunk/generic/lib/math/logb.cl Tue Jan 17 21:14:10 2017 @@ -0,0 +1,31 @@ +#include +#include "math.h" +#include "../clcmacro.h" + +_CLC_OVERLOAD _CLC_DEF float logb(float x) { +int ax = as_int(x) & EXSIGNBIT_SP32; +float s = -118 - clz(ax); +float r = (ax >> EXPSHIFTBITS_SP32) - EXPBIAS_SP32; +r = ax >= PINFBITPATT_SP32 ? as_float(ax) : r; +r = ax < 0x0080 ? s : r; +r = ax == 0 ? as_float(NINFBITPATT_SP32) : r; +return r; +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, logb, float); + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + +_CLC_OVERLOAD _CLC_DEF double logb(double x) { +long ax = as_long(x) & EXSIGNBIT_DP64; +double s = -1011L - clz(ax); +double r = (int) (ax >> EXPSHIFTBITS_DP64) - EXPBIAS_DP64; +r = ax >= PINFBITPATT_DP64 ? as_double(ax) : r; +r = ax < 0x0010L ? s : r; +r = ax == 0L ? as_double(NINFBITPATT_DP64) : r; +return r; +} + +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, double, logb, double) +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28844: clang-format: fix fallback style set to "none" not formatting
amaiorano created this revision. This change fixes the fact that fallback style set to "none" should not format. Without this change, fallback style "none" ends up applying LLVM formatting. https://reviews.llvm.org/D28844 Files: lib/Format/Format.cpp test/Format/style-on-command-line.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -10978,13 +10978,18 @@ ASSERT_TRUE((bool)Style1); ASSERT_EQ(*Style1, getLLVMStyle()); - // Test 2: fallback to default. + // Test 2.1: fallback to default. ASSERT_TRUE( FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;"))); auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS); ASSERT_TRUE((bool)Style2); ASSERT_EQ(*Style2, getMozillaStyle()); + // Test 2.2: no format on 'none' fallback style. + Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS); + ASSERT_TRUE((bool)Style2); + ASSERT_EQ(*Style2, getNoStyle()); + // Test 3: format file in parent directory. ASSERT_TRUE( FS.addFile("/c/.clang-format", 0, Index: test/Format/style-on-command-line.cpp === --- test/Format/style-on-command-line.cpp +++ test/Format/style-on-command-line.cpp @@ -11,6 +11,10 @@ // RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s | FileCheck -strict-whitespace -check-prefix=CHECK7 %s // RUN: clang-format -style="{BasedOnStyle: LLVM, PointerBindsToType: true}" %s | FileCheck -strict-whitespace -check-prefix=CHECK8 %s // RUN: clang-format -style="{BasedOnStyle: WebKit, PointerBindsToType: false}" %s | FileCheck -strict-whitespace -check-prefix=CHECK9 %s +// RUN: rm %T/_clang-format +// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s +// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s void f() { // CHECK1: {{^int\* i;$}} // CHECK2: {{^ int \*i;$}} @@ -22,6 +26,9 @@ // CHECK7: {{^ int\* i;$}} // CHECK8: {{^ int\* i;$}} // CHECK9: {{^int \*i;$}} +// CHECK10: {{^int\* i;$}} +// CHECK11: {{^ int \*i;$}} +// CHECK12: {{^int\*i;$}} int*i; int j; } Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1888,8 +1888,8 @@ } llvm::Expected getStyle(StringRef StyleName, StringRef FileName, - StringRef FallbackStyle, StringRef Code, - vfs::FileSystem *FS) { + StringRef FallbackStyleName, + StringRef Code, vfs::FileSystem *FS) { if (!FS) { FS = vfs::getRealFileSystem().get(); } @@ -1903,9 +1903,9 @@ (Code.contains("\n- (") || Code.contains("\n+ ("))) Style.Language = FormatStyle::LK_ObjC; - // FIXME: If FallbackStyle is explicitly "none", format is disabled. - if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) -return make_string_error("Invalid fallback style \"" + FallbackStyle.str()); + FormatStyle FallbackStyle = getNoStyle(); + if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle)) +return make_string_error("Invalid fallback style \"" + FallbackStyleName); if (StyleName.startswith("{")) { // Parse YAML/JSON style from the command line. @@ -1977,7 +1977,7 @@ return make_string_error("Configuration file(s) do(es) not support " + getLanguageName(Style.Language) + ": " + UnsuitableConfigFiles); - return Style; + return FallbackStyle; } } // namespace format Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -10978,13 +10978,18 @@ ASSERT_TRUE((bool)Style1); ASSERT_EQ(*Style1, getLLVMStyle()); - // Test 2: fallback to default. + // Test 2.1: fallback to default. ASSERT_TRUE( FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;"))); auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", "", &FS); ASSERT_TRUE((bool)Style2); ASSERT_EQ(*Style2, getMozillaStyle()); + // Test 2.2: no format on 'none' fallback style. + Style2 = getStyle("file", "/b/test.cpp", "none", "", &FS); + ASSERT_TRUE((bool)Style2); + ASSERT_EQ(*Style2, getNoStyle()); + // Test 3: format file in parent directory. ASSERT_TRUE( FS.addFile("/c/.clang-format", 0, Index:
[PATCH] D28844: clang-format: fix fallback style set to "none" not formatting
amaiorano added inline comments. Comment at: lib/Format/Format.cpp:1906 - // FIXME: If FallbackStyle is explicitly "none", format is disabled. - if (!getPredefinedStyle(FallbackStyle, Style.Language, &Style)) -return make_string_error("Invalid fallback style \"" + FallbackStyle.str()); + FormatStyle FallbackStyle = getNoStyle(); + if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle)) Technically, we don't need to initialize FallbackStyle to getNoStyle() here as the call to getPredefinedStyle just below will initialize it. Let me know what you would prefer here. Comment at: test/Format/style-on-command-line.cpp:15 +// RUN: rm %T/_clang-format +// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s Tests no config file found, WebKit fallback style is applied Comment at: test/Format/style-on-command-line.cpp:16 +// RUN: clang-format -style=file -fallback-style=WebKit -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK10 %s +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s +// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s Tests no config file found, no fallback style, LLVM style is applied Comment at: test/Format/style-on-command-line.cpp:17 +// RUN: clang-format -style=file -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK11 %s +// RUN: clang-format -style=file -fallback-style=none -assume-filename=%T/foo.cpp < %s 2>&1 | FileCheck -strict-whitespace -check-prefix=CHECK12 %s void f() { Tests no config file found, fallback style set to "none", no formatting is applied https://reviews.llvm.org/D28844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits