[PATCH] D41102: Setup clang-doc frontend framework
juliehockett added inline comments. Comment at: clang-doc/ClangDocBinary.cpp:88 + Stream.Emit((unsigned)'C', 8); + Stream.Emit((unsigned)'S', 8); +} lebedev.ri wrote: > General comment: shouldn't the bitcode be versioned? Possibly? My understanding of the versioning (which could be incorrect) was that it was for the LLVM IR and how it is written in the given file -- I'm not writing to LLVM IR here, just using it as a data storage format, and so didn't think it was necessary. Happy to add it in though, but which version number should I use? https://reviews.llvm.org/D41102 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41102: Setup clang-doc frontend framework
juliehockett updated this revision to Diff 134855. juliehockett marked 14 inline comments as done. juliehockett added a comment. 1. Fixing docs 2. Adding static map from bitcode block/record id to block/record name 3. Pulling magic numbers into one struct 4. Cleaning up and clarifying command line options 5. Adding tests for functions and methods https://reviews.llvm.org/D41102 Files: CMakeLists.txt clang-doc/CMakeLists.txt clang-doc/ClangDoc.cpp clang-doc/ClangDoc.h clang-doc/ClangDocBinary.cpp clang-doc/ClangDocBinary.h clang-doc/ClangDocMapper.cpp clang-doc/ClangDocMapper.h clang-doc/ClangDocRepresentation.h clang-doc/tool/CMakeLists.txt clang-doc/tool/ClangDocMain.cpp docs/clang-doc.rst test/CMakeLists.txt test/clang-doc/mapper-class.cpp test/clang-doc/mapper-enum.cpp test/clang-doc/mapper-function.cpp test/clang-doc/mapper-method.cpp test/clang-doc/mapper-namespace.cpp test/clang-doc/mapper-struct.cpp test/clang-doc/mapper-undefined.cpp test/clang-doc/mapper-union.cpp Index: test/clang-doc/mapper-union.cpp === --- /dev/null +++ test/clang-doc/mapper-union.cpp @@ -0,0 +1,26 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer %t/docs/A.bc --dump | FileCheck %s + +union A { int X; int Y; }; +// CHECK: +// CHECK: + // CHECK: blob data = 'A' + // CHECK: blob data = 'A' + // CHECK: + // CHECK: +// CHECK: +// CHECK: blob data = 'int' +// CHECK: blob data = 'A::X' +// CHECK: + // CHECK: + // CHECK: +// CHECK: +// CHECK: blob data = 'int' +// CHECK: blob data = 'A::Y' +// CHECK: + // CHECK: +// CHECK: Index: test/clang-doc/mapper-undefined.cpp === --- /dev/null +++ test/clang-doc/mapper-undefined.cpp @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer %t/docs/E.bc --dump | FileCheck %s + +class E; +// CHECK: +// CHECK: + // CHECK: blob data = 'E' + // CHECK: blob data = 'E' + // CHECK: +// CHECK: + Index: test/clang-doc/mapper-struct.cpp === --- /dev/null +++ test/clang-doc/mapper-struct.cpp @@ -0,0 +1,19 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer %t/docs/C.bc --dump | FileCheck %s + +struct C { int i; }; +// CHECK: +// CHECK: + // CHECK: blob data = 'C' + // CHECK: blob data = 'C' + // CHECK: +// CHECK: +// CHECK: blob data = 'int' +// CHECK: blob data = 'C::i' +// CHECK: + // CHECK: +// CHECK: Index: test/clang-doc/mapper-namespace.cpp === --- /dev/null +++ test/clang-doc/mapper-namespace.cpp @@ -0,0 +1,13 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer %t/docs/A.bc --dump | FileCheck %s + +namespace A {} +// CHECK: +// CHECK: + // CHECK: blob data = 'A' + // CHECK: blob data = 'A' +// CHECK: Index: test/clang-doc/mapper-method.cpp === --- /dev/null +++ test/clang-doc/mapper-method.cpp @@ -0,0 +1,30 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer %t/docs/_ZN1E6MethodEi.bc --dump | FileCheck %s + +class E { +public: + int Method(int param) { return param; } +}; +// CHECK: +// CHECK: + // CHECK: blob data = 'E::Method' + // CHECK: blob data = 'Method' + // CHECK: blob data = 'E' + // CHECK: blob data = '_ZN1E6MethodEi' + // CHECK: blob data = 'E' + // CHECK: +// CHECK: +// CHECK: blob data = 'int' +// CHECK: + // CHECK: + // CHECK: +// CHECK: +// CHECK: blob data = 'int' +// CHECK: blob data = 'param' +// CHECK: + // CHECK: +// CHECK: Index: test/clang-doc/mapper-function.cpp === --- /dev/null +++ test/clang-doc/mapper-function.cpp @@ -0,0 +1,25 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "" > %t/compile_flags.txt +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs +// RUN: llvm-bcanalyzer
[PATCH] D43429: [clangd] Add missing library (clangLex) in a few places
malaperle abandoned this revision. malaperle added a comment. Already landed in another commit. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D43429 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43430: Omit nullptr check for sufficiently simple delete-expressions
ahh updated this revision to Diff 134846. ahh added a comment. Fix indentation Repository: rC Clang https://reviews.llvm.org/D43430 Files: lib/CodeGen/CGCXXABI.h lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/cxx2a-destroying-delete.cpp test/CodeGenCXX/delete-two-arg.cpp test/CodeGenCXX/delete.cpp Index: test/CodeGenCXX/delete.cpp === --- test/CodeGenCXX/delete.cpp +++ test/CodeGenCXX/delete.cpp @@ -9,7 +9,12 @@ }; // POD types. +// CHECK-LABEL: define void @_Z2t3P1S void t3(S *s) { + // CHECK-NOT: icmp eq {{.*}}, null + // CHECK-NOT: br i1 + // CHECK: call void @_ZdlPv + delete s; } @@ -99,6 +104,8 @@ namespace test3 { void f(int a[10][20]) { +// CHECK-NOT: icmp eq {{.*}}, null +// CHECK-NOT: br i1 // CHECK: call void @_ZdaPv(i8* delete a; } @@ -113,6 +120,8 @@ // CHECK-LABEL: define void @_ZN5test421global_delete_virtualEPNS_1XE void global_delete_virtual(X *xp) { +// CHECK: icmp eq {{.*}}, null +// CHECK: br i1 // Load the offset-to-top from the vtable and apply it. // This has to be done first because the dtor can mess it up. // CHECK: [[T0:%.*]] = bitcast [[X:%.*]]* [[XP:%.*]] to i64** Index: test/CodeGenCXX/delete-two-arg.cpp === --- test/CodeGenCXX/delete-two-arg.cpp +++ test/CodeGenCXX/delete-two-arg.cpp @@ -9,8 +9,8 @@ // CHECK-LABEL: define void @_ZN5test11aEPNS_1AE( void a(A *x) { // CHECK: load -// CHECK-NEXT: icmp eq {{.*}}, null -// CHECK-NEXT: br i1 +// CHECK-NOT: icmp eq {{.*}}, null +// CHECK-NOT: br i1 // CHECK: call void @_ZN5test11AdlEPvj(i8* %{{.*}}, i32 4) delete x; } Index: test/CodeGenCXX/cxx2a-destroying-delete.cpp === --- test/CodeGenCXX/cxx2a-destroying-delete.cpp +++ test/CodeGenCXX/cxx2a-destroying-delete.cpp @@ -15,9 +15,8 @@ void delete_A(A *a) { delete a; } // CHECK-LABEL: define {{.*}}delete_A // CHECK: %[[a:.*]] = load -// CHECK: icmp eq %{{.*}} %[[a]], null -// CHECK: br i1 -// +// CHECK-NOT: icmp eq %{{.*}} %[[a]], null +// CHECK-NOT: br i1 // Ensure that we call the destroying delete and not the destructor. // CHECK-NOT: call // CHECK-ITANIUM: call void @_ZN1AdlEPS_St19destroying_delete_t(%{{.*}}* %[[a]]) @@ -60,8 +59,8 @@ // CHECK: %[[castbase:.*]] = bitcast {{.*}} %[[base]] // // CHECK: %[[a:.*]] = phi {{.*}} %[[castbase]] -// CHECK: icmp eq %{{.*}} %[[a]], null -// CHECK: br i1 +// CHECK-NOT: icmp eq %{{.*}} %[[a]], null +// CHECK-NOT: br i1 // // CHECK-NOT: call // CHECK-ITANIUM: call void @_ZN1AdlEPS_St19destroying_delete_t(%{{.*}}* %[[a]]) Index: lib/CodeGen/CGExprCXX.cpp === --- lib/CodeGen/CGExprCXX.cpp +++ lib/CodeGen/CGExprCXX.cpp @@ -1971,26 +1971,57 @@ CGF.PopCleanupBlock(); } -void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { - const Expr *Arg = E->getArgument(); - Address Ptr = EmitPointerWithAlignment(Arg); +// Will we read through the deleted pointer? If so, +// we must first check it is not null. +static bool DeleteMightAccessObject(CodeGenFunction , +const CXXDeleteExpr *E, QualType DeleteTy) { - // Null check the pointer. - llvm::BasicBlock *DeleteNotNull = createBasicBlock("delete.notnull"); - llvm::BasicBlock *DeleteEnd = createBasicBlock("delete.end"); + if (E->getOperatorDelete()->isDestroyingOperatorDelete()) { +// It is safe to call destroying operator delete with nullptr arguments +// ([expr.delete] tells us it is unspecified whether a deallocation +// function is called) but a virtual destructor must be resolved +// to find the right function, which we can't do on nullptr. +auto *Dtor = DeleteTy->getAsCXXRecordDecl()->getDestructor(); +return Dtor && Dtor->isVirtual(); + } - llvm::Value *IsNull = Builder.CreateIsNull(Ptr.getPointer(), "isnull"); + if (E->isArrayForm()) { +return CGF.CGM.getCXXABI().requiresArrayCookie(E, DeleteTy); + } - Builder.CreateCondBr(IsNull, DeleteEnd, DeleteNotNull); - EmitBlock(DeleteNotNull); + // Otherwise, we should avoid invoking any nontrivial destructor on + // a null object. + return DeleteTy.isDestructedType(); +} +void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { + const Expr *Arg = E->getArgument(); + Address Ptr = EmitPointerWithAlignment(Arg); QualType DeleteTy = E->getDestroyedType(); + // Null check the pointer, unless the destructor is trivial. In that case, + // all we'll be doing is passing Ptr to ::operator delete(), which is + // well formed for nullptr arguments (and allowed by [expr.delete.7] + // The overwhelming majority of deletes are of non-nullptr, so there's + // no efficiency gain to be had by skipping the very rare exceptions, and + // it bleeds
[PATCH] D43430: Omit nullptr check for sufficiently simple delete-expressions
rsmith added a comment. LGTM, but I'd also like @rjmccall's opinion. Repository: rC Clang https://reviews.llvm.org/D43430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43430: Omit nullptr check for sufficiently simple delete-expressions
rsmith added a comment. In https://reviews.llvm.org/D43430#1011269, @kimgr wrote: > I wonder if this could have negative effects for frequent deletion of > nullptrs (e.g. a sometimes-allocated member of a heavily used value type). For that to be better, I think we'd need one of two things to happen: 1. The compiler can statically detect that the pointer is null, and remove the call to `operator delete` and potentially other code too. (This happens, eg, when inlining `vector::push_back` on an empty `vector`.) 2. The condition cannot be determined statically, but dynamically it turns out that the pointer is very frequently null, so that the cost of the extra checks in the non-null case are cheaper than the cost of the function call in the null case. For case 1, the optimizer already knows that it can remove calls to usual `operator delete` functions on a null pointer, so that optimization should not be inhibited by this change. For case 2, it seems to me that our default assumption should probably be that most deleted pointers are not null. But I don't have measurements to back that up. If the user knows that their pointers are usually null, they can express that knowledge with an `if`, but if we always generate the branch on null here, then there would be no easy way for the programmer to express their intent that the pointer is usually not null. Comment at: lib/CodeGen/CGExprCXX.cpp:1977-1978 +static bool DeleteMightAccessObject(CodeGenFunction , + const CXXDeleteExpr *E, + QualType DeleteTy) { Reindent. Repository: rC Clang https://reviews.llvm.org/D43430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r325468 - [Analyzer] Move UnexploredFirstStack into an anonymous namespace.
Author: d0k Date: Sun Feb 18 11:08:27 2018 New Revision: 325468 URL: http://llvm.org/viewvc/llvm-project?rev=325468=rev Log: [Analyzer] Move UnexploredFirstStack into an anonymous namespace. No functionality change intended. Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp?rev=325468=325467=325468=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp Sun Feb 18 11:08:27 2018 @@ -132,6 +132,7 @@ std::unique_ptr WorkList::make return llvm::make_unique(); } +namespace { class UnexploredFirstStack : public WorkList { /// Stack of nodes known to have statements we have not traversed yet. @@ -185,6 +186,7 @@ public: } } }; +} // end anonymous namespace std::unique_ptr WorkList::makeUnexploredFirst() { return llvm::make_unique(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r325467 - [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts.
Author: d0k Date: Sun Feb 18 11:02:35 2018 New Revision: 325467 URL: http://llvm.org/viewvc/llvm-project?rev=325467=rev Log: [tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts. No functionality change intended. Modified: clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp clang-tools-extra/trunk/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp clang-tools-extra/trunk/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp clang-tools-extra/trunk/clang-tidy/fuchsia/TrailingReturnCheck.cpp clang-tools-extra/trunk/clang-tidy/fuchsia/VirtualInheritanceCheck.cpp clang-tools-extra/trunk/clang-tidy/hicpp/NoAssemblerCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp?rev=325467=325466=325467=diff == --- clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp Sun Feb 18 11:02:35 2018 @@ -15,10 +15,12 @@ namespace clang { namespace tidy { namespace boost { +namespace { AST_MATCHER(Type, isStrictlyInteger) { return Node.isIntegerType() && !Node.isAnyCharacterType() && !Node.isBooleanType(); } +} // namespace void UseToStringCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) Modified: clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp?rev=325467=325466=325467=diff == --- clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/bugprone/StringConstructorCheck.cpp Sun Feb 18 11:02:35 2018 @@ -18,9 +18,11 @@ namespace clang { namespace tidy { namespace bugprone { +namespace { AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) { return Node.getValue().getZExtValue() > N; } +} // namespace StringConstructorCheck::StringConstructorCheck(StringRef Name, ClangTidyContext *Context) Modified: clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp?rev=325467=325466=325467=diff == --- clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/bugprone/VirtualNearMissCheck.cpp Sun Feb 18 11:02:35 2018 @@ -19,11 +19,13 @@ namespace clang { namespace tidy { namespace bugprone { +namespace { AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); } AST_MATCHER(CXXMethodDecl, isOverloadedOperator) { return Node.isOverloadedOperator(); } +} // namespace /// Finds out if the given method overrides some method. static bool isOverrideMethod(const CXXMethodDecl *MD) { Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp?rev=325467=325466=325467=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp Sun Feb 18 11:02:35 2018 @@ -17,9 +17,11 @@ namespace clang { namespace tidy { namespace cppcoreguidelines { +namespace { AST_MATCHER(GotoStmt, isForwardJumping) { return Node.getLocStart() < Node.getLabel()->getLocStart(); } +} // namespace void AvoidGotoCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=325467=325466=325467=diff
Re: [PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well
I’ll have a look this week. -jroelofs On Sun, Feb 18, 2018 at 9:27 AM Rink via Phabricator < revi...@reviews.llvm.org> wrote: > zhmu added a comment. > > I've added jroelofs to the reviewer list as we spoke about this in #llvm > quite some time ago. > > > Repository: > rUNW libunwind > > https://reviews.llvm.org/D43442 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43443: libcxxabi: when building without threads, pass this to libcxx as well
zhmu created this revision. zhmu added a reviewer: jroelofs. Herald added subscribers: cfe-commits, mgorny. Herald added a reviewer: EricWF. I'm trying to build libcxxabi as prerequisite for libcxx. The target doesn't yet support userland threads, so I set LIBCXXABI_ENABLE_THREADS to 'OFF' in CMake (also, LLVM_ENABLE_LIBCXX is set to 'on' andLIBCXXABI_USE_LLVM_UNWINDER is 'yes'). This fails to build: /home/rink/github/ananas/toolchain/x86_64-ananas-elf-clang --target=x86_64-ananas-elf --sysroot=/tmp/ananas-build -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCXXABI_BUILDING_LIBRARY -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/rink/github/ananas/external/llvm/projects/libcxxabi/include -I/home/rink/github/ananas/external/llvm/projects/libcxx/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -funwind-tables -D_DEBUG -std=c++11 -MD -MT src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o -MF src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o.d -o src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o -c /home/rink/github/ananas/external/llvm/projects/libcxxabi/src/cxa_demangle.cpp In file included from /home/rink/github/ananas/external/llvm/projects/libcxxabi/src/cxa_demangle.cpp:20: In file included from /home/rink/github/ananas/external/llvm/projects/libcxx/include/vector:264: /home/rink/github/ananas/external/llvm/projects/libcxx/include/__config:1056:4: error: "No thread API" # error "No thread API" My patch is similar to https://reviews.llvm.org/D43442: emit a define so that libcxx works when included. Repository: rCXXA libc++abi https://reviews.llvm.org/D43443 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -333,6 +333,8 @@ " is also set to ON.") endif() add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) + # propgate no threads to libcxx, which uses a different flag + add_definitions(-D_LIBCPP_HAS_NO_THREADS) endif() if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -333,6 +333,8 @@ " is also set to ON.") endif() add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) + # propgate no threads to libcxx, which uses a different flag + add_definitions(-D_LIBCPP_HAS_NO_THREADS) endif() if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well
zhmu added a comment. I've added jroelofs to the reviewer list as we spoke about this in #llvm quite some time ago. Repository: rUNW libunwind https://reviews.llvm.org/D43442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43442: libunwind: when building without threads, pass this to libcxx as well
zhmu created this revision. zhmu added a reviewer: jroelofs. Herald added subscribers: cfe-commits, mgorny. Herald added a reviewer: EricWF. I'm trying to build libunwind as prerequisite for libcxx/libcxxabi. The target doesn't yet support userland threads, so I set LIBUNWIND_ENABLE_THREADS to 'OFF' in CMake (also, LLVM_ENABLE_LIBCXX is set to 'on'). This fails to build: /home/rink/github/ananas/toolchain/x86_64-ananas-elf-clang --target=x86_64-ananas-elf --sysroot=/tmp/ananas-build -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/rink/github/ananas/external/llvm/projects/libunwind/include -I/home/rink/github/ananas/external/llvm/projects/libcxx/include -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics -std=c++11 -g -fPIC -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wno-unused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -pedantic -D_DEBUG -D_LIBUNWIND_IS_NATIVE_ONLY -D_LIBUNWIND_HAS_NO_THREADS -fno-exceptions -funwind-tables -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -fcolor-diagnostics -std=c++11 -fstrict-aliasing -nostdinc++ -fno-rtti -MD -MT src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -MF src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o.d -o src/CMakeFiles/unwind_objects.dir/libunwind.cpp.o -c /home/rink/github/ananas/external/llvm/projects/libunwind/src/libunwind.cpp In file included from /home/rink/github/ananas/external/llvm/projects/libunwind/src/libunwind.cpp:13: In file included from /home/rink/github/ananas/external/llvm/projects/libunwind/include/libunwind.h:19: In file included from /home/rink/github/ananas/external/llvm/projects/libcxx/include/stdint.h:102: /home/rink/github/ananas/external/llvm/projects/libcxx/include/__config:1056:4: error: "No thread API" # error "No thread API" ^ 1 error generated. As the 'do not use threads' flag isn't passed to libcxx. I've attached a patch to remedy this - I hope it is the correct place to do so. Repository: rUNW libunwind https://reviews.llvm.org/D43442 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -296,6 +296,10 @@ # Threading-support if (NOT LIBUNWIND_ENABLE_THREADS) list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS) + if(LLVM_ENABLE_LIBCXX) +# Ensure libcxx doesn't try to use threads either +list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBCPP_HAS_NO_THREADS) + endif() endif() # ARM WMMX register support Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -296,6 +296,10 @@ # Threading-support if (NOT LIBUNWIND_ENABLE_THREADS) list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS) + if(LLVM_ENABLE_LIBCXX) +# Ensure libcxx doesn't try to use threads either +list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBCPP_HAS_NO_THREADS) + endif() endif() # ARM WMMX register support ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43440: clang-format: [JS] fix `of` detection.
mprobst created this revision. mprobst added a reviewer: djasper. Herald added a subscriber: klimek. `of` is only a keyword when after an identifier, but not when after an actual keyword. Before: return of (a, b, c); After: return of(a, b, c); Repository: rC Clang https://reviews.llvm.org/D43440 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -294,6 +294,7 @@ verifyFormat("x.for = 1;"); verifyFormat("x.of();"); verifyFormat("of(null);"); + verifyFormat("return of(null);"); verifyFormat("import {of} from 'x';"); verifyFormat("x.in();"); verifyFormat("x.let();"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2496,7 +2496,7 @@ // (e.g. as "const x of y" in a for loop), or after a destructuring // operation (const [x, y] of z, const {a, b} of c). (Left.is(Keywords.kw_of) && Left.Previous && - (Left.Previous->Tok.getIdentifierInfo() || + (Left.Previous->Tok.is(tok::identifier) || Left.Previous->isOneOf(tok::r_square, tok::r_brace && (!Left.Previous || !Left.Previous->is(tok::period))) return true; Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -294,6 +294,7 @@ verifyFormat("x.for = 1;"); verifyFormat("x.of();"); verifyFormat("of(null);"); + verifyFormat("return of(null);"); verifyFormat("import {of} from 'x';"); verifyFormat("x.in();"); verifyFormat("x.let();"); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2496,7 +2496,7 @@ // (e.g. as "const x of y" in a for loop), or after a destructuring // operation (const [x, y] of z, const {a, b} of c). (Left.is(Keywords.kw_of) && Left.Previous && - (Left.Previous->Tok.getIdentifierInfo() || + (Left.Previous->Tok.is(tok::identifier) || Left.Previous->isOneOf(tok::r_square, tok::r_brace && (!Left.Previous || !Left.Previous->is(tok::period))) return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D43394: [X86] Add 'sahf' CPU feature, and emit __LAHFSAHF__ for it
On Fri, Feb 16, 2018 at 6:21 PM, Dimitry Andricwrote: > On 17 Feb 2018, at 00:12, Craig Topper via Phabricator < > revi...@reviews.llvm.org> wrote: > > > > craig.topper added inline comments. > > > > > > > > Comment at: lib/Basic/Targets/X86.cpp:1049 > > > > + if (HasLAHFSAHF) > > +Builder.defineMacro("__LAHFSAHF__"); > > > > dim wrote: > >> craig.topper wrote: > >>> Does gcc define this? It's such a low level instruction I have a hard > time believing this define would be useful. > >> I tried gcc 6, 7 and 8, and while they do expose stuff like > `__POPCNT__`, I see no `__LAHFSAHF__`. I am supposing Jonathan's original > intent with this was to make it easily testable in source, so you can > insert the right assembly for the target CPU. The same could really be > said for things like `__RDSEED__`, and some other defines... > > Most of the defines indicate the availability of intrinsics. At least > that was their original intent. They used to control what intrinsic header > were included in x86intrin.h or immintrin.h. Though now we include > everything except in MSVC compatible mode and allow the target attribute to > provide per function control. > > > > I'd prefer not to add this one if gcc doesn't have it. > > Jonathan, can you comment on your reasons for adding the __LAHFSAHF__ > define? Was this just a nice-to-have, or do you require it for something > related to https://bugs.llvm.org/show_bug.cgi?id=36028 ? > > Its just a "nice-to-have". Among other things, it makes it easy to determine CPU support in case you wanted to write assembly to use this feature. It also makes it easy to test for the behavior of the front-end with respect to this feature. But, I don't have any current use case for it, and won't be upset if it disappears. Jonathan ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D43430: Omit nullptr check for sufficiently simple delete-expressions
On Sat, Feb 17, 2018 at 1:41 AM Kim Gräsman via Phabricator < revi...@reviews.llvm.org> wrote: > kimgr added a comment. > > Peanut gallery observation: there was a discussion on the Boost list years > and years ago where someone made the case that `if (x != nullptr) delete > x;` was measurably faster than just calling `delete x;` I can't find it > now, but I think it might have been in the context of their > `checked_delete` library. Anyway, the reasoning was that with an external > nullptr check, you'd pay for one comparison, but without it you'd always > pay for a jump + a comparison. I suppose that only holds true for null > pointers, for non-null pointers the extra check is just waste. > > This is all correct, to some extent; that said, the net difference will be a call to a reasonably hot function and an extra branch. For grins, I benchmarked the cost of ::operator delete (this is slightly challenging because clang currently (mis?) compiles ::operator delete(nullptr) away, but this is solvable...) With our tcmalloc, the cost of deleting null is about 8 cycles (compared to an empty loop.) (I don't really know how to benchmark the version with an if around it, but if we assume that's free, 8 cycles is still very cheap.) > It looks to me like the compiler inserts an external null check, and > you're now removing it in select cases, did I understand that right? Yes, precisely. > I wonder if this could have negative effects for frequent deletion of > nullptrs (e.g. a sometimes-allocated member of a heavily used value type). > > In principle yes. I would be very surprised if any binary deletes null pointers often enough for this to be a significant concern (other than statically-provable ones, which are still free.) You'd have to be doing it a lot to notice those 8 cycles. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43303: [Format] Fix for bug 35641
kadircet updated this revision to Diff 134830. kadircet added a comment. Rebased and uploaded diff to the master. Sorry for the inconvenience. Repository: rC Clang https://reviews.llvm.org/D43303 Files: lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -9449,6 +9449,14 @@ "});\n", Alignment); Alignment.PointerAlignment = FormatStyle::PAS_Right; + + // See llvm.org/PR35641 + Alignment.AlignConsecutiveDeclarations = true; + verifyFormat("int func() { //\n" + " int b;\n" + " unsigned c;\n" + "}", + Alignment); } TEST_F(FormatTest, LinuxBraceBreaking) { Index: lib/Format/WhitespaceManager.cpp === --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -255,8 +255,14 @@ Changes[ScopeStack.back()].indentAndNestingLevel()) ScopeStack.pop_back(); +// Compare current token to previous non-comment token to ensure whether +// it is in a deeper scope or not. +unsigned PreviousNonComment = i - 1; +while (PreviousNonComment > Start && + Changes[PreviousNonComment].Tok->is(tok::comment)) + PreviousNonComment--; if (i != Start && Changes[i].indentAndNestingLevel() > - Changes[i - 1].indentAndNestingLevel()) + Changes[PreviousNonComment].indentAndNestingLevel()) ScopeStack.push_back(i); bool InsideNestedScope = ScopeStack.size() != 0; Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -9449,6 +9449,14 @@ "});\n", Alignment); Alignment.PointerAlignment = FormatStyle::PAS_Right; + + // See llvm.org/PR35641 + Alignment.AlignConsecutiveDeclarations = true; + verifyFormat("int func() { //\n" + " int b;\n" + " unsigned c;\n" + "}", + Alignment); } TEST_F(FormatTest, LinuxBraceBreaking) { Index: lib/Format/WhitespaceManager.cpp === --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -255,8 +255,14 @@ Changes[ScopeStack.back()].indentAndNestingLevel()) ScopeStack.pop_back(); +// Compare current token to previous non-comment token to ensure whether +// it is in a deeper scope or not. +unsigned PreviousNonComment = i - 1; +while (PreviousNonComment > Start && + Changes[PreviousNonComment].Tok->is(tok::comment)) + PreviousNonComment--; if (i != Start && Changes[i].indentAndNestingLevel() > - Changes[i - 1].indentAndNestingLevel()) + Changes[PreviousNonComment].indentAndNestingLevel()) ScopeStack.push_back(i); bool InsideNestedScope = ScopeStack.size() != 0; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43437: [clangd] Fix link failures for Preprocessor::addCommentHandler
This revision was automatically updated to reflect the committed changes. Closed by commit rL325458: [clangd] Fix link failures for Preprocessor::addCommentHandler (authored by aheejin, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D43437 Files: clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Index: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt @@ -38,6 +38,7 @@ clangFormat clangFrontend clangIndex + clangLex clangSema clangTooling clangToolingCore Index: clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt === --- clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt +++ clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt @@ -15,5 +15,6 @@ clangDaemon clangBasic clangFrontend + clangLex clangTooling ) Index: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt === --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt @@ -38,6 +38,7 @@ clangFormat clangFrontend clangIndex + clangLex clangSema clangTooling clangToolingCore Index: clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt === --- clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt +++ clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt @@ -15,5 +15,6 @@ clangDaemon clangBasic clangFrontend + clangLex clangTooling ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r325458 - [clangd] Fix link failures for Preprocessor::addCommentHandler
Author: aheejin Date: Sun Feb 18 02:50:16 2018 New Revision: 325458 URL: http://llvm.org/viewvc/llvm-project?rev=325458=rev Log: [clangd] Fix link failures for Preprocessor::addCommentHandler Summary: D42640 adds calls to `Preprocessor::addCommentHandler` in `unittests/clangd/SymbolCollectorTests.cpp` and `clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp` but does not link `clangLex` library. This causes undefined reference errors when built with `-DBUILD_SHARED_LIBS=ON`. Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43437 Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt?rev=325458=325457=325458=diff == --- clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/global-symbol-builder/CMakeLists.txt Sun Feb 18 02:50:16 2018 @@ -15,5 +15,6 @@ target_link_libraries(global-symbol-buil clangDaemon clangBasic clangFrontend + clangLex clangTooling ) Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt?rev=325458=325457=325458=diff == --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original) +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Sun Feb 18 02:50:16 2018 @@ -38,6 +38,7 @@ target_link_libraries(ClangdTests clangFormat clangFrontend clangIndex + clangLex clangSema clangTooling clangToolingCore ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43437: Fix link failures for Preprocessor::addCommentHandler
ioeric accepted this revision. ioeric added a subscriber: malaperle. ioeric added a comment. This revision is now accepted and ready to land. lg. Thanks! fyi, @malaperle also sent https://reviews.llvm.org/D43429 for the same fix but has not landed it yet ;) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D43437 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43303: [Format] Fix for bug 35641
lebedev.ri added a comment. The diff looks wrong, the `lib/Format/WhitespaceManager.cpp` change gone missing. You need to upload the diff to the `git master`/svn trunk/etc, *NOT* to the previous commit (previous diff). Repository: rC Clang https://reviews.llvm.org/D43303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43303: [Format] Fix for bug 35641
kadircet added a comment. Btw, I cannot commit the change myself, don't have commit rights. Repository: rC Clang https://reviews.llvm.org/D43303 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43437: Fix link failures for Preprocessor::addCommentHandler
aheejin created this revision. aheejin added a reviewer: ioeric. Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, mgorny, klimek. https://reviews.llvm.org/D42640 adds calls to `Preprocessor::addCommentHandler` in `unittests/clangd/SymbolCollectorTests.cpp` and `clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp` but does not link `clangLex` library. This causes undefined reference errors when built with `-DBUILD_SHARED_LIBS=ON`. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D43437 Files: clangd/global-symbol-builder/CMakeLists.txt unittests/clangd/CMakeLists.txt Index: unittests/clangd/CMakeLists.txt === --- unittests/clangd/CMakeLists.txt +++ unittests/clangd/CMakeLists.txt @@ -38,6 +38,7 @@ clangFormat clangFrontend clangIndex + clangLex clangSema clangTooling clangToolingCore Index: clangd/global-symbol-builder/CMakeLists.txt === --- clangd/global-symbol-builder/CMakeLists.txt +++ clangd/global-symbol-builder/CMakeLists.txt @@ -15,5 +15,6 @@ clangDaemon clangBasic clangFrontend + clangLex clangTooling ) Index: unittests/clangd/CMakeLists.txt === --- unittests/clangd/CMakeLists.txt +++ unittests/clangd/CMakeLists.txt @@ -38,6 +38,7 @@ clangFormat clangFrontend clangIndex + clangLex clangSema clangTooling clangToolingCore Index: clangd/global-symbol-builder/CMakeLists.txt === --- clangd/global-symbol-builder/CMakeLists.txt +++ clangd/global-symbol-builder/CMakeLists.txt @@ -15,5 +15,6 @@ clangDaemon clangBasic clangFrontend + clangLex clangTooling ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits