r262178 - Add ARM EHABI-related constants to unwind.h.
Author: logan Date: Sun Feb 28 09:01:42 2016 New Revision: 262178 URL: http://llvm.org/viewvc/llvm-project?rev=262178&view=rev Log: Add ARM EHABI-related constants to unwind.h. Adds a number of constants, defined in the ARM EHABI spec, to the Clang lib/Headers/unwind.h header. This is prerequisite for landing http://reviews.llvm.org/D15781, as previously discussed there. Patch by Timon Van Overveldt. Modified: cfe/trunk/lib/Headers/unwind.h Modified: cfe/trunk/lib/Headers/unwind.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=262178&r1=262177&r2=262178&view=diff == --- cfe/trunk/lib/Headers/unwind.h (original) +++ cfe/trunk/lib/Headers/unwind.h Sun Feb 28 09:01:42 2016 @@ -79,6 +79,10 @@ struct _Unwind_Context; struct _Unwind_Exception; typedef enum { _URC_NO_REASON = 0, +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ +!defined(__ARM_DWARF_EH__) + _URC_OK = 0, /* used by ARM EHABI */ +#endif _URC_FOREIGN_EXCEPTION_CAUGHT = 1, _URC_FATAL_PHASE2_ERROR = 2, @@ -88,7 +92,11 @@ typedef enum { _URC_END_OF_STACK = 5, _URC_HANDLER_FOUND = 6, _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8 + _URC_CONTINUE_UNWIND = 8, +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ +!defined(__ARM_DWARF_EH__) + _URC_FAILURE = 9 /* used by ARM EHABI */ +#endif } _Unwind_Reason_Code; typedef enum { @@ -150,6 +158,15 @@ typedef enum { _UVRSR_FAILED = 2 } _Unwind_VRS_Result; +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__ARM_DWARF_EH__) +typedef uint32_t _Unwind_State; +#define _US_VIRTUAL_UNWIND_FRAME ((_Unwind_State)0) +#define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1) +#define _US_UNWIND_FRAME_RESUME ((_Unwind_State)2) +#define _US_ACTION_MASK ((_Unwind_State)3) +#define _US_FORCE_UNWIND ((_Unwind_State)8) +#endif + _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context, _Unwind_VRS_RegClass __regclass, uint32_t __regno, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.
logan added a comment. Hi @timonvo, I have committed this change as http://reviews.llvm.org/rL262178. Thanks for your work. Let's move forward to http://reviews.llvm.org/D15781. http://reviews.llvm.org/D15883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.
thakis created this revision. thakis added a reviewer: hans. thakis added a subscriber: cfe-commits. In the gcc precompiled header model, one explicitly runs clang with `-x c++-header` on a .h file to produce a gch file, and then includes the header with `-include foo.h` and if a .gch file exists for that header it gets used. This is documented at http://clang.llvm.org/docs/UsersManual.html#precompiled-headers cl.exe's model is fairly different, and controlled by the two flags /Yc and /Yu. A pch file is generated as a side effect of a regular compilation when /Ycheader.h is passed. While the compilation is running, the compiler keeps track of #include lines in the main translation unit and writes everything up to an `#include "header.h"` line into a pch file. Conversely, /Yuheader.h tells the compiler to skip all code in the main TU up to and including `#include "header.h"` and instead load header.pch. (It's also possible to use /Yc and /Yu without an argument, in that case a `#pragma hrdstop` takes the role of controlling the point where pch ends and real code begins.) This file implements limited support for this in that it requires the pch header to be passed as a /FI force include flag – with this restriction, support for this can be implemented completely in the driver with fairly small amounts of code. For /Yu, this is trivial, and for /Yc a separate pch action is added that runs before the actual compilation. To make sure the compilation doesn't run if building the pch fails, Action gets support for "implicit inputs": Inputs that are needed from a dependency point of view so that a command won't run if an implicit input failed to build, but that aren't passed as inputs to the action. It looks like this concept might be useful for CUDA as well. If /Yc /Yu are used in a setup that clang-cl doesn't implement yet, clang-cl will now emit a "not implemented yet, ignoring flag" warning that can be disabled by -Wno-clang-cl-pch. (The default stdafx.h setup passes stdafx.h as explicit argument to /Yc but not as /FI – instead every single TU has to `#include ` as first thing it does. Implementing support for this should be possible with the approach in this patch with minimal frontend changes by passing a --stop-at / --start-at flag from the driver to the frontend. This is left for a follow-up. I don't think we ever want to support `#pragma hdrstop`, and supporting it with this approach isn't easy: This approach relies on the driver knowing the pch filename in advance, and `#pragma hdrstop(out.pch)` can set the output filename, so the driver can't know about it in advance.) clang-cl now also honors /Fp and puts pch files in the same spot that cl.exe would put them, but the pch file format is of course incompatible. This has ramifications on /fallback, so /Yc /Yu aren't passed through to cl.exe in /fallback builds. http://reviews.llvm.org/D17695 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/Action.h include/clang/Driver/CLCompatOptions.td include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/Inputs/pchfile.h test/Driver/cl-pch.c test/Driver/cl-pch.cpp Index: test/Driver/cl-pch.cpp === --- test/Driver/cl-pch.cpp +++ test/Driver/cl-pch.cpp @@ -0,0 +1,309 @@ +// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// /Yc +// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC %s +// 1. Build .pch file. +// CHECK-YC: cc1 +// CHECK-YC: -emit-pch +// CHECK-YC: -o +// CHECK-YC: pchfile.pch +// CHECK-YC: -x +// CHECK-YC: "c++" +// 2. Use .pch file. +// CHECK-YC: cc1 +// CHECK-YC: -emit-obj +// CHECK-YC: -include-pch +// CHECK-YC: pchfile.pch + +// /Yc /Fo +// /Fo overrides the .obj output filename, but not the .pch filename +// RUN: %clang_cl -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YCO %s +// 1. Build .pch file. +// CHECK-YCO: cc1 +// CHECK-YCO: -emit-pch +// CHECK-YCO: -o +// CHECK-YCO: pchfile.pch +// 2. Use .pch file. +// CHECK-YCO: cc1 +// CHECK-YCO: -emit-obj +// CHECK-YCO: -include-pch +// CHECK-YCO: pchfile.pch +// CHECK-YCO: -o +// CHECK-YCO: myobj.obj + +// /Yc /Y- +// /Y- disables pch generation +// RUN: %clang_cl -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-Y_ %s +// CHECK-YC-Y_-NOT: -emit-pch +// CHECK-YC-Y_-NOT: -include-pch + +// /Yu +// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YU %s +// Use .pch file, but don't build it. +// CHECK-YU-NOT: -emit-pch +// CHECK-YU: cc1 +// C
Re: [PATCH] D14286: ASTImporter: expressions, pt.1
2016-02-19 20:52 GMT+06:00 Aleksei Sidorin : > a.sidorin added a comment. > > Serge Pavlov: I'll enable tests from you patch ( > http://reviews.llvm.org/D14224) after all node types your patch supports > will be supported. If you're agree, of course. > > Yes, sure, that would be nice! I cannot compile clang with the patch applied: ``` In file included from /export/serge/llvm/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:57:0, from /export/serge/llvm/llvm/llvm/tools/clang/unittests/AST/MatchVerifier.h:26, from /export/serge/llvm/llvm/llvm/tools/clang/unittests/AST/ASTImporterTest.cpp:16: /export/serge/llvm/llvm/llvm/tools/clang/unittests/AST/ASTImporterTest.cpp: In member function âvirtual void clang::ast_matchers::ImportExpr_ImportAtomicExpr_Test::TestBody()â: /export/serge/llvm/llvm/llvm/tools/clang/unittests/AST/ASTImporterTest.cpp:241:21: error: âatomicExprâ was not declared in this scope ))); ^ ``` and many other error messages. Thanks, --Serge ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions
zaks.anna added a comment. The two underscores in the names are hard to read. Maybe we should just prefix them with 'win'? http://reviews.llvm.org/D17688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions
On Sun, Feb 28, 2016 at 1:21 PM, Anna Zaks wrote: > zaks.anna added a comment. > > The two underscores in the names are hard to read. Maybe we should just > prefix them with 'win'? Two underscores in the name is actually undefined behavior, so I would second this suggestion. ;-) ~Aaron ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r262189 - [modules] Prefer more complete array types.
Author: vvassilev Date: Sun Feb 28 13:08:24 2016 New Revision: 262189 URL: http://llvm.org/viewvc/llvm-project?rev=262189&view=rev Log: [modules] Prefer more complete array types. If we import a module that has a complete array type and one that has an incomplete array type, the declaration found by name lookup might be the one with the incomplete type, possibly resulting in rejects-valid. Now, the name lookup prefers decls with a complete array types. Also, diagnose cases when the redecl chain has array bound, different from the merge candidate. Reviewed by Richard Smith. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaLookup.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp cfe/trunk/test/Modules/Inputs/PR26179/A.h cfe/trunk/test/Modules/Inputs/PR26179/B.h cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=262189&r1=262188&r2=262189&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Feb 28 13:08:24 2016 @@ -3245,6 +3245,22 @@ void Sema::mergeObjCMethodDecls(ObjCMeth CheckObjCMethodOverride(newMethod, oldMethod); } +static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) { + assert(!S.Context.hasSameType(New->getType(), Old->getType())); + + S.Diag(New->getLocation(), New->isThisDeclarationADefinition() + ? diag::err_redefinition_different_type + : diag::err_redeclaration_different_type) +<< New->getDeclName() << New->getType() << Old->getType(); + + diag::kind PrevDiag; + SourceLocation OldLocation; + std::tie(PrevDiag, OldLocation) += getNoteDiagForInvalidRedeclaration(Old, New); + S.Diag(OldLocation, PrevDiag); + New->setInvalidDecl(); +} + /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and /// scope as a previous declaration 'Old'. Figure out how to merge their types, /// emitting diagnostics as appropriate. @@ -3271,21 +3287,40 @@ void Sema::MergeVarDeclTypes(VarDecl *Ne // object or function shall be identical, except that declarations for an // array object can specify array types that differ by the presence or // absence of a major array bound (8.3.4). -else if (Old->getType()->isIncompleteArrayType() && - New->getType()->isArrayType()) { - const ArrayType *OldArray = Context.getAsArrayType(Old->getType()); - const ArrayType *NewArray = Context.getAsArrayType(New->getType()); - if (Context.hasSameType(OldArray->getElementType(), - NewArray->getElementType())) -MergedT = New->getType(); -} else if (Old->getType()->isArrayType() && - New->getType()->isIncompleteArrayType()) { +else if (Old->getType()->isArrayType() && New->getType()->isArrayType()) { const ArrayType *OldArray = Context.getAsArrayType(Old->getType()); const ArrayType *NewArray = Context.getAsArrayType(New->getType()); - if (Context.hasSameType(OldArray->getElementType(), - NewArray->getElementType())) -MergedT = Old->getType(); -} else if (New->getType()->isObjCObjectPointerType() && + + // We are merging a variable declaration New into Old. If it has an array + // bound, and that bound differs from Old's bound, we should diagnose the + // mismatch. + if (!NewArray->isIncompleteArrayType()) { +for (VarDecl *PrevVD = Old->getMostRecentDecl(); PrevVD; + PrevVD = PrevVD->getPreviousDecl()) { + const ArrayType *PrevVDTy = Context.getAsArrayType(PrevVD->getType()); + if (PrevVDTy->isIncompleteArrayType()) +continue; + + if (!Context.hasSameType(NewArray, PrevVDTy)) +return diagnoseVarDeclTypeMismatch(*this, New, PrevVD); +} + } + + if (OldArray->isIncompleteArrayType() && NewArray->isArrayType()) { +if (Context.hasSameType(OldArray->getElementType(), +NewArray->getElementType())) + MergedT = New->getType(); + } + // FIXME: Check visibility. New is hidden but has a complete type. If New + // has no array bound, it should not inherit one from Old, if Old is not + // visible. + else if (OldArray->isArrayType() && NewArray->isIncompleteArrayType()) { +if (Context.hasSameType(OldArray->getElementType(), +NewArray->getElementType())) + MergedT = Old->getType(); + } +} +else if (New->getType()->isObjCObjectPointerType() && Old->getType()->isObjCObjectPointerType()) { MergedT = Context.mergeObjCGCQualifiers(New->getType(), Old->ge
Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.
thakis updated this revision to Diff 49325. thakis added a comment. clean up accidentally duplicate if block http://reviews.llvm.org/D17695 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Basic/DiagnosticGroups.td include/clang/Driver/Action.h include/clang/Driver/CLCompatOptions.td include/clang/Driver/Driver.h lib/Driver/Action.cpp lib/Driver/Compilation.cpp lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/Inputs/pchfile.h test/Driver/cl-pch.c test/Driver/cl-pch.cpp Index: test/Driver/cl-pch.cpp === --- test/Driver/cl-pch.cpp +++ test/Driver/cl-pch.cpp @@ -0,0 +1,309 @@ +// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// /Yc +// RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC %s +// 1. Build .pch file. +// CHECK-YC: cc1 +// CHECK-YC: -emit-pch +// CHECK-YC: -o +// CHECK-YC: pchfile.pch +// CHECK-YC: -x +// CHECK-YC: "c++" +// 2. Use .pch file. +// CHECK-YC: cc1 +// CHECK-YC: -emit-obj +// CHECK-YC: -include-pch +// CHECK-YC: pchfile.pch + +// /Yc /Fo +// /Fo overrides the .obj output filename, but not the .pch filename +// RUN: %clang_cl -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YCO %s +// 1. Build .pch file. +// CHECK-YCO: cc1 +// CHECK-YCO: -emit-pch +// CHECK-YCO: -o +// CHECK-YCO: pchfile.pch +// 2. Use .pch file. +// CHECK-YCO: cc1 +// CHECK-YCO: -emit-obj +// CHECK-YCO: -include-pch +// CHECK-YCO: pchfile.pch +// CHECK-YCO: -o +// CHECK-YCO: myobj.obj + +// /Yc /Y- +// /Y- disables pch generation +// RUN: %clang_cl -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-Y_ %s +// CHECK-YC-Y_-NOT: -emit-pch +// CHECK-YC-Y_-NOT: -include-pch + +// /Yu +// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YU %s +// Use .pch file, but don't build it. +// CHECK-YU-NOT: -emit-pch +// CHECK-YU: cc1 +// CHECK-YU: -emit-obj +// CHECK-YU: -include-pch +// CHECK-YU: pchfile.pch + +// /Yu /Y- +// RUN: %clang_cl -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YU-Y_ %s +// CHECK-YU-Y_-NOT: -emit-pch +// CHECK-YU-Y_-NOT: -include-pch + +// /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file +// RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-YU %s +// 1. Build .pch file. +// CHECK-YC-YU: cc1 +// CHECK-YC-YU: -emit-pch +// CHECK-YC-YU: -o +// CHECK-YC-YU: pchfile.pch +// 2. Use .pch file. +// CHECK-YC-YU: cc1 +// CHECK-YC-YU: -emit-obj +// CHECK-YC-YU: -include-pch +// CHECK-YC-YU: pchfile.pch + +// If /Yc /Yu refer to different files, semantics are pretty wonky. Since this +// doesn't seem like something that's important in practice, just punt for now. +// RUN: %clang_cl -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s +// CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet, ignoring flags + +// Similarly, punt on /Yc with more than one input file. +// RUN: %clang_cl -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s +// CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one input source file not implemented yet, ignoring flag + +// /Yc /Yu /Y- +// RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s +// CHECK-YC-YU-Y_-NOT: -emit-pch +// CHECK-YC-YU-Y_-NOT: -include-pch + +// Test computation of pch filename in various cases. + +// /Yu /Fpout.pch => out.pch is filename +// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s +// Use .pch file, but don't build it. +// CHECK-YUFP1: -include-pch +// CHECK-YUFP1: out.pch + +// /Yu /Fpout => out.pch is filename (.pch gets added if no extension present) +// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YUFP2 %s +// Use .pch file, but don't build it. +// CHECK-YUFP2: -include-pch +// CHECK-YUFP2: out.pch + +// /Yu /Fpout.bmp => out.bmp is filename (.pch not added when extension present) +// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.bmp /c -### -- %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-YUFP3 %s +// Use .pch file, but don't build it. +// CHECK-YUFP3: -include-pch +// CHECK-YUFP3: out.bmp + +// /Yusub/dir.h => sub/dir.pch +// RUN: %clang_cl -Werror /Yusub/pchfile.h /FIsub/pchfile.h /c -### -- %s
Re: r261774 - Bail on compilation as soon as a job fails.
Do you think something like the implicit inputs thing in http://reviews.llvm.org/D17695 could work for you as well, instead of this patch? Then we don't have to forever promise to compile all .cc input files serially. On Wed, Feb 24, 2016 at 4:49 PM, Justin Lebar via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: jlebar > Date: Wed Feb 24 15:49:28 2016 > New Revision: 261774 > > URL: http://llvm.org/viewvc/llvm-project?rev=261774&view=rev > Log: > Bail on compilation as soon as a job fails. > > Summary: > (Re-land of r260448, which was reverted in r260522 due to a test failure > in Driver/output-file-cleanup.c that only showed up in fresh builds.) > > Previously we attempted to be smart; if one job failed, we'd run all > jobs that didn't depend on the failing job. > > Problem is, this doesn't work well for e.g. CUDA compilation without > -save-temps. In this case, the device-side and host-side Assemble > actions (which actually are responsible for preprocess, compile, > backend, and assemble, since we're not saving temps) are necessarily > distinct. So our clever heuristic doesn't help us, and we repeat every > error message once for host and once for each device arch. > > The main effect of this change, other than fixing CUDA, is that if you > pass multiple cc files to one instance of clang and you get a compile > error, we'll stop when the first cc1 job fails. > > Reviewers: echristo > > Subscribers: cfe-commits, jhen, echristo, tra, rafael > > Differential Revision: http://reviews.llvm.org/D17217 > > Modified: > cfe/trunk/lib/Driver/Compilation.cpp > cfe/trunk/test/Driver/output-file-cleanup.c > > Modified: cfe/trunk/lib/Driver/Compilation.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=261774&r1=261773&r2=261774&view=diff > > == > --- cfe/trunk/lib/Driver/Compilation.cpp (original) > +++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 24 15:49:28 2016 > @@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Co >return ExecutionFailed ? 1 : Res; > } > > -typedef SmallVectorImpl< std::pair > > FailingCommandList; > - > -static bool ActionFailed(const Action *A, > - const FailingCommandList &FailingCommands) { > - > - if (FailingCommands.empty()) > -return false; > - > - for (FailingCommandList::const_iterator CI = FailingCommands.begin(), > - CE = FailingCommands.end(); CI != CE; ++CI) > -if (A == &(CI->second->getSource())) > - return true; > - > - for (const Action *AI : A->inputs()) > -if (ActionFailed(AI, FailingCommands)) > - return true; > - > - return false; > -} > - > -static bool InputsOk(const Command &C, > - const FailingCommandList &FailingCommands) { > - return !ActionFailed(&C.getSource(), FailingCommands); > -} > - > -void Compilation::ExecuteJobs(const JobList &Jobs, > - FailingCommandList &FailingCommands) const { > +void Compilation::ExecuteJobs( > +const JobList &Jobs, > +SmallVectorImpl> &FailingCommands) > const { >for (const auto &Job : Jobs) { > -if (!InputsOk(Job, FailingCommands)) > - continue; > const Command *FailingCommand = nullptr; > -if (int Res = ExecuteCommand(Job, FailingCommand)) > +if (int Res = ExecuteCommand(Job, FailingCommand)) { >FailingCommands.push_back(std::make_pair(Res, FailingCommand)); > + // Bail as soon as one command fails, so we don't output duplicate > error > + // messages if we die on e.g. the same file. > + return; > +} >} > } > > > Modified: cfe/trunk/test/Driver/output-file-cleanup.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/output-file-cleanup.c?rev=261774&r1=261773&r2=261774&view=diff > > == > --- cfe/trunk/test/Driver/output-file-cleanup.c (original) > +++ cfe/trunk/test/Driver/output-file-cleanup.c Wed Feb 24 15:49:28 2016 > @@ -38,6 +38,9 @@ invalid C code > // RUN: test -f %t1.s > // RUN: test ! -f %t2.s > > +// When given multiple .c files to compile, clang compiles them in order > until > +// it hits an error, at which point it stops. > +// > // RUN: touch %t1.c > // RUN: echo "invalid C code" > %t2.c > // RUN: touch %t3.c > @@ -46,6 +49,6 @@ invalid C code > // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c > // RUN: test -f %t1.s > // RUN: test ! -f %t2.s > -// RUN: test -f %t3.s > +// RUN: test ! -f %t3.s > // RUN: test ! -f %t4.s > -// RUN: test -f %t5.s > +// RUN: test ! -f %t5.s > > > ___ > 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-c
Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions
ariccio added a comment. In http://reviews.llvm.org/D17688#363835, @zaks.anna wrote: > The two underscores in the names are hard to read. Maybe we should just > prefix them with 'win'? I like that better, will change. http://reviews.llvm.org/D17688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions
ariccio updated this revision to Diff 49330. ariccio added a comment. Changed underscore prefixed variable names to `win` prefixed variable names. http://reviews.llvm.org/D17688 Files: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -169,11 +169,12 @@ { public: MallocChecker() - : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr), -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr), -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr), -II_kmalloc(nullptr), II_if_nameindex(nullptr), -II_if_freenameindex(nullptr) {} + : II_alloca(nullptr), II_winalloca(nullptr), II_malloc(nullptr), +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr), +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr), +II_strdup(nullptr), II_winstrdup(nullptr), II_kmalloc(nullptr), +II_if_nameindex(nullptr), II_if_freenameindex(nullptr), +II_wcsdup(nullptr), II_winwcsdup(nullptr) {} /// In pessimistic mode, the checker assumes that it does not know which /// functions might free the memory. @@ -231,10 +232,11 @@ mutable std::unique_ptr BT_MismatchedDealloc; mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds]; mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds]; - mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc, - *II_calloc, *II_valloc, *II_reallocf, *II_strndup, - *II_strdup, *II_kmalloc, *II_if_nameindex, - *II_if_freenameindex; + mutable IdentifierInfo *II_alloca, *II_winalloca, *II_malloc, *II_free, + *II_realloc, *II_calloc, *II_valloc, *II_reallocf, + *II_strndup, *II_strdup, *II_winstrdup, *II_kmalloc, + *II_if_nameindex, *II_if_freenameindex, *II_wcsdup, + *II_winwcsdup; mutable Optional KernelZeroFlagVal; void initIdentifierInfo(ASTContext &C) const; @@ -540,9 +542,15 @@ II_valloc = &Ctx.Idents.get("valloc"); II_strdup = &Ctx.Idents.get("strdup"); II_strndup = &Ctx.Idents.get("strndup"); + II_wcsdup = &Ctx.Idents.get("wcsdup"); II_kmalloc = &Ctx.Idents.get("kmalloc"); II_if_nameindex = &Ctx.Idents.get("if_nameindex"); II_if_freenameindex = &Ctx.Idents.get("if_freenameindex"); + + //MSVC uses `_`-prefixed instead, so we check for them too. + II_winstrdup = &Ctx.Idents.get("_strdup"); + II_winwcsdup = &Ctx.Idents.get("_wcsdup"); + II_winalloca = &Ctx.Idents.get("_alloca"); } bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) const { @@ -585,7 +593,8 @@ if (Family == AF_Malloc && CheckAlloc) { if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf || FunI == II_calloc || FunI == II_valloc || FunI == II_strdup || - FunI == II_strndup || FunI == II_kmalloc) + FunI == II_winstrdup || FunI == II_strndup || FunI == II_wcsdup || + FunI == II_winwcsdup || FunI == II_kmalloc) return true; } @@ -600,7 +609,7 @@ } if (Family == AF_Alloca && CheckAlloc) { - if (FunI == II_alloca) + if (FunI == II_alloca || FunI == II_winalloca) return true; } } @@ -789,11 +798,12 @@ State = ProcessZeroAllocation(C, CE, 1, State); } else if (FunI == II_free) { State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory); -} else if (FunI == II_strdup) { +} else if (FunI == II_strdup || FunI == II_winstrdup || + FunI == II_wcsdup || FunI == II_winwcsdup) { State = MallocUpdateRefState(C, CE, State); } else if (FunI == II_strndup) { State = MallocUpdateRefState(C, CE, State); -} else if (FunI == II_alloca) { +} else if (FunI == II_alloca || FunI == II_winalloca) { State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State, AF_Alloca); State = ProcessZeroAllocation(C, CE, 0, State); Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp === --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -169,11 +169,12 @@ { public: MallocChecker() - : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr), -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr), -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr), -II_kmalloc(nullptr), II_if_nameindex(nullptr), -II_if_freenameindex(nullptr) {} + : II_alloca(nullptr),
Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions
ariccio added a comment. //(This is mostly for my own reference)// BTW, there are a few other non-MS-only functions in the C standard library that allocate memory that needs to be free()d: 1. getcwd (and _getcwd/_wgetcwd) And some MS-specific functions that I'm surprised are actually MS-only: 1. _getdcwd/_wgetdcwd 2. _dupenv_s/_wdupenv_s 3. _fullpath/_wfullpath http://reviews.llvm.org/D17688 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17637: [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics
kbarton added a comment. This failed testing: Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 1 warning(s) in tests. Testing Time: 225.81s Failing Tests (1): Clang :: CodeGen/builtins-ppc-vsx.c Expected Passes: 25406 Expected Failures : 166 Unsupported Tests : 558 Unexpected Failures: 1 gmake[3]: *** [CMakeFiles/check-all] Error 1 gmake[2]: *** [CMakeFiles/check-all.dir/all] Error 2 gmake[1]: *** [CMakeFiles/check-all.dir/rule] Error 2 gmake: *** [check-all] Error 2 Test finished. Check results in /home/kbarton/llvm/build/dev.git/CHECK.log Tests PASSED! Reproduce with: llvm-lit tools/clang/test/CodeGen/builtins-ppc-vsx.c http://reviews.llvm.org/D17637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r261774 - Bail on compilation as soon as a job fails.
On Sun, Feb 28, 2016 at 1:46 PM, Nico Weber wrote: > Do you think something like the implicit inputs thing in > http://reviews.llvm.org/D17695 could work for you as well, instead of this > patch? Having read just the patch description, I think it would be workable, although it might not be particularly clean. I think you'd have to make most (all?) of the intermediate actions associated with a compilation be implicit inputs to all later actions in all other compilations. Otherwise things like saving vs. not saving temps would give you different behavior. It seems like kind of a fragile way to get this behavior. > Then we don't have to forever promise to compile all .cc input files > serially. I've thought about this some, since we don't really want this even for CUDA. With CUDA, you commonly want to compile the device code for different architectures, and it would be reasonable to do those compilations in parallel. What I think may be a reasonable promise, at least for CUDA, is that we will behave *as if* we're compiling in series. Which just means not interleaving diagnostics from different compilations, and not showing diagnostics from other subcompilations after we hit an error. I think basically nobody wants randomly-interleaved diagnostics. Whether or there's a good use-case where we continue after we hit an error is a harder question, I'm not sure. But in any case, stopping after an error shouldn't mean we're forced to serialize, I think. -Justin > On Wed, Feb 24, 2016 at 4:49 PM, Justin Lebar via cfe-commits > wrote: >> >> Author: jlebar >> Date: Wed Feb 24 15:49:28 2016 >> New Revision: 261774 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=261774&view=rev >> Log: >> Bail on compilation as soon as a job fails. >> >> Summary: >> (Re-land of r260448, which was reverted in r260522 due to a test failure >> in Driver/output-file-cleanup.c that only showed up in fresh builds.) >> >> Previously we attempted to be smart; if one job failed, we'd run all >> jobs that didn't depend on the failing job. >> >> Problem is, this doesn't work well for e.g. CUDA compilation without >> -save-temps. In this case, the device-side and host-side Assemble >> actions (which actually are responsible for preprocess, compile, >> backend, and assemble, since we're not saving temps) are necessarily >> distinct. So our clever heuristic doesn't help us, and we repeat every >> error message once for host and once for each device arch. >> >> The main effect of this change, other than fixing CUDA, is that if you >> pass multiple cc files to one instance of clang and you get a compile >> error, we'll stop when the first cc1 job fails. >> >> Reviewers: echristo >> >> Subscribers: cfe-commits, jhen, echristo, tra, rafael >> >> Differential Revision: http://reviews.llvm.org/D17217 >> >> Modified: >> cfe/trunk/lib/Driver/Compilation.cpp >> cfe/trunk/test/Driver/output-file-cleanup.c >> >> Modified: cfe/trunk/lib/Driver/Compilation.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=261774&r1=261773&r2=261774&view=diff >> >> == >> --- cfe/trunk/lib/Driver/Compilation.cpp (original) >> +++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 24 15:49:28 2016 >> @@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Co >>return ExecutionFailed ? 1 : Res; >> } >> >> -typedef SmallVectorImpl< std::pair > >> FailingCommandList; >> - >> -static bool ActionFailed(const Action *A, >> - const FailingCommandList &FailingCommands) { >> - >> - if (FailingCommands.empty()) >> -return false; >> - >> - for (FailingCommandList::const_iterator CI = FailingCommands.begin(), >> - CE = FailingCommands.end(); CI != CE; ++CI) >> -if (A == &(CI->second->getSource())) >> - return true; >> - >> - for (const Action *AI : A->inputs()) >> -if (ActionFailed(AI, FailingCommands)) >> - return true; >> - >> - return false; >> -} >> - >> -static bool InputsOk(const Command &C, >> - const FailingCommandList &FailingCommands) { >> - return !ActionFailed(&C.getSource(), FailingCommands); >> -} >> - >> -void Compilation::ExecuteJobs(const JobList &Jobs, >> - FailingCommandList &FailingCommands) const >> { >> +void Compilation::ExecuteJobs( >> +const JobList &Jobs, >> +SmallVectorImpl> &FailingCommands) >> const { >>for (const auto &Job : Jobs) { >> -if (!InputsOk(Job, FailingCommands)) >> - continue; >> const Command *FailingCommand = nullptr; >> -if (int Res = ExecuteCommand(Job, FailingCommand)) >> +if (int Res = ExecuteCommand(Job, FailingCommand)) { >>FailingCommands.push_back(std::make_pair(Res, FailingCommand)); >> + // Bail as soon as one command fails, so we don't output duplicate >> error >> + // messages if we die on e.g. the same file. >> + return; >> +} >
Re: [PATCH] D15643: [clang-format] Don't allow newline after uppercase Obj-C block return types
ksuther added a comment. This patch got buried, giving it a bump to see if anyone can take a look at it. http://reviews.llvm.org/D15643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching
sfantao updated this revision to Diff 49331. sfantao marked an inline comment as done. sfantao added a comment. Emit num teams and thread limit using the inlined directives machinery. http://reviews.llvm.org/D17019 Files: lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h test/OpenMP/teams_codegen.cpp Index: test/OpenMP/teams_codegen.cpp === --- /dev/null +++ test/OpenMP/teams_codegen.cpp @@ -0,0 +1,194 @@ +// expected-no-diagnostics +#ifndef HEADER +#define HEADER +// Test host codegen. +// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 +// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64 +// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 +// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32 +#ifdef CK1 + +int Gbla; +long long Gblb; + +// CK1-LABEL: teams_argument_global_local +int teams_argument_global_local(int a){ + int comp = 1; + + int la = 23; + float lc = 25.0; + + // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0) + // CK1: call void @{{.+}}(i{{64|32}} %{{.+}}) + #pragma omp target + #pragma omp teams + { +++comp; + } + + // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0) + // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]], + + // CK1: call void @{{.+}}(i{{64|32}} %{{.+}}) + #pragma omp target + #pragma omp teams num_teams(la) + { +++comp; + } + + // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 [[NT:%[^,]+]]) + // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]], + + // CK1: call void @{{.+}}(i{{64|32}} %{{.+}}) + #pragma omp target + #pragma omp teams thread_limit(la) + { +++comp; + } + + // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 5, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 [[TL:%[^,]+]]) + + // CK1-DAG: [[NT]] = add nsw i32 [[NTA:%[^,]+]], [[NTB:%[^,]+]] + // CK1-DAG: [[NTA]] = load i32, i32* @Gbla, + // CK1-DAG: [[NTB]] = load i32, i32* %{{.+}}, + + // CK1-DAG: [[TL]] = trunc i64 [[TLA:%[^,]+]] to i32 + // CK1-DAG: [[TLA]] = add nsw i64 [[TLB:%[^,]+]], [[TLC:%[^,]+]] + // CK1-DAG: [[TLC]] = fptosi float [[TLD:%[^,]+]] to i64 + // CK1-DAG: [[TLD]] = load float, float* %{{.+}}, + // CK1-DAG: [[TLB]] = load i64, i64* @Gblb, + + // CK1: call void @{{.+}}(i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}, i{{.+}} {{.+}}) + #pragma omp target + #pragma omp teams num_teams(Gbla+a) thread_limit(Gblb+(long long)lc) + { +++comp; + } + + return comp; +} + +#endif // CK1 + +// Test host codegen. +// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 +// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64 +// RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32 +// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s +// RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=
Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching
sfantao added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:4002 @@ +4001,3 @@ +static llvm::Value * +emitNumTeamsClauseForTargetDirective(CodeGenFunction &CGF, + const OMPExecutableDirective &D, ABataev wrote: > I still don't like the generation of some functions, that, generally > speaking, are not required. > Could you try to add a new 'class CGOpenMPInlinedRegionInfo' like class, that > will be able to handle not captured variables in expressions? Ok. In the the new diff I am using the logic for emission of inlined regions for num teams and thread limit as well. I still had to add extra logic in CodeGenFunction to insert extra entries in the local declaration cache, given that, as I discussed above, target regions make captured global variables local. Hope this is aligned with what you have in mind. Thanks! http://reviews.llvm.org/D17019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D9237: Update block formatting to behave like Xcode
tonyarnold added a comment. @djasper so was the decision here to not merge these options? I think it's fair that you require a documented style guide somewhere (which Apple don't currently publish), however it would be good to at least have generic options in clang-format that allow us to replicate the unpublished style, even without official support in the tool. What do we need to do to get support for options like `ObjCAvoidLineBreaksForInlineBlocks` and `ObjCLeftAlignMultipleBlocks` into clang-format? There are potentially one or two more options around dictionary/array literal alignment/newlines that I'd like to add — but I'm not going to spend any time drawing up PRs if there's no way they'll ever be merged. http://reviews.llvm.org/D9237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting
ksuther created this revision. ksuther added a reviewer: djasper. ksuther added a subscriber: cfe-commits. Herald added a subscriber: klimek. Changes to clang-format's Objective-C block formatting over the past year have made clang-format's output deviate from what is expected (in my opinion). There are three changes in particular: - Method calls with multiple block parameters has each block indented further in - Nested blocks get indented one level in - Method calls that end with a block parameter always get forced to a new line and indented The end of this message has examples of formatting with and without these changes. This patch undoes one revision which causes methods with multiple block parameters to indent for each parameter (r236598) and adds two new options. AllowNewlineBeforeBlockParameter makes the change in r235580 optional. IndentNestedBlocks makes the change in r234304 optional. Some relevant Bugzilla issues: https://llvm.org/bugs/show_bug.cgi?id=23585 https://llvm.org/bugs/show_bug.cgi?id=23317 This patch came out of a discussion here https://github.com/square/spacecommander/issues/33, where we're using a custom version of clang-format with these options added. Based on the Bugzilla issues, it seems that we're not alone. Thanks! --- Current trunk: bin/clang-format -style="{BasedOnStyle: WebKit, ColumnLimit: 0, IndentWidth: 4}" ~/clang-format.m ``` - (void)test { [self block:^(void) { doStuff(); } completionHandler:^(void) { doStuff(); [self block:^(void) { doStuff(); } completionHandler:^(void) { doStuff(); }]; }]; [[SessionService sharedService] loadWindow:aWindow completionBlock:^(SessionWindow* window) { if (window) { [self doStuff]; } }]; } ``` With this patch applied: bin/clang-format -style="{BasedOnStyle: WebKit, ColumnLimit: 0, IndentWidth: 4, IndentNestedBlocks: false, AllowNewlineBeforeBlockParameter: false}"~/clang-format.m ``` - (void)test { [self block:^(void) { doStuff(); } completionHandler:^(void) { doStuff(); [self block:^(void) { doStuff(); } completionHandler:^(void) { doStuff(); }]; }]; [[SessionService sharedService] loadWindow:aWindow completionBlock:^(SessionWindow* window) { if (window) { [self doStuff]; } }]; } ``` http://reviews.llvm.org/D17700 Files: include/clang/Format/Format.h lib/Format/ContinuationIndenter.cpp lib/Format/Format.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7606,13 +7606,6 @@ " aaa | aaa | aaa |\n" " aaa | aaa];"); - // FIXME: This violates the column limit. - verifyFormat( - "[a\n" - "a:\n" - " aaa:a];", - getLLVMStyleWithColumns(60)); - // Variadic parameters. verifyFormat( "NSArray *myStrings = [NSArray stringarray:@\"a\", @\"b\", nil];"); Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -296,6 +296,10 @@ IO.mapOptional("IndentWidth", Style.IndentWidth); IO.mapOptional("IndentWrappedFunctionNames", Style.IndentWrappedFunctionNames); +IO.mapOptional("IndentNestedBlocks", + Style.IndentNestedBlocks); +IO.mapOptional("AllowNewlineBeforeBlockParameter", + Style.AllowNewlineBeforeBlockParameter); IO.mapOptional("KeepEmptyLinesAtTheStartOfBlocks", Style.KeepEmptyLinesAtTheStartOfBlocks); IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin); @@ -510,6 +514,8 @@ {".*", 1}}; LLVMStyle.IndentCaseLabels = false; LLVMStyle.IndentWrappedFunctionNames = false; + LLVMStyle.IndentNestedBlocks = true; + LLVMStyle.AllowNewlineBeforeBlockParameter = true; LLVMStyle.IndentWidth = 2; LLVMStyle.TabWidth = 8; LLVMStyle.MaxEmptyLinesToKeep = 1; Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -178,9 +178,6 @@ ((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) || Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 0)) return true; - if (Cu
r262197 - [clang-cl] /EHc should not have an effect on /EHa
Author: majnemer Date: Sun Feb 28 19:40:30 2016 New Revision: 262197 URL: http://llvm.org/viewvc/llvm-project?rev=262197&view=rev Log: [clang-cl] /EHc should not have an effect on /EHa This matches behavior with MSVC. Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/cl-eh.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=262197&r1=262196&r2=262197&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Sun Feb 28 19:40:30 2016 @@ -5829,12 +5829,16 @@ static EHFlags parseClangCLEHFlags(const switch (EHVal[I]) { case 'a': EH.Asynch = maybeConsumeDash(EHVal, I); +if (EH.Asynch) + EH.Synch = false; continue; case 'c': EH.NoUnwindC = maybeConsumeDash(EHVal, I); continue; case 's': EH.Synch = maybeConsumeDash(EHVal, I); +if (EH.Synch) + EH.Asynch = false; continue; default: break; @@ -5932,7 +5936,7 @@ void Clang::AddClangCLArgs(const ArgList if (EH.Synch || EH.Asynch) { CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); -if (EH.NoUnwindC) +if (EH.Synch && EH.NoUnwindC) CmdArgs.push_back("-fexternc-nounwind"); } Modified: cfe/trunk/test/Driver/cl-eh.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-eh.cpp?rev=262197&r1=262196&r2=262197&view=diff == --- cfe/trunk/test/Driver/cl-eh.cpp (original) +++ cfe/trunk/test/Driver/cl-eh.cpp Sun Feb 28 19:40:30 2016 @@ -21,6 +21,11 @@ // EHs_EHa: "-fcxx-exceptions" // EHs_EHa: "-fexceptions" +// RUN: %clang_cl /c /EHa /EHc -### -- %s 2>&1 | FileCheck -check-prefix=EHa_EHc %s +// EHa_EHc: "-fcxx-exceptions" +// EHa_EHc: "-fexceptions" +// EHa_EHc-NOT: "-fexternc-nounwind" + // RUN: %clang_cl /c /EHinvalid -### -- %s 2>&1 | FileCheck -check-prefix=EHinvalid %s // EHinvalid: error: invalid value 'invalid' in '/EH' // EHinvalid-NOT: error: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r262198 - [clang-cl] /EHc should not effect functions with explicit exception specifications
Author: majnemer Date: Sun Feb 28 19:40:36 2016 New Revision: 262198 URL: http://llvm.org/viewvc/llvm-project?rev=262198&view=rev Log: [clang-cl] /EHc should not effect functions with explicit exception specifications Functions with an explicit exception specification have their behavior dictated by the specification. The additional /EHc behavior only comes into play if no exception specification is given. Modified: cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Driver/Tools.h cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=262198&r1=262197&r2=262198&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Sun Feb 28 19:40:36 2016 @@ -4119,8 +4119,9 @@ void Clang::ConstructJob(Compilation &C, bool EmitCodeView = false; // Add clang-cl arguments. + types::ID InputType = Input.getType(); if (getToolChain().getDriver().IsCLMode()) -AddClangCLArgs(Args, CmdArgs, &DebugInfoKind, &EmitCodeView); +AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); // Pass the linker version in use. if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) { @@ -4133,7 +4134,6 @@ void Clang::ConstructJob(Compilation &C, // Explicitly error on some things we know we don't support and can't just // ignore. - types::ID InputType = Input.getType(); if (!Args.hasArg(options::OPT_fallow_unsupported)) { Arg *Unsupported; if (types::isCXX(InputType) && getToolChain().getTriple().isOSDarwin() && @@ -5859,7 +5859,8 @@ static EHFlags parseClangCLEHFlags(const return EH; } -void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs, +void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, + ArgStringList &CmdArgs, codegenoptions::DebugInfoKind *DebugInfoKind, bool *EmitCodeView) const { unsigned RTOptionID = options::OPT__SLASH_MT; @@ -5934,11 +5935,12 @@ void Clang::AddClangCLArgs(const ArgList const Driver &D = getToolChain().getDriver(); EHFlags EH = parseClangCLEHFlags(D, Args); if (EH.Synch || EH.Asynch) { -CmdArgs.push_back("-fcxx-exceptions"); +if (types::isCXX(InputType)) + CmdArgs.push_back("-fcxx-exceptions"); CmdArgs.push_back("-fexceptions"); -if (EH.Synch && EH.NoUnwindC) - CmdArgs.push_back("-fexternc-nounwind"); } + if (types::isCXX(InputType) && EH.Synch && EH.NoUnwindC) +CmdArgs.push_back("-fexternc-nounwind"); // /EP should expand to -E -P. if (Args.hasArg(options::OPT__SLASH_EP)) { Modified: cfe/trunk/lib/Driver/Tools.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=262198&r1=262197&r2=262198&view=diff == --- cfe/trunk/lib/Driver/Tools.h (original) +++ cfe/trunk/lib/Driver/Tools.h Sun Feb 28 19:40:36 2016 @@ -91,7 +91,7 @@ private: llvm::opt::ArgStringList &cmdArgs, RewriteKind rewrite) const; - void AddClangCLArgs(const llvm::opt::ArgList &Args, + void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType, llvm::opt::ArgStringList &CmdArgs, codegenoptions::DebugInfoKind *DebugInfoKind, bool *EmitCodeView) const; Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=262198&r1=262197&r2=262198&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Feb 28 19:40:36 2016 @@ -11635,8 +11635,11 @@ void Sema::AddKnownFunctionAttributes(Fu // throw, add an implicit nothrow attribute to any extern "C" function we come // across. if (getLangOpts().CXXExceptions && getLangOpts().ExternCNoUnwind && - FD->isExternC() && !FD->hasAttr()) -FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation())); + FD->isExternC() && !FD->hasAttr()) { +const auto *FPT = FD->getType()->getAs(); +if (!FPT || FPT->getExceptionSpecType() == EST_None) + FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation())); + } IdentifierInfo *Name = FD->getIdentifier(); if (!Name) Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp?rev=262198&r1=262197&r2=262198&view=diff == --- cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp (origin
Re: [PATCH] D13704: [Fix] Allow implicit conversions of the address of overloadable functions in C + docs update
george.burgess.iv updated this revision to Diff 49333. george.burgess.iv added a comment. Rebased, and narrowed the scope of the patch a bit. http://reviews.llvm.org/D13704 Files: include/clang/Basic/AttrDocs.td lib/Sema/SemaOverload.cpp test/CodeGen/overloadable.c test/Sema/overloadable.c test/Sema/pass-object-size.c Index: test/Sema/pass-object-size.c === --- test/Sema/pass-object-size.c +++ test/Sema/pass-object-size.c @@ -38,8 +38,8 @@ void (*p)(void *) = NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}} void (*p2)(void *) = &NotOverloaded; //expected-error{{cannot take address of function 'NotOverloaded' because parameter 1 has pass_object_size attribute}} - void (*p3)(void *) = IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type ''}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}} - void (*p4)(void *) = &IsOverloaded; //expected-error{{initializing 'void (*)(void *)' with an expression of incompatible type ''}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}} + void (*p3)(void *) = IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type ''}} expected-note@-6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-5{{type mismatch}} + void (*p4)(void *) = &IsOverloaded; //expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type ''}} expected-note@-7{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@-6{{type mismatch}} void (*p5)(char *) = IsOverloaded; void (*p6)(char *) = &IsOverloaded; Index: test/Sema/overloadable.c === --- test/Sema/overloadable.c +++ test/Sema/overloadable.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wincompatible-pointer-types int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}} void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}} @@ -99,3 +99,26 @@ unsigned char *c; multi_type(c); } + +// Ensure that we allow C-specific type conversions in C +void fn_type_conversions() { + void foo(void *c) __attribute__((overloadable)); + void foo(char *c) __attribute__((overloadable)); + void (*ptr1)(void *) = &foo; + void (*ptr2)(char *) = &foo; + void (*ambiguous)(int *) = &foo; // expected-error{{initializing 'void (*)(int *)' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}} + void *vp_ambiguous = &foo; // expected-error{{initializing 'void *' with an expression of incompatible type ''}} expected-note@105{{candidate function}} expected-note@106{{candidate function}} + + void (*specific1)(int *) = (void (*)(void *))&foo; // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type 'void (*)(void *)'}} + void *specific2 = (void (*)(void *))&foo; + + void disabled(void *c) __attribute__((overloadable, enable_if(0, ""))); + void disabled(int *c) __attribute__((overloadable, enable_if(c, ""))); + void disabled(char *c) __attribute__((overloadable, enable_if(1, "The function name lies."))); + // To be clear, these should all point to the last overload of 'disabled' + void (*dptr1)(char *c) = &disabled; + void (*dptr2)(void *c) = &disabled; // expected-warning{{incompatible pointer types initializing 'void (*)(void *)' with an expression of type ''}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate function made ineligible by enable_if}} expected-note@117{{candidate function has type mismatch at 1st parameter (expected 'void *' but has 'char *')}} + void (*dptr3)(int *c) = &disabled; // expected-warning{{incompatible pointer types initializing 'void (*)(int *)' with an expression of type ''}} expected-note@115{{candidate function made ineligible by enable_if}} expected-note@116{{candidate function made ineligible by enable_if}} expected-note@117{{candidate function has type mismatch at 1st parameter (expected 'int *' but has 'char *')}} + + void *specific_disabled = &disabled; +} Index: test/CodeGen/overloadable.c === --- test/CodeGen/overloadable.c +++ test/CodeGen/overloadable.c @@ -29,3 +29,33 @@ cdv = f(cdv); vv = f(vv); } + +// Ensuring that we pick the correct functi
[PATCH] D17701: [Sema] Teach SemaCast to allow reinterpret_casts of overloaded functions with only one addressable candidate
george.burgess.iv created this revision. george.burgess.iv added a reviewer: rsmith. george.burgess.iv added a subscriber: cfe-commits. Given the following declarations for `foo`: ``` void foo(int a); void foo(int a) __attribute__((enable_if(a, ""))); ``` ...The only way to `reinterpret_cast` `foo` is to insert two casts: ``` auto fnptr = reinterpret_cast((void (*)(int))foo); ``` ...Which isn't quite ideal. This patch teaches clang to check to see if an overload set has only one candidate that can have its address taken. If this is the case, then we'll use it automatically. (As a side note: we use a custom loop rather than modifying `AddressOfFunctionResolver` because we don't need to do any kind of ranking, and there seem to be some cases where `AddressOfFunctionResolver` will disqualify candidates, which we don't really want here. I can fold this logic into `AddressOfFunctionResolver` if we want to potentially have less code duplication, but I feel this is straightforward enough that it can stand on its own, rather than adding complexity to `AddressOfFunctionResolver`). http://reviews.llvm.org/D17701 Files: include/clang/Sema/Sema.h lib/Sema/SemaCast.cpp lib/Sema/SemaOverload.cpp test/SemaCXX/enable_if.cpp test/SemaCXX/unaddressable-functions.cpp Index: test/SemaCXX/unaddressable-functions.cpp === --- /dev/null +++ test/SemaCXX/unaddressable-functions.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 + +namespace access_control { +class Private { + void check(int *) __attribute__((enable_if(false, ""))); + void check(double *) __attribute__((enable_if(true, ""))); + + static void checkStatic(int *) __attribute__((enable_if(false, ""))); + static void checkStatic(double *) __attribute__((enable_if(true, ""))); +}; + +auto Priv = reinterpret_cast(&Private::check); // expected-error{{'check' is a private member of 'access_control::Private'}} expected-note@6{{implicitly declared private here}} + +auto PrivStatic = reinterpret_cast(&Private::checkStatic); // expected-error{{'checkStatic' is a private member of 'access_control::Private'}} expected-note@9{{implicitly declared private here}} + +class Protected { +protected: + void check(int *) __attribute__((enable_if(false, ""))); + void check(double *) __attribute__((enable_if(true, ""))); + + static void checkStatic(int *) __attribute__((enable_if(false, ""))); + static void checkStatic(double *) __attribute__((enable_if(true, ""))); +}; + +auto Prot = reinterpret_cast(&Protected::check); // expected-error{{'check' is a protected member of 'access_control::Protected'}} expected-note@19{{declared protected here}} + +auto ProtStatic = reinterpret_cast(&Protected::checkStatic); // expected-error{{'checkStatic' is a protected member of 'access_control::Protected'}} expected-note@22{{declared protected here}} +} Index: test/SemaCXX/enable_if.cpp === --- test/SemaCXX/enable_if.cpp +++ test/SemaCXX/enable_if.cpp @@ -253,3 +253,96 @@ a = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}} } } + +namespace casting { +using VoidFnTy = void (*)(); + +void foo(void *c) __attribute__((enable_if(0, ""))); +void foo(int *c) __attribute__((enable_if(c, ""))); +void foo(char *c) __attribute__((enable_if(1, ""))); + +void testIt() { + auto A = reinterpret_cast(foo); + auto AAmp = reinterpret_cast(&foo); + + using VoidFooTy = void (*)(void *); + auto B = reinterpret_cast(foo); + auto BAmp = reinterpret_cast(&foo); + + using IntFooTy = void (*)(int *); + auto C = reinterpret_cast(foo); + auto CAmp = reinterpret_cast(&foo); + + using CharFooTy = void (*)(void *); + auto D = reinterpret_cast(foo); + auto DAmp = reinterpret_cast(&foo); +} + +void testItCStyle() { + auto A = (VoidFnTy)foo; + auto AAmp = (VoidFnTy)&foo; + + using VoidFooTy = void (*)(void *); + auto B = (VoidFooTy)foo; + auto BAmp = (VoidFooTy)&foo; + + using IntFooTy = void (*)(int *); + auto C = (IntFooTy)foo; + auto CAmp = (IntFooTy)&foo; + + using CharFooTy = void (*)(void *); + auto D = (CharFooTy)foo; + auto DAmp = (CharFooTy)&foo; +} +} + +namespace casting_templates { +template void foo(T) {} // expected-note 4 {{candidate function}} + +void foo(int *c) __attribute__((enable_if(c, ""))); //expected-note 4 {{candidate function}} +void foo(char *c) __attribute__((enable_if(c, ""))); //expected-note 4 {{candidate function}} + +void testIt() { + using IntFooTy = void (*)(int *); + auto A = reinterpret_cast(foo); // expected-error{{reinterpret_cast cannot resolve overloaded function 'foo' to type}} + auto ARef = reinterpret_cast(&foo); // expected-error{{reinterpret_cast cannot resolve overloaded function 'foo' to type}} + auto AExplicit = reinterpret_cast(foo); + + using CharFooTy = void
Re: [PATCH] D15591: [Bugfix] Make type deduction work more nicely with unaddressable functions
george.burgess.iv updated this revision to Diff 49337. george.burgess.iv added a comment. - Rebased - Added tests for template type inference - Updated to use machinery introduced by http://reviews.llvm.org/D17701 http://reviews.llvm.org/D15591 Files: lib/Sema/SemaTemplateDeduction.cpp test/SemaCXX/unaddressable-functions.cpp Index: test/SemaCXX/unaddressable-functions.cpp === --- test/SemaCXX/unaddressable-functions.cpp +++ test/SemaCXX/unaddressable-functions.cpp @@ -26,3 +26,69 @@ auto ProtStatic = reinterpret_cast(&Protected::checkStatic); // expected-error{{'checkStatic' is a protected member of 'access_control::Protected'}} expected-note@22{{declared protected here}} } + +namespace template_deduction { +void foo() __attribute__((enable_if(false, ""))); + +void bar() __attribute__((enable_if(true, ""))); +void bar() __attribute__((enable_if(false, ""))); + +void baz(int a) __attribute__((enable_if(true, ""))); +void baz(int a) __attribute__((enable_if(a, ""))); +void baz(int a) __attribute__((enable_if(false, ""))); + +void qux(int a) __attribute__((enable_if(1, ""))); +void qux(int a) __attribute__((enable_if(true, ""))); +void qux(int a) __attribute__((enable_if(a, ""))); +void qux(int a) __attribute__((enable_if(false, ""))); + +template void call(Fn F, Args... As) { + F(As...); +} + +void test() { + call(foo); // expected-error{{cannot take address of function 'foo'}} + call(bar); + call(baz, 0); + call(qux, 0); // expected-error{{no matching function for call to 'call'}} expected-note@45{{candidate template ignored: couldn't infer template argument 'Fn'}} + + auto Ptr1 = foo; // expected-error{{cannot take address of function 'foo'}} + auto Ptr2 = bar; + auto Ptr3 = baz; + auto Ptr4 = qux; // expected-error{{variable 'Ptr4' with type 'auto' has incompatible initializer of type ''}} +} + +template +void callMem(Fn F, T t, Args... As) { + (t.*F)(As...); +} + +class Foo { + void bar() __attribute__((enable_if(true, ""))); + void bar() __attribute__((enable_if(false, ""))); + + static void staticBar() __attribute__((enable_if(true, ""))); + static void staticBar() __attribute__((enable_if(false, ""))); +}; + +void testAccess() { + callMem(&Foo::bar, Foo()); // expected-error{{'bar' is a private member of 'template_deduction::Foo'}} expected-note@-8{{implicitly declared private here}} + call(&Foo::staticBar); // expected-error{{'staticBar' is a private member of 'template_deduction::Foo'}} expected-note@-6{{implicitly declared private here}} +} +} + +namespace template_template_deduction { +void foo() __attribute__((enable_if(false, ""))); +template +T foo() __attribute__((enable_if(true, ""))); + +template auto call(Fn F, Args... As) { + return F(As...); +} + +auto Ok = call(&foo); +auto Fail = call(&foo); // expected-error{{no matching function for call to 'call'}} expected-note@-5{{candidate template ignored: couldn't infer template argument 'Fn'}} + +auto PtrOk = &foo; +auto PtrFail = &foo; // expected-error{{variable 'PtrFail' with type 'auto' has incompatible initializer of type ''}} +} Index: lib/Sema/SemaTemplateDeduction.cpp === --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -3010,6 +3010,11 @@ return GetTypeOfFunction(S, R, ExplicitSpec); } +DeclAccessPair DAP; +if (FunctionDecl *Viable = +S.resolveAddressOfOnlyViableOverloadCandidate(Arg, DAP)) + return GetTypeOfFunction(S, R, Viable); + return QualType(); } Index: test/SemaCXX/unaddressable-functions.cpp === --- test/SemaCXX/unaddressable-functions.cpp +++ test/SemaCXX/unaddressable-functions.cpp @@ -26,3 +26,69 @@ auto ProtStatic = reinterpret_cast(&Protected::checkStatic); // expected-error{{'checkStatic' is a protected member of 'access_control::Protected'}} expected-note@22{{declared protected here}} } + +namespace template_deduction { +void foo() __attribute__((enable_if(false, ""))); + +void bar() __attribute__((enable_if(true, ""))); +void bar() __attribute__((enable_if(false, ""))); + +void baz(int a) __attribute__((enable_if(true, ""))); +void baz(int a) __attribute__((enable_if(a, ""))); +void baz(int a) __attribute__((enable_if(false, ""))); + +void qux(int a) __attribute__((enable_if(1, ""))); +void qux(int a) __attribute__((enable_if(true, ""))); +void qux(int a) __attribute__((enable_if(a, ""))); +void qux(int a) __attribute__((enable_if(false, ""))); + +template void call(Fn F, Args... As) { + F(As...); +} + +void test() { + call(foo); // expected-error{{cannot take address of function 'foo'}} + call(bar); + call(baz, 0); + call(qux, 0); // expected-error{{no matching function for call to 'call'}} expected-note@45{{candidate template ignored: couldn't infer template argument 'Fn'}} + + auto Ptr1
Re: [PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting
tonyarnold added a comment. Aside from the lack of tests, and `AllowNewlineBeforeBlockParameter` being outside of `BraceWrapping`, this is good! Much closer to how Apple's documentation and Xcode format blocks! 👍 Comment at: include/clang/Format/Format.h:421 @@ +420,3 @@ + /// \brief If true, allow newlines before block parameters when ColumnLimit is 0. + bool AllowNewlineBeforeBlockParameter; + Perhaps this would be better placed within the custom `BraceWrapping` options? Something simpler like `BeforeBlockParameter`. http://reviews.llvm.org/D17700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting
tonyarnold added a comment. I did find one bug though — if there's any parameters in between the two blocks, they'll end up forcing a newline: objective-c @implementation SomeClass - (void)test { [sharedController passingTest:^BOOL(id application) { return application.thing; } withTimeout:kTimeout completionHandler:^(BOOL success, NSError *error) { if (success == NO && error != nil) { // Do the thing } }]; } } @end Wrongly becomes: objective-c @implementation SomeClass - (void)test { [sharedController passingTest:^BOOL(id application) { return application.thing; } withTimeout:kTimeout completionHandler:^(BOOL success, NSError *error) { if (success == NO && error != nil) { // Do the thing } }]; } } @end http://reviews.llvm.org/D17700 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r262199 - [OPENMP 4.5] Initial support for data members in 'reduction' clauses.
Author: abataev Date: Sun Feb 28 23:54:20 2016 New Revision: 262199 URL: http://llvm.org/viewvc/llvm-project?rev=262199&view=rev Log: [OPENMP 4.5] Initial support for data members in 'reduction' clauses. OpenMP 4.5 allows to privatize non-static data members of current class in non-static member functions. Patch adds initial parsing/semantic analysis for data members support in 'reduction' clauses. Modified: cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/parallel_ast_print.cpp Modified: cfe/trunk/lib/AST/StmtPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=262199&r1=262198&r2=262199&view=diff == --- cfe/trunk/lib/AST/StmtPrinter.cpp (original) +++ cfe/trunk/lib/AST/StmtPrinter.cpp Sun Feb 28 23:54:20 2016 @@ -666,14 +666,7 @@ void OMPClausePrinter::VisitOMPScheduleC OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind()); if (auto *E = Node->getChunkSize()) { OS << ", "; -if (Node->getPreInitStmt()) { - cast( - cast(E->IgnoreImpCasts())->getDecl()) - ->getInit() - ->IgnoreImpCasts() - ->printPretty(OS, nullptr, Policy); -} else - E->printPretty(OS, nullptr, Policy); +E->printPretty(OS, nullptr, Policy); } OS << ")"; } @@ -775,8 +768,8 @@ void OMPClausePrinter::VisitOMPClauseLis assert(*I && "Expected non-null Stmt"); OS << (I == Node->varlist_begin() ? StartSym : ','); if (DeclRefExpr *DRE = dyn_cast(*I)) { - if (auto *CED = dyn_cast(DRE->getDecl())) -CED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy, 0); + if (isa(DRE->getDecl())) +DRE->printPretty(OS, nullptr, Policy, 0); else DRE->getDecl()->printQualifiedName(OS); } else @@ -924,14 +917,7 @@ void OMPClausePrinter::VisitOMPDistSched OMPC_dist_schedule, Node->getDistScheduleKind()); if (auto *E = Node->getChunkSize()) { OS << ", "; -if (Node->getPreInitStmt()) { - cast( - cast(E->IgnoreImpCasts())->getDecl()) - ->getInit() - ->IgnoreImpCasts() - ->printPretty(OS, nullptr, Policy); -} else - E->printPretty(OS, nullptr, Policy); +E->printPretty(OS, nullptr, Policy); } OS << ")"; } @@ -1150,6 +1136,10 @@ void StmtPrinter::VisitOMPDistributeDire //===--===// void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { + if (auto *OCED = dyn_cast(Node->getDecl())) { +OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy); +return; + } if (NestedNameSpecifier *Qualifier = Node->getQualifier()) Qualifier->print(OS, Policy); if (Node->hasTemplateKeyword()) Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=262199&r1=262198&r2=262199&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Sun Feb 28 23:54:20 2016 @@ -7096,27 +7096,60 @@ ExprResult Sema::getOpenMPCapturedExpr(V return Res; } -static std::pair getPrivateItem(Sema &S, Expr *RefExpr) { +static std::pair +getPrivateItem(Sema &S, Expr *&RefExpr, SourceLocation &ELoc, + SourceRange &ERange, bool AllowArraySection = false) { if (RefExpr->isTypeDependent() || RefExpr->isValueDependent() || RefExpr->containsUnexpandedParameterPack()) return std::make_pair(nullptr, true); - SourceLocation ELoc = RefExpr->getExprLoc(); - SourceRange SR = RefExpr->getSourceRange(); // OpenMP [3.1, C/C++] // A list item is a variable name. // OpenMP [2.9.3.3, Restrictions, p.1] // A variable that is part of another variable (as an array or // structure element) cannot appear in a private clause. RefExpr = RefExpr->IgnoreParens(); + enum { +NoArrayExpr = -1, +ArraySubscript = 0, +OMPArraySection = 1 + } IsArrayExpr = NoArrayExpr; + if (AllowArraySection) { +if (auto *ASE = dyn_cast_or_null(RefExpr)) { + auto *Base = ASE->getBase()->IgnoreParenImpCasts(); + while (auto *TempASE = dyn_cast(Base)) +Base = TempASE->getBase()->IgnoreParenImpCasts(); + RefExpr = Base; + IsArrayExpr = ArraySubscript; +} else if (auto *OASE = dyn_cast_or_null(RefExpr)) { + auto *Base = OASE->getBase()->IgnoreParenImpCasts(); + while (auto *TempOASE = dyn_cast(Base)) +Base = TempOASE->getBase()->IgnoreParenImpCasts(); + while (auto *TempASE = dyn_cast(Base)) +Base = TempASE->getBase()->IgnoreParenImpCasts(); + RefExpr = Base; + IsArrayExpr = OMPArraySection; +} + } + ELoc = RefExpr->getExprLoc(); + ERange = RefExpr->getSourceRange(); + RefExpr = RefExpr->Ignore
r262200 - [X86] Enabling xsave should not enable AVX. I seem to have done this, but I don't know why.
Author: ctopper Date: Mon Feb 29 00:51:34 2016 New Revision: 262200 URL: http://llvm.org/viewvc/llvm-project?rev=262200&view=rev Log: [X86] Enabling xsave should not enable AVX. I seem to have done this, but I don't know why. Modified: cfe/trunk/lib/Basic/Targets.cpp Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262200&r1=262199&r2=262200&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 29 00:51:34 2016 @@ -3018,15 +3018,11 @@ void X86TargetInfo::setFeatureEnabledImp else setSSELevel(Features, SSE41, Enabled); } else if (Name == "xsave") { -if (Enabled) - setSSELevel(Features, AVX, Enabled); -else +if (!Enabled) Features["xsaveopt"] = false; } else if (Name == "xsaveopt" || Name == "xsavec" || Name == "xsaves") { -if (Enabled) { +if (Enabled) Features["xsave"] = true; - setSSELevel(Features, AVX, Enabled); -} } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r262201 - [X86] Disabling avx512f should also disable avx512vbmi and avx512ifma. Enabling avx512vbmi or avx512ifma should enable avx512f. Add command line switches and header defines for avx512ifma an
Author: ctopper Date: Mon Feb 29 00:51:38 2016 New Revision: 262201 URL: http://llvm.org/viewvc/llvm-project?rev=262201&view=rev Log: [X86] Disabling avx512f should also disable avx512vbmi and avx512ifma. Enabling avx512vbmi or avx512ifma should enable avx512f. Add command line switches and header defines for avx512ifma and avx512vbmi. Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGen/attr-target-x86.c cfe/trunk/test/Preprocessor/predefined-arch-macros.c cfe/trunk/test/Preprocessor/x86_target_features.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262201&r1=262200&r2=262201&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 29 00:51:38 2016 @@ -1366,6 +1366,8 @@ def mno_avx512pf : Flag<["-"], "mno-avx5 def mno_avx512dq : Flag<["-"], "mno-avx512dq">, Group; def mno_avx512bw : Flag<["-"], "mno-avx512bw">, Group; def mno_avx512vl : Flag<["-"], "mno-avx512vl">, Group; +def mno_avx512vbmi : Flag<["-"], "mno-avx512vbmi">, Group; +def mno_avx512ifma : Flag<["-"], "mno-avx512ifma">, Group; def mno_pclmul : Flag<["-"], "mno-pclmul">, Group; def mno_lzcnt : Flag<["-"], "mno-lzcnt">, Group; def mno_rdrnd : Flag<["-"], "mno-rdrnd">, Group; @@ -1527,6 +1529,8 @@ def mavx512pf : Flag<["-"], "mavx512pf"> def mavx512dq : Flag<["-"], "mavx512dq">, Group; def mavx512bw : Flag<["-"], "mavx512bw">, Group; def mavx512vl : Flag<["-"], "mavx512vl">, Group; +def mavx512vbmi : Flag<["-"], "mavx512vbmi">, Group; +def mavx512ifma : Flag<["-"], "mavx512ifma">, Group; def mpclmul : Flag<["-"], "mpclmul">, Group; def mlzcnt : Flag<["-"], "mlzcnt">, Group; def mrdrnd : Flag<["-"], "mrdrnd">, Group; Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262201&r1=262200&r2=262201&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 29 00:51:38 2016 @@ -2891,7 +2891,8 @@ void X86TargetInfo::setSSELevel(llvm::St case AVX512F: Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] = Features["avx512pf"] = Features["avx512dq"] = Features["avx512bw"] = - Features["avx512vl"] = false; + Features["avx512vl"] = Features["avx512vbmi"] = + Features["avx512ifma"] = false; } } @@ -2989,8 +2990,9 @@ void X86TargetInfo::setFeatureEnabledImp setSSELevel(Features, AVX2, Enabled); } else if (Name == "avx512f") { setSSELevel(Features, AVX512F, Enabled); - } else if (Name == "avx512cd" || Name == "avx512er" || Name == "avx512pf" - || Name == "avx512dq" || Name == "avx512bw" || Name == "avx512vl") { + } else if (Name == "avx512cd" || Name == "avx512er" || Name == "avx512pf" || + Name == "avx512dq" || Name == "avx512bw" || Name == "avx512vl" || + Name == "avx512vbmi" || Name == "avx512ifma") { if (Enabled) setSSELevel(Features, AVX512F, Enabled); } else if (Name == "fma") { @@ -3398,6 +3400,10 @@ void X86TargetInfo::getTargetDefines(con Builder.defineMacro("__AVX512BW__"); if (HasAVX512VL) Builder.defineMacro("__AVX512VL__"); + if (HasAVX512VBMI) +Builder.defineMacro("__AVX512VBMI__"); + if (HasAVX512IFMA) +Builder.defineMacro("__AVX512IFMA__"); if (HasSHA) Builder.defineMacro("__SHA__"); Modified: cfe/trunk/test/CodeGen/attr-target-x86.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-x86.c?rev=262201&r1=262200&r2=262201&view=diff == --- cfe/trunk/test/CodeGen/attr-target-x86.c (original) +++ cfe/trunk/test/CodeGen/attr-target-x86.c Mon Feb 29 00:51:38 2016 @@ -33,7 +33,7 @@ int __attribute__((target("no-mmx"))) qq // CHECK: qq{{.*}} #5 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+xsave,+xsaveopt" -// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512pf,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt" +// CHECK: #2 = {{.*}}"target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,-aes,-avx,-avx2,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vl,-f16c,-fma,-fma4,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-xop,-xsave,-xsaveopt" // CHECK: #3 = {{.*}}"target-cpu"="x86-64" "t