[PATCH] D33719: Add _Float16 as a C/C++ source language type
rogfer01 added inline comments. Comment at: include/clang/AST/Type.h:1669 bool isHalfType() const; // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half) + bool isFloat16Type() const; // FIXME bool isRealType() const; // C99 6.2.5p17 (real floating + integer) I think you want to make clear that this is ``` // C11 extension ISO/IEC TS 18661-3 ``` Comment at: lib/AST/StmtPrinter.cpp:1434 default: llvm_unreachable("Unexpected type for float literal!"); + case BuiltinType::Float16: case BuiltinType::Half: break; // FIXME: suffix? Should this be `.f16` as suffix for consistency with the floating literal syntax? Comment at: lib/CodeGen/CGExprScalar.cpp:1932-1934 + else if (value->getType()->isFloat16Ty()) { +FS = &CGF.getTarget().getHalfFormat(); //FIXME? + } else I think you don't need this new LLVM type (that you introduce in D34205) as you are already able to tell the two types apart (`_fp16` and `_Float16`) at the level of clang types. And your change does not seem to need it in any other place. Comment at: lib/CodeGen/CodeGenTypes.cpp:445 + getTypeForFormat(getLLVMContext(), Context.getFloatTypeSemantics(T), + true); + break; I think you can make this more obvious to the reader with a comment for this bool parameter. ``` /* UseNativeHalf */ true ``` https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32520: Support __fp16 vectors
ahatanak updated this revision to Diff 102642. ahatanak marked 3 inline comments as done. ahatanak added a comment. Herald added a subscriber: kristof.beyls. Address review comments. https://reviews.llvm.org/D32520 Files: include/clang/Sema/Sema.h lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaExpr.cpp test/CodeGen/fp16vec-ops.c test/Sema/fp16vec-sema.c Index: test/Sema/fp16vec-sema.c === --- /dev/null +++ test/Sema/fp16vec-sema.c @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef __fp16 half4 __attribute__ ((vector_size (8))); +typedef float float4 __attribute__ ((vector_size (16))); +typedef short short4 __attribute__ ((vector_size (8))); +typedef int int4 __attribute__ ((vector_size (16))); + +half4 hv0, hv1; +float4 fv0, fv1; +short4 sv0; +int4 iv0; + +void testFP16Vec(int c) { + hv0 = hv0 + hv1; + hv0 = hv0 - hv1; + hv0 = hv0 * hv1; + hv0 = hv0 / hv1; + hv0 = c ? hv0 : hv1; + hv0 += hv1; + hv0 -= hv1; + hv0 *= hv1; + hv0 /= hv1; + sv0 = hv0 == hv1; + sv0 = hv0 != hv1; + sv0 = hv0 < hv1; + sv0 = hv0 > hv1; + sv0 = hv0 <= hv1; + sv0 = hv0 >= hv1; + sv0 = hv0 || hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}} + sv0 = hv0 && hv1; // expected-error{{logical expression with vector types 'half4' (vector of 4 '__fp16' values) and 'half4' is only supported in C++}} + + // Implicit conversion between half vectors and float vectors are not allowed. + hv0 = fv0; // expected-error{{assigning to}} + fv0 = hv0; // expected-error{{assigning to}} + hv0 = (half4)fv0; // expected-error{{invalid conversion between}} + fv0 = (float4)hv0; // expected-error{{invalid conversion between}} + hv0 = fv0 + fv1; // expected-error{{assigning to}} + fv0 = hv0 + hv1; // expected-error{{assigning to}} + hv0 = hv0 + fv1; // expected-error{{cannot convert between vector}} + hv0 = c ? hv0 : fv1; // expected-error{{cannot convert between vector}} + sv0 = hv0 == fv1; // expected-error{{cannot convert between vector}} + sv0 = hv0 < fv1; // expected-error{{cannot convert between vector}} + sv0 = hv0 || fv1; // expected-error{{cannot convert between vector}} expected-error{{invalid operands to binary expression}} + iv0 = hv0 == hv1; // expected-error{{assigning to}} + + // FIXME: clang currently disallows using these operators on vectors, which is + // allowed by gcc. + sv0 = !hv0; // expected-error{{invalid argument type}} + hv0++; // expected-error{{cannot increment value of type}} + ++hv0; // expected-error{{cannot increment value of type}} +} Index: test/CodeGen/fp16vec-ops.c === --- /dev/null +++ test/CodeGen/fp16vec-ops.c @@ -0,0 +1,162 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -triple arm64-apple-ios9 -emit-llvm -o - -fallow-half-arguments-and-returns %s | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -triple armv7-apple-ios9 -emit-llvm -o - -fallow-half-arguments-and-returns %s | FileCheck %s --check-prefix=CHECK + +typedef __fp16 half4 __attribute__ ((vector_size (8))); +typedef short short4 __attribute__ ((vector_size (8))); + +half4 hv0, hv1; +short4 sv0; + +// CHECK-LABEL: testFP16Vec0 +// CHECK: %[[V0:.*]] = load <4 x half>, <4 x half>* @hv0, align 8 +// CHECK: %[[CONV:.*]] = fpext <4 x half> %[[V0]] to <4 x float> +// CHECK: %[[V1:.*]] = load <4 x half>, <4 x half>* @hv1, align 8 +// CHECK: %[[CONV1:.*]] = fpext <4 x half> %[[V1]] to <4 x float> +// CHECK: %[[ADD:.*]] = fadd <4 x float> %[[CONV]], %[[CONV1]] +// CHECK: %[[CONV2:.*]] = fptrunc <4 x float> %[[ADD]] to <4 x half> +// CHECK: store <4 x half> %[[CONV2]], <4 x half>* @hv0, align 8 +// CHECK: %[[V2:.*]] = load <4 x half>, <4 x half>* @hv0, align 8 +// CHECK: %[[CONV3:.*]] = fpext <4 x half> %[[V2]] to <4 x float> +// CHECK: %[[V3:.*]] = load <4 x half>, <4 x half>* @hv1, align 8 +// CHECK: %[[CONV4:.*]] = fpext <4 x half> %[[V3]] to <4 x float> +// CHECK: %[[SUB:.*]] = fsub <4 x float> %[[CONV3]], %[[CONV4]] +// CHECK: %[[CONV5:.*]] = fptrunc <4 x float> %[[SUB]] to <4 x half> +// CHECK: store <4 x half> %[[CONV5]], <4 x half>* @hv0, align 8 +// CHECK: %[[V4:.*]] = load <4 x half>, <4 x half>* @hv0, align 8 +// CHECK: %[[CONV6:.*]] = fpext <4 x half> %[[V4]] to <4 x float> +// CHECK: %[[V5:.*]] = load <4 x half>, <4 x half>* @hv1, align 8 +// CHECK: %[[CONV7:.*]] = fpext <4 x half> %[[V5]] to <4 x float> +// CHECK: %[[MUL:.*]] = fmul <4 x float> %[[CONV6]], %[[CONV7]] +// CHECK: %[[CONV8:.*]] = fptrunc <4 x float> %[[MUL]] to <4 x half> +// CHECK: store <4 x half> %[[CONV8]], <4 x half>* @hv0, align 8 +// CHECK: %[[V6:.*]] = load <4 x half>, <4 x half>* @hv0, align 8 +// CHECK: %[[CONV9:.*]] = fpext <4 x half> %[[V6]] to <4 x float> +// CHECK: %[[V7:.*]] = load <4 x half>, <4 x half>* @hv1, align 8 +// CHECK: %[[CONV10:.*]] = fpext <4 x half> %[[V7]] to <4 x float>
[PATCH] D32520: Support __fp16 vectors
ahatanak added inline comments. Comment at: lib/CodeGen/CGExprScalar.cpp:997 - // Allow bitcast from vector to integer/fp of the same size. - if (isa(SrcTy) || - isa(DstTy)) -return Builder.CreateBitCast(Src, DstTy, "conv"); + if (isa(SrcTy) || isa(DstTy)) { +auto GetSize = [](const llvm::Type *Ty) { bruno wrote: > Please also add a comment explaining what's going on here, like we see for > other snippets of logic above. > > It also sounds like this is more generic than it should (which can have > unexpected side effects due to the lack of testcases covering vector with > other element sizes). I suggest you either (a) add testcases for other sizes > or (b) make the condition more restrictive to be sure you're only changing > the logic you intend to (i.e., half and i16). > > After these changes, if it makes sense, can you refactor the logic under this > condition into its own function? Seems like this function is too big already. I'm surprised that we don't have many code-gen tests for vectors, but I can add more test cases that are the same as the tests in fp16vec-ops.c except that the element types are different. Just to be clear, the only change I'm making here is to handle cases in which the source and destination have different sizes. That shouldn't happen when for example an i8 vector is converted to an i32 because if it did happen, that would have previously caused an assertion when calling CreateBitCast (bitcast requires the sizes of the destination and source be the same). Also, I removed the lambda and instead used Type::getPrimitiveSizeInBit to compute the vector size. If this looks OK, I'll try refactoring this function. Comment at: lib/Sema/SemaExpr.cpp:11433 ExprObjectKind OK = OK_Ordinary; + bool ConvertHalfVec = false; bruno wrote: > Assuming we're able to handle other vector types here, is it in > `ConvertHalfVec` really necessary? It seems odd to me that we need to special > case it in every case below. ConvertHalfVec is needed to distinguish operations that involve vectors of half from those that don't. If the operands are vectors of half, convertHalfVecBinOp is called to promote the operands and truncate the result. https://reviews.llvm.org/D32520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r305454 - [clangd] Add priority to completion item sort text
Author: krasimir Date: Thu Jun 15 04:11:57 2017 New Revision: 305454 URL: http://llvm.org/viewvc/llvm-project?rev=305454&view=rev Log: [clangd] Add priority to completion item sort text Summary: This patch adds the priority of a completion item to the sort text of the returned LSP result. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34137 Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/test/clangd/authority-less-uri.test clang-tools-extra/trunk/test/clangd/completion.test Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=305454&r1=305453&r2=305454&view=diff == --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Jun 15 04:11:57 2017 @@ -13,6 +13,7 @@ #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/Utils.h" #include "clang/Tooling/CompilationDatabase.h" +#include "llvm/Support/Format.h" using namespace clang::clangd; using namespace clang; @@ -153,7 +154,17 @@ public: } assert(CCS->getTypedText()); Item.kind = getKind(Result.CursorKind); -Item.insertText = Item.sortText = Item.filterText = CCS->getTypedText(); +// Priority is a 16-bit integer, hence at most 5 digits. +// Since identifiers with higher priority need to come first, +// we subtract the priority from 9. +// For example, the sort text of the identifier 'a' with priority 35 +// is 99964a. +assert(CCS->getPriority() < 9 && "Expecting code completion result " + "priority to have at most " + "5-digits"); +llvm::raw_string_ostream(Item.sortText) << llvm::format( +"%05d%s", 9 - CCS->getPriority(), CCS->getTypedText()); +Item.insertText = Item.filterText = CCS->getTypedText(); if (CCS->getBriefComment()) Item.documentation = CCS->getBriefComment(); Items->push_back(std::move(Item)); Modified: clang-tools-extra/trunk/test/clangd/authority-less-uri.test URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/authority-less-uri.test?rev=305454&r1=305453&r2=305454&view=diff == --- clang-tools-extra/trunk/test/clangd/authority-less-uri.test (original) +++ clang-tools-extra/trunk/test/clangd/authority-less-uri.test Thu Jun 15 04:11:57 2017 @@ -16,7 +16,7 @@ Content-Length: 146 # Test authority-less URI # # CHECK: {"jsonrpc":"2.0","id":1,"result":[ -# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"} +# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"99964a","filterText":"a","insertText":"a"} # CHECK: ]} Content-Length: 172 @@ -25,7 +25,7 @@ Content-Length: 172 # Test params parsing in the presence of a 1.x-compatible client (inlined "uri") # # CHECK: {"jsonrpc":"2.0","id":2,"result":[ -# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"} +# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"99964a","filterText":"a","insertText":"a"} # CHECK: ]} Content-Length: 44 Modified: clang-tools-extra/trunk/test/clangd/completion.test URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion.test?rev=305454&r1=305453&r2=305454&view=diff == --- clang-tools-extra/trunk/test/clangd/completion.test (original) +++ clang-tools-extra/trunk/test/clangd/completion.test Thu Jun 15 04:11:57 2017 @@ -16,12 +16,12 @@ Content-Length: 148 # nondeterministic, so we check regardless of order. # # CHECK: {"jsonrpc":"2.0","id":1,"result":[ -# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"} -# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"} -# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"} -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"operator=","filterText":"operator=","insertText":"operator="} -# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"} -# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"} +# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"99964a","filterText":"a","insertText":"a"} +# CHECK-DAG: {"label":"bb","kind":5,"detai
[PATCH] D34137: [clangd] Add priority to completion item sort text
This revision was automatically updated to reflect the committed changes. Closed by commit rL305454: [clangd] Add priority to completion item sort text (authored by krasimir). Changed prior to commit: https://reviews.llvm.org/D34137?vs=102522&id=102646#toc Repository: rL LLVM https://reviews.llvm.org/D34137 Files: clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/test/clangd/authority-less-uri.test clang-tools-extra/trunk/test/clangd/completion.test Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp === --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp @@ -13,6 +13,7 @@ #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/Utils.h" #include "clang/Tooling/CompilationDatabase.h" +#include "llvm/Support/Format.h" using namespace clang::clangd; using namespace clang; @@ -153,7 +154,17 @@ } assert(CCS->getTypedText()); Item.kind = getKind(Result.CursorKind); -Item.insertText = Item.sortText = Item.filterText = CCS->getTypedText(); +// Priority is a 16-bit integer, hence at most 5 digits. +// Since identifiers with higher priority need to come first, +// we subtract the priority from 9. +// For example, the sort text of the identifier 'a' with priority 35 +// is 99964a. +assert(CCS->getPriority() < 9 && "Expecting code completion result " + "priority to have at most " + "5-digits"); +llvm::raw_string_ostream(Item.sortText) << llvm::format( +"%05d%s", 9 - CCS->getPriority(), CCS->getTypedText()); +Item.insertText = Item.filterText = CCS->getTypedText(); if (CCS->getBriefComment()) Item.documentation = CCS->getBriefComment(); Items->push_back(std::move(Item)); Index: clang-tools-extra/trunk/test/clangd/completion.test === --- clang-tools-extra/trunk/test/clangd/completion.test +++ clang-tools-extra/trunk/test/clangd/completion.test @@ -16,25 +16,25 @@ # nondeterministic, so we check regardless of order. # # CHECK: {"jsonrpc":"2.0","id":1,"result":[ -# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"} -# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"} -# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"} -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"operator=","filterText":"operator=","insertText":"operator="} -# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"} -# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"} +# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"99964a","filterText":"a","insertText":"a"} +# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"99964bb","filterText":"bb","insertText":"bb"} +# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"99964ccc","filterText":"ccc","insertText":"ccc"} +# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"99965operator=","filterText":"operator=","insertText":"operator="} +# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"99965~fake","filterText":"~fake","insertText":"~fake"} +# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"99964f","filterText":"f","insertText":"f"} # CHECK: ]} Content-Length: 148 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}} # Repeat the completion request, expect the same results. # # CHECK: {"jsonrpc":"2.0","id":2,"result":[ -# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"a","filterText":"a","insertText":"a"} -# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"bb","filterText":"bb","insertText":"bb"} -# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"ccc","filterText":"ccc","insertText":"ccc"} -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"operator=","filterText":"operator=","insertText":"operator="} -# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"~fake","filterText":"~fake","insertText":"~fake"} -# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"f","filterText":"f","insertText":"f"} +# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"99964a","filterText":"a","insertText":"a"} +# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"99964b
r305456 - Revert "Define _GNU_SOURCE for rtems c++"
Author: djasper Date: Thu Jun 15 04:17:12 2017 New Revision: 305456 URL: http://llvm.org/viewvc/llvm-project?rev=305456&view=rev Log: Revert "Define _GNU_SOURCE for rtems c++" This reverts commit r305399. This breaks a build in libcxx: libcxx/src/system_error.cpp:90:16: error: assigning to 'int' from incompatible type 'char *' if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) { ^~~~ 1 error generated. Which makes sense according to: https://linux.die.net/man/3/strerror_r Not entirely sure how this needs to be fixed. Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=305456&r1=305455&r2=305456&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Thu Jun 15 04:17:12 2017 @@ -4734,9 +4734,6 @@ protected: Builder.defineMacro("__rtems__"); Builder.defineMacro("__ELF__"); -// Required by the libc++ locale support. -if (Opts.CPlusPlus) - Builder.defineMacro("_GNU_SOURCE"); } public: Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=305456&r1=305455&r2=305456&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Thu Jun 15 04:17:12 2017 @@ -8779,7 +8779,6 @@ // KFREEBSDI686-DEFINE:#define __GLIBC__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s -// RUN: %clang_cc1 -x c++ -triple sparc-rtems-elf -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s // GNUSOURCE:#define _GNU_SOURCE 1 // // RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NORTTI %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler
teemperor requested changes to this revision. teemperor added a comment. This revision now requires changes to proceed. Sorry for the delay, we got stuck because hard coding a certain file pattern into the clang source code doesn't seem to be a optimal solution (e.g. every user that has a different set of generated files needs to patch clang to hide his specific reports). I would prefer if we could get this into a variable that the user can change dynamically. Would it solve your use case if allow specifying file patterns via the command line like this `-analyzer-config alpha.clone.CloneChecker:IgnoredFiles=moc_*;*.pb.h;*.pb.cc`? If yes, please update this PR accordingly and then I think this patch is good to go. Thanks for the work! Repository: rL LLVM https://reviews.llvm.org/D31320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33719: Add _Float16 as a C/C++ source language type
SjoerdMeijer updated this revision to Diff 102649. SjoerdMeijer added a comment. Thanks Roger. I did the clean up; there were indeed still a few fixmes there. The good thing is that it's a self-contained clang patch again: we don't need https://reviews.llvm.org/D34205, which I have abandoned. https://reviews.llvm.org/D33719 Files: include/clang-c/Index.h include/clang/AST/ASTContext.h include/clang/AST/BuiltinTypes.def include/clang/Basic/Specifiers.h include/clang/Basic/TokenKinds.def include/clang/Lex/LiteralSupport.h include/clang/Sema/DeclSpec.h include/clang/Serialization/ASTBitCodes.h lib/AST/ASTContext.cpp lib/AST/ItaniumMangle.cpp lib/AST/MicrosoftMangle.cpp lib/AST/NSAPI.cpp lib/AST/StmtPrinter.cpp lib/AST/Type.cpp lib/AST/TypeLoc.cpp lib/Analysis/PrintfFormatString.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/Format/FormatToken.cpp lib/Index/USRGeneration.cpp lib/Lex/LiteralSupport.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseTentative.cpp lib/Sema/DeclSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaTemplateVariadic.cpp lib/Sema/SemaType.cpp lib/Serialization/ASTCommon.cpp lib/Serialization/ASTReader.cpp test/CodeGenCXX/float16-declarations.cpp test/Lexer/half-literal.cpp tools/libclang/CXType.cpp Index: tools/libclang/CXType.cpp === --- tools/libclang/CXType.cpp +++ tools/libclang/CXType.cpp @@ -53,6 +53,7 @@ BTCASE(Float); BTCASE(Double); BTCASE(LongDouble); +BTCASE(Float16); BTCASE(Float128); BTCASE(NullPtr); BTCASE(Overload); @@ -520,7 +521,7 @@ TKIND(Char_U); TKIND(UChar); TKIND(Char16); -TKIND(Char32); +TKIND(Char32); TKIND(UShort); TKIND(UInt); TKIND(ULong); @@ -538,6 +539,7 @@ TKIND(Float); TKIND(Double); TKIND(LongDouble); +TKIND(Float16); TKIND(Float128); TKIND(NullPtr); TKIND(Overload); Index: test/Lexer/half-literal.cpp === --- test/Lexer/half-literal.cpp +++ test/Lexer/half-literal.cpp @@ -1,3 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s float a = 1.0h; // expected-error{{invalid suffix 'h' on floating constant}} float b = 1.0H; // expected-error{{invalid suffix 'H' on floating constant}} + +_Float16 c = 1.f166; // expected-error{{invalid suffix 'f166' on floating constant}} +_Float16 d = 1.f1; // expected-error{{invalid suffix 'f1' on floating constant}} Index: test/CodeGenCXX/float16-declarations.cpp === --- /dev/null +++ test/CodeGenCXX/float16-declarations.cpp @@ -0,0 +1,132 @@ +// RUN: %clang -std=c++11 --target=aarch64-arm--eabi -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64 +// RUN: %clang -std=c++11 --target=x86_64 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X86 + +/* Various contexts where type _Float16 can appear. */ + + +/* Namespace */ + +namespace { + _Float16 f1n; +// CHECK-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global half 0xH, align 2 + + _Float16 f2n = 33.f16; +// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global half 0xH5020, align 2 +// CHECK-X86-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global i16 20512, align 2 + + _Float16 arr1n[10]; +// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 2 +// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x half] zeroinitializer, align 16 + + _Float16 arr2n[] = { 1.2, 3.0, 3.e4 }; +// CHECK-AARCH64-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x half] [half 0xH3CCD, half 0xH4200, half 0xH7753], align 2 +// CHECK-X86-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x i16] [i16 15565, i16 16896, i16 30547], align 2 + + const volatile _Float16 func1n(const _Float16 &arg) { +return arg + f2n + arr1n[4] - arr2n[1]; + } +} + + +/* File */ + +_Float16 f1f; +// CHECK-AARCH64-DAG: @f1f = global half 0xH, align 2 +// CHECK-X86-DAG: @f1f = global half 0xH, align 2 + +_Float16 f2f = 32.4; +// CHECK-AARCH64-DAG: @f2f = global half 0xH500D, align 2 +// CHECK-X86-DAG: @f2f = global i16 20493, align 2 + +_Float16 arr1f[10]; +// CHECK-AARCH64-DAG: @arr1f = global [10 x half] zeroinitializer, align 2 +// CHECK-X86-DAG: @arr1f = global [10 x half] zeroinitializer, align 16 + +_Float16 arr2f[] = { -1.2, -3.0, -3.e4 }; +// CHECK-AARCH64-DAG: @arr2f = global [3 x half] [half 0xHBCCD, half 0xHC200, half 0xHF753], align 2 +// CHECK-X86-DAG: @arr2f = global [3 x i16] [i16 -17203, i16 -15872, i16 -2221], align 2 + +_Float16 func1f(_Float16 arg); + + +/* Class */ + +class C1 { + _Float16 f1c; + + static const _Float16 f2c;
[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler
v.g.vassilev added a comment. I agree with Raphael. If you need to have more fine grained control over the translation unit (TU) I think we can have suppressing false positives via comments (@Noq would know more). Eg. // File.h defining moc_* yields a lot of false positives // alpha.clone.CloneChecker:Ignored: some_regex ... This would affect only the TU which include File.h. Repository: rL LLVM https://reviews.llvm.org/D31320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers
szdominik updated this revision to Diff 102650. szdominik added a comment. Delete modeling checkers (unix.StdCLibraryFunctions, cplusplus.SelfAssignment). Delete unix.MallocWithAnnotations. https://reviews.llvm.org/D33645 Files: www/analyzer/alpha_checks.html www/analyzer/available_checks.html www/analyzer/implicit_checks.html Index: www/analyzer/implicit_checks.html === --- www/analyzer/implicit_checks.html +++ www/analyzer/implicit_checks.html @@ -27,7 +27,7 @@ OS X Implicit Checkers - + Core Implicit Checkers @@ -124,7 +124,7 @@ - + OS X Implicit Checkers Index: www/analyzer/available_checks.html === --- www/analyzer/available_checks.html +++ www/analyzer/available_checks.html @@ -38,12 +38,14 @@ Core Checkers model core language features and perform general-purpose checks such as division by zero, null pointer dereference, usage of uninitialized values, etc. C++ Checkers perform C++-specific checks Dead Code Checkers check for unused code +Nullability Checkers +Optin Checkers OS X Checkers perform Objective-C-specific checks and check the use of Apple's SDKs (OS X and iOS) Security Checkers check for insecure API usage and perform checks based on the CERT Secure Coding Standards Unix Checkers check the use of Unix and POSIX APIs - + Core Checkers @@ -360,7 +362,7 @@ - + C++ Checkers @@ -421,9 +423,21 @@ } + +cplusplus.NewDeleteLeaks +(C++) +Check for memory leaks. Traces memory managed by new/ +delete. + + +void test() { + int *p = new int; +} // warn + + - + Dead Code Checkers @@ -444,7 +458,157 @@ - + +Nullability Checkers + + +Name, DescriptionExample + + + +nullability.NullPassedToNonnull +(ObjC) +Warns when a null pointer is passed to a pointer which has a +_Nonnull type. + + +typedef struct Dummy { int val; } Dummy; +void takesNonnull(Dummy *_Nonnull); + +void test() { + Dummy *q = 0; + takesNonnull(q); // warn +} + + + + +nullability.NullReturnedFromNonnull +(ObjC) +Warns when a null pointer is returned from a function that has +_Nonnull return type. + + +typedef struct Dummy { int val; } Dummy; + +Dummy *_Nonnull test() { + Dummy *p = 0; + return p; // warn +} + + + + +nullability.NullableDereferenced +(ObjC) +Warns when a nullable pointer is dereferenced. + + +typedef struct Dummy { int val; } Dummy; +Dummy *_Nullable returnsNullable(); + +void test() { + Dummy *p = returnsNullable(); + Dummy &r = *p; // warn +} + + + + +nullability.NullablePassedToNonnull +(ObjC) +Warns when a nullable pointer is passed to a pointer which has a _Nonnull type. + + +typedef struct Dummy { int val; } Dummy; +Dummy *_Nullable returnsNullable(); +void takesNonnull(Dummy *_Nonnull); + +void test() { + Dummy *p = returnsNullable(); + takesNonnull(p); // warn +} + + + + + +Optin Checkers + + +Name, DescriptionExample + + + +optin.mpi.MPI-Checker +(C) +Checks MPI code + + +void test() { + double buf = 0; + MPI_Request sendReq1; + MPI_Ireduce(MPI_IN_PLACE, &buf, 1, MPI_DOUBLE, MPI_SUM, + 0, MPI_COMM_WORLD, &sendReq1); +} // warn: request 'sendReq1' has no matching wait. + + +void test() { + double buf = 0; + MPI_Request sendReq; + MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); + MPI_Irecv(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // warn + MPI_Isend(&buf, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, &sendReq); // warn + MPI_Wait(&sendReq, MPI_STATUS_IGNORE); +} + + +void missingNonBlocking() { + int rank = 0; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Request sendReq1[10][10][10]; + MPI_Wait(&sendReq1[1][7][9], MPI_STATUS_IGNORE); // warn +} + + + + +optin.osx.cocoa.localizability.EmptyLocalizationContextChecker +(ObjC) +Check that NSLocalizedString macros include a comment for context. + + +- (void)test { + NSString *string = NSLocalizedString(@"LocalizedString", nil); // warn + NSString *string2 = NSLocalizedString(@"LocalizedString", @" "); // warn + NSString *string3 = NSLocalizedStringWithDefaultValue( +@"LocalizedString", nil, [[NSBundle alloc] init], nil,@""); // warn +} + + + + +optin.osx.cocoa.localizability.NonLocalizedStringChecker +(ObjC) +Warns about uses of non-localized NSStrings passed to UI methods +expecting localized NSStrings + + +- (void)test { + UILabel *testLabel = [[UILabel alloc] init]; + NSString *bar = NSLocalizedString(@"Hello", @"Comment"); + + if (random()) { +bar = @"Unlocalized string"; + } + + [testLabel setText:bar]; // warn +} + + + + + OS X Checkers @@ -466,6 +630,37 @@ +osx.NumberObjectConversion +(C, C++, ObjC) +Check for erroneous conversions of objects representing numbers +into numbers + + +typedef const struct __CFNumber *CFNumberRef; +void takes_int(int); + +void test(CFNumberRef p) { +#ifdef PEDANTIC + if (p) {} // warn + if (!p) {} // warn + p ? 1 : 2; // warn + if (p == 0) {} // warn
[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers
szdominik marked 3 inline comments as done. szdominik added inline comments. Comment at: www/analyzer/alpha_checks.html:91 +(C, C++) +Check for logical errors for function calls and Objective-C message +expressions (e.g., uninitialized arguments, null function pointers, zaks.anna wrote: > for function calls -> in function calls? > After briefly looking into this, the checker only reports the use of > uninitialized arguments in calls, not the other issues (like null function > pointers). Could you double check this? As I see here https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp#L341 there are checks for null pointers too. https://reviews.llvm.org/D33645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305460 - Revert "Load lazily the template specialization in multi-module setups."
Author: vvassilev Date: Thu Jun 15 06:05:32 2017 New Revision: 305460 URL: http://llvm.org/viewvc/llvm-project?rev=305460&view=rev Log: Revert "Load lazily the template specialization in multi-module setups." This broke our libcxx modules builds. Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=305460&r1=305459&r2=305460&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Jun 15 06:05:32 2017 @@ -216,30 +216,6 @@ namespace clang { TypedefNameForLinkage(nullptr), HasPendingBody(false), IsDeclMarkedUsed(false) {} -template static -void AddLazySpecializations(T *D, -SmallVectorImpl& IDs) { - if (IDs.empty()) -return; - - // FIXME: We should avoid this pattern of getting the ASTContext. - ASTContext &C = D->getASTContext(); - - auto *&LazySpecializations = D->getCommonPtr()->LazySpecializations; - - if (auto &Old = LazySpecializations) { -IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]); -std::sort(IDs.begin(), IDs.end()); -IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end()); - } - - auto *Result = new (C) serialization::DeclID[1 + IDs.size()]; - *Result = IDs.size(); - std::copy(IDs.begin(), IDs.end(), Result + 1); - - LazySpecializations = Result; -} - template static Decl *getMostRecentDeclImpl(Redeclarable *D); static Decl *getMostRecentDeclImpl(...); @@ -268,7 +244,7 @@ namespace clang { void ReadFunctionDefinition(FunctionDecl *FD); void Visit(Decl *D); -void UpdateDecl(Decl *D, llvm::SmallVectorImpl&); +void UpdateDecl(Decl *D); static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next) { @@ -1976,6 +1952,21 @@ ASTDeclReader::VisitRedeclarableTemplate return Redecl; } +static DeclID *newDeclIDList(ASTContext &Context, DeclID *Old, + SmallVectorImpl &IDs) { + assert(!IDs.empty() && "no IDs to add to list"); + if (Old) { +IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]); +std::sort(IDs.begin(), IDs.end()); +IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end()); + } + + auto *Result = new (Context) DeclID[1 + IDs.size()]; + *Result = IDs.size(); + std::copy(IDs.begin(), IDs.end(), Result + 1); + return Result; +} + void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) { RedeclarableResult Redecl = VisitRedeclarableTemplateDecl(D); @@ -1984,7 +1975,12 @@ void ASTDeclReader::VisitClassTemplateDe // the specializations. SmallVector SpecIDs; ReadDeclIDList(SpecIDs); -ASTDeclReader::AddLazySpecializations(D, SpecIDs); + +if (!SpecIDs.empty()) { + auto *CommonPtr = D->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs); +} } if (D->getTemplatedDecl()->TemplateOrInstantiation) { @@ -2011,7 +2007,12 @@ void ASTDeclReader::VisitVarTemplateDecl // the specializations. SmallVector SpecIDs; ReadDeclIDList(SpecIDs); -ASTDeclReader::AddLazySpecializations(D, SpecIDs); + +if (!SpecIDs.empty()) { + auto *CommonPtr = D->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs); +} } } @@ -2117,7 +2118,12 @@ void ASTDeclReader::VisitFunctionTemplat // This FunctionTemplateDecl owns a CommonPtr; read it. SmallVector SpecIDs; ReadDeclIDList(SpecIDs); -ASTDeclReader::AddLazySpecializations(D, SpecIDs); + +if (!SpecIDs.empty()) { + auto *CommonPtr = D->getCommonPtr(); + CommonPtr->LazySpecializations = newDeclIDList( + Reader.getContext(), CommonPtr->LazySpecializations, SpecIDs); +} } } @@ -3661,9 +3667,6 @@ void ASTReader::loadDeclUpdateRecords(Pe Decl *D = Record.D; ProcessingUpdatesRAIIObj ProcessingUpdates(*this); DeclUpdateOffsetsMap::iterator UpdI = DeclUpdateOffsets.find(ID); - - llvm::SmallVector PendingLazySpecializationIDs; - if (UpdI != DeclUpdateOffsets.end()) { auto UpdateOffsets = std::move(UpdI->second); DeclUpdateOffsets.erase(UpdI); @@ -3688,7 +3691,7 @@ void ASTReader::loadDeclUpdateRecords(Pe ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID, SourceLocation()); - Reader.UpdateDecl(D, PendingLazySpecializationIDs); + Reader.UpdateDecl(D); // We might have made this declaration interesting. If so, remember that // we need to hand it off to the consumer. @@ -3700,17 +3703,6 @
[PATCH] D29951: Load lazily the template specialization in multi-module setups.
v.g.vassilev added a comment. Reverted in r305460 because broke libcxx modules builds. https://reviews.llvm.org/D29951 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34235: [OpenCL] Fix OpenCL and SPIR version metadata generation.
bader created this revision. OpenCL and SPIR version metadata must be generated once per module instead of once per mangled global value. https://reviews.llvm.org/D34235 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h lib/CodeGen/TargetInfo.cpp test/CodeGenOpenCL/spir_version.cl Index: test/CodeGenOpenCL/spir_version.cl === --- test/CodeGenOpenCL/spir_version.cl +++ test/CodeGenOpenCL/spir_version.cl @@ -10,17 +10,18 @@ // RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-AMDGCN-CL20 kernel void foo() {} +kernel void bar() {} -// CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2} -// CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0} -// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]} -// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL10-DAG: !opencl.spir.version = !{[[SPIR:![0-9]+]]} +// CHECK-SPIR-CL10-DAG: !opencl.ocl.version = !{[[OCL:![0-9]+]]} +// CHECK-SPIR-CL10-DAG: [[SPIR]] = !{i32 1, i32 2} +// CHECK-SPIR-CL10-DAG: [[OCL]] = !{i32 1, i32 0} +// CHECK-SPIR-CL12-DAG: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL12-DAG: !opencl.ocl.version = !{[[VER]]} // CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2} -// CHECK-SPIR-CL20: !opencl.spir.version = !{[[VER:![0-9]+]]} -// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL20-DAG: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL20-DAG: !opencl.ocl.version = !{[[VER]]} // CHECK-SPIR-CL20: [[VER]] = !{i32 2, i32 0} // CHECK-AMDGCN-CL10-NOT: !opencl.spir.version Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7344,8 +7344,6 @@ }; } -static void appendOpenCLVersionMD (CodeGen::CodeGenModule &CGM); - void AMDGPUTargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, @@ -7402,8 +7400,6 @@ if (NumVGPR != 0) F->addFnAttr("amdgpu-num-vgpr", llvm::utostr(NumVGPR)); } - - appendOpenCLVersionMD(M); } unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const { @@ -8074,8 +8070,6 @@ public: SPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) : TargetCodeGenInfo(new DefaultABIInfo(CGT)) {} - void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M) const override; unsigned getOpenCLKernelCallingConv() const override; }; @@ -8090,41 +8084,6 @@ } } -/// Emit SPIR specific metadata: OpenCL and SPIR version. -void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) const { - llvm::LLVMContext &Ctx = CGM.getModule().getContext(); - llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx); - llvm::Module &M = CGM.getModule(); - // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the - // opencl.spir.version named metadata. - llvm::Metadata *SPIRVerElts[] = { - llvm::ConstantAsMetadata::get( - llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( - Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))}; - llvm::NamedMDNode *SPIRVerMD = - M.getOrInsertNamedMetadata("opencl.spir.version"); - SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); - appendOpenCLVersionMD(CGM); -} - -static void appendOpenCLVersionMD(CodeGen::CodeGenModule &CGM) { - llvm::LLVMContext &Ctx = CGM.getModule().getContext(); - llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx); - llvm::Module &M = CGM.getModule(); - // SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the - // opencl.ocl.version named metadata node. - llvm::Metadata *OCLVerElts[] = { - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( - Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( - Int32Ty, (CGM.getLangOpts().OpenCLVersion % 100) / 10))}; - llvm::NamedMDNode *OCLVerMD = - M.getOrInsertNamedMetadata("opencl.ocl.version"); - OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts)); -} - unsigned SPIRTargetCodeGenInfo::getOpenCLKernelCallingConv() const { return llvm::CallingConv::SPIR_KERNEL; } Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1321,6 +1321,9 @@ /// Emits target specific Metadata for global declarations. void EmitTargetMetadata(); + /// Emits OpenCL specific Metadata e.g. OpenCL version. + void EmitOpenCLMetadata(); + /// Emit the llvm.gcov metad
[PATCH] D34235: [OpenCL] Fix OpenCL and SPIR version metadata generation.
yaxunl added a comment. LGTM. Thanks. https://reviews.llvm.org/D34235 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34237: Mark the operations of __wrap_iter as constexpr
mclow.lists created this revision. `__wrap_iter` is an internal libc++ class used to, well, wrap other iterators (such as pointers) when we need or want an object type. Mark the operations on `__wrap_iter` as constexpr, so that they can be used in a constexpr context if the underlying iterator can be used in such a context. I've had this kicking around my machine for a while, and it hasn't caused any problems. It probably needs a few tests before committing, though. https://reviews.llvm.org/D34237 Files: include/algorithm include/iterator Index: include/iterator === --- include/iterator +++ include/iterator @@ -1199,32 +1199,32 @@ template class __wrap_iter; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; @@ -1236,13 +1236,13 @@ -> decltype(__x.base() - __y.base()); #else template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename __wrap_iter<_Iter1>::difference_type operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG; #endif template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __wrap_iter<_Iter> operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG; @@ -1254,7 +1254,7 @@ #if _LIBCPP_DEBUG_LEVEL < 2 template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename enable_if < is_trivially_copy_assignable<_Tp>::value, @@ -1265,7 +1265,7 @@ #else template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename enable_if < is_trivially_copy_assignable<_Tp>::value, @@ -1288,7 +1288,8 @@ private: iterator_type __i; public: -_LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT_DEBUG +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +__wrap_iter() _NOEXCEPT_DEBUG #if _LIBCPP_STD_VER > 11 : __i{} #endif @@ -1297,7 +1298,8 @@ __get_db()->__insert_i(this); #endif } -template _LIBCPP_INLINE_VISIBILITY __wrap_iter(const __wrap_iter<_Up>& __u, +template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + __wrap_iter(const __wrap_iter<_Up>& __u, typename enable_if::value>::type* = 0) _NOEXCEPT_DEBUG : __i(__u.base()) { @@ -1306,13 +1308,13 @@ #endif } #if _LIBCPP_DEBUG_LEVEL >= 2 -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __wrap_iter(const __wrap_iter& __x) : __i(__x.base()) { __get_db()->__iterator_copy(this, &__x); } -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __wrap_iter& operator=(const __wrap_iter& __x) { if (this != &__x) @@ -1328,7 +1330,8 @@ __get_db()->__erase_i(this); } #endif -_LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT_DEBUG +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reference operator*() const _NOEXCEPT_DEBUG { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), @@ -1336,7 +1339,8 @@ #endif return *__i; } -_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT_DEBUG +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +pointer operator->() const _NOEXCEPT_DEBUG { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), @@ -1344,7 +1348,8 @@ #endif return (pointer)_VSTD::addressof(*__i); } -_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT_DEBUG +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +__wrap_iter& operator++() _NOEXCEPT_DEBUG { #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_ASSERT(__get_const_
[PATCH] D34238: clang-format: Do not binpack initialization lists
Typz created this revision. Herald added a subscriber: klimek. This patch tries to avoid binpacking when initializing lists/arrays, to allow things like: static int types[] = { registerType1(), registerType2(), registerType3(), }; std::map x = { { 0, "foo fjakfjaklf kljj" }, { 1, "bar fjakfjaklf kljj" }, { 2, "stuff fjakfjaklf kljj" }, }; This is similar to how dictionnaries are formatted, and actually corresponds to the same conditions: when initializing a container (and not just 'calling' a constructor). Such formatting involves 2 things: - Line breaks around the content of the block. This can be forced by adding a comma or comment after the last element - Elements should not be binpacked This patch considers the block is an initializer list if it either ends with a comma, or follows an assignment, which seems to provide a sensible approximation. https://reviews.llvm.org/D34238 Files: lib/Format/ContinuationIndenter.cpp Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -999,9 +999,13 @@ bool EndsInComma = Current.MatchingParen && Current.MatchingParen->Previous && Current.MatchingParen->Previous->is(tok::comma); +const FormatToken *PreviousNoComment = Current.getPreviousNonComment(); +bool IsAfterAssignment = PreviousNoComment && + PreviousNoComment->getPrecedence() == + prec::Assignment; AvoidBinPacking = -(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) || -Current.is(TT_DictLiteral) || +(/*Current.is(TT_ArrayInitializerLSquare) && */EndsInComma) || +IsAfterAssignment || Current.is(TT_DictLiteral) || Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments || (NextNoComment && NextNoComment->is(TT_DesignatedInitializerPeriod)); if (Current.ParameterCount > 1) Index: lib/Format/ContinuationIndenter.cpp === --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -999,9 +999,13 @@ bool EndsInComma = Current.MatchingParen && Current.MatchingParen->Previous && Current.MatchingParen->Previous->is(tok::comma); +const FormatToken *PreviousNoComment = Current.getPreviousNonComment(); +bool IsAfterAssignment = PreviousNoComment && + PreviousNoComment->getPrecedence() == + prec::Assignment; AvoidBinPacking = -(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) || -Current.is(TT_DictLiteral) || +(/*Current.is(TT_ArrayInitializerLSquare) && */EndsInComma) || +IsAfterAssignment || Current.is(TT_DictLiteral) || Style.Language == FormatStyle::LK_Proto || !Style.BinPackArguments || (NextNoComment && NextNoComment->is(TT_DesignatedInitializerPeriod)); if (Current.ParameterCount > 1) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34238: clang-format: Do not binpack initialization lists
Typz added a comment. This patch is probably not complete, though it works fine in all situations I could think of: nested initializers, "short" statement (properly merged), column layout is still performed when needed... static int types[] = { SourcePrivate::registerTypes(), registerEnum(), registerEnum(), }; static int types[] = {registerTypes(), registerEnum(), registerEnum()}; static int types[]{ SourcePrivate::registerTypes(), registerEnum(), registerEnum(), }; static int types[]{SourcePrivate::registerTypes(), registerEnum(), registerEnum()}; static int types[]{0, 1, 2}; static int types[] = {0, 1, 2}; static int types[] = {aaa, bb, , , eee, fff, gg, , ii}; static int types[] = { aaa, bb, , , eee, fff, gg, , ii, }; std::map x = { {0, "foo fjakfjaklf kljj"}, {1, "bar fjakfjaklf kljj"}, {2, "stuff fjakfjaklf kljj"}, }; I have seen 2 problems so far, but they do not seem to be related: - indent is performed using `continuationIndentWidth`, while I think `IndentWidth` may be more appropriate - When force-wrapping due to comma, all the content may be merged afterwards, leading to some strange layout. In this case, I think it should either not merge the content at all, or merge the braces as well: static int types[] = { 0, 1, 2 }; but I would need some feedback: - Would this be an interesting improvement? - Should this come with an option, or should this be the new behavior? - Any case in particular you think will break? - Technically, is this the right approach, or should I introduce a new TokenType and try to determine it in TokenAnnotator? This may help factorize some code from TokenAnnotator (which adds the forced line breaks) and ContinuationIndenter (which prevents BinPacking) and possibly UnwrappedLineFormatter (to fix the issue where the items get merged but not the braces) Comment at: lib/Format/ContinuationIndenter.cpp:1007 AvoidBinPacking = -(Current.is(TT_ArrayInitializerLSquare) && EndsInComma) || -Current.is(TT_DictLiteral) || +(/*Current.is(TT_ArrayInitializerLSquare) && */EndsInComma) || +IsAfterAssignment || Current.is(TT_DictLiteral) || I don't really understand what this "TT_ArrayInitializerLSquare" case is... https://reviews.llvm.org/D34238 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r305469 - Add missing include to __bsd_locale_fallbacks.h. Fixes https://bugs.llvm.org/show_bug.cgi?id=33370
Author: marshall Date: Thu Jun 15 09:31:11 2017 New Revision: 305469 URL: http://llvm.org/viewvc/llvm-project?rev=305469&view=rev Log: Add missing include to __bsd_locale_fallbacks.h. Fixes https://bugs.llvm.org/show_bug.cgi?id=33370 Modified: libcxx/trunk/include/__bsd_locale_fallbacks.h Modified: libcxx/trunk/include/__bsd_locale_fallbacks.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bsd_locale_fallbacks.h?rev=305469&r1=305468&r2=305469&view=diff == --- libcxx/trunk/include/__bsd_locale_fallbacks.h (original) +++ libcxx/trunk/include/__bsd_locale_fallbacks.h Thu Jun 15 09:31:11 2017 @@ -15,6 +15,7 @@ #define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H #include +#include #include _LIBCPP_BEGIN_NAMESPACE_STD ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34238: clang-format: Do not binpack initialization lists
malcolm.parsons added a comment. Some people write auto x = std::map{ { 0, "foo fjakfjaklf kljj" }, { 1, "bar fjakfjaklf kljj" }, { 2, "stuff fjakfjaklf kljj" }, }; https://reviews.llvm.org/D34238 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34238: clang-format: Do not binpack initialization lists
Typz added a comment. In https://reviews.llvm.org/D34238#781224, @malcolm.parsons wrote: > Some people write > > auto x = std::map{ >{ 0, "foo fjakfjaklf kljj" }, >{ 1, "bar fjakfjaklf kljj" }, >{ 2, "stuff fjakfjaklf kljj" }, >}; This case (and other way `std::map<> x =`) actually already worked, as long it ends with a comma: I suppose the braces at the beginning of each item already caused a line-break. https://reviews.llvm.org/D34238 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes
malcolm.parsons added a comment. This check is similar to `misc-move-constructor-init`; could it have a similar name please. https://reviews.llvm.org/D33722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well
2017-06-15 2:43 GMT+07:00 David Blaikie : > > > On Wed, Jun 14, 2017, 8:17 AM Serge Pavlov wrote: > >> 2017-06-14 4:24 GMT+07:00 David Blaikie : >> >>> Ah, I find that the test passes if I remove the compile_commands.json >>> file from my build directory (I have Ninja configured to generate a >>> compile_commands.json file). >>> >>> Looks like what happens is it finds the compilation database and fails >>> hard when the database doesn't contain a compile command for the file in >>> question. If the database is not found, it falls back to some basic command >>> behavior, perhaps? >>> >>> >> You are right, constructor of `CommonOptionsParser` calls >> `autoDetectFromSource` or `autoDetectFromDirectory` prior to final >> construction of `FixedCompilationDatabase. >> >> Is there some way this test could be fixed to cope with this, otherwise >>> it seems to get in the way of people actually using clang tools in their >>> LLVM/Clang build environment? >>> >>> >> IIUC, presence of stale compilation database file in test directory could >> break many tests. I don't understand why only diagnostic.cpp fails, >> probably there is something wrong with the clang-tidy application cleanup >> in this case? >> > > Except it's neither stale nor in the test directory. > > It's the up to date/useful/used compile_commands.json generated by ninja > in the root of the build tree. > I miss something. If I could reproduce the problem, I would investigate it. > > >> >>> On Tue, Jun 13, 2017 at 7:41 AM Serge Pavlov >>> wrote: >>> I cannot reproduce such fail, so I can only guess how changes made in https://reviews.llvm.org/rL303756 and https://reviews.llvm.org/rL303741 could cause such problem. Behavior of `Driver::BuildCompilation` is changed so that it returns null pointer if errors occur during driver argument parse. It is called in `CompilationDatabase.cpp` from `stripPositionalArgs`. The call stack at this point is: stripPositionalArgs clang::tooling::FixedCompilationDatabase::loadFromCommandLine clang::tooling::CommonOptionsParser::CommonOptionsParser clang::tidy::clangTidyMain main `FixedCompilationDatabase::loadFromCommandLine` returns null and CommonOptionsParser uses another method to create compilation database. The output "Compile command not found" means that no input file were found in `ClangTool::run`. Maybe some file names are nulls? Thanks, --Serge 2017-06-13 3:42 GMT+07:00 David Blaikie : > I've been seeing errors from this test recently: > > Command Output (stderr): > -- > 1 error generated. > Error while processing /usr/local/google/home/ > blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang- > tidy/diagnostic.cpp.nonexistent.cpp. > /usr/local/google/home/blaikie/dev/llvm/src/tools/ > clang/tools/extra/test/clang-tidy/diagnostic.cpp:10:12: error: > expected string not found in input > // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' > to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal- > conversion] >^ > :2:1: note: scanning from here > Skipping /usr/local/google/home/blaikie/dev/llvm/src/tools/ > clang/tools/extra/test/clang-tidy/diagnostic.cpp. Compile command not > found. > ^ > :2:1: note: with expression "@LINE+2" equal to "12" > Skipping /usr/local/google/home/blaikie/dev/llvm/src/tools/ > clang/tools/extra/test/clang-tidy/diagnostic.cpp. Compile command not > found. > ^ > > > Specifically, the output is: > $ ./bin/clang-tidy > -checks='-*,clang-diagnostic-*,google-explicit-constructor' > /usr/local/google/home/blaikie/dev/llvm/src/tools/ > clang/tools/extra/test/clang-tidy/diagnostic.cpp -- > -fan-unknown-option 2>&1error: unknown > argument: '-fan-unknown-option' > Skipping > /usr/local/google/home/blaikie/dev/llvm/src/tools/ > clang/tools/extra/test/clang-tidy/diagnostic.cpp. Compile command not > found. > > > Does this look like it might be related to any of your changes in this > area? Perhaps the error due to unknown argument is causing clang-tidy not > to continue on to run the check & report the warning? > > > On Wed, May 24, 2017 at 3:51 AM Serge Pavlov via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: sepavloff >> Date: Wed May 24 05:50:56 2017 >> New Revision: 303735 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=303735&view=rev >> Log: >> Modify test so that it looks for patterns in stderr as well >> >> With the change https://reviews.llvm.org/D33013 driver will not build >> compilation object if command line is invalid, in particular, if >> unrecognized option is provided. In such cases it will prints >>
[PATCH] D34238: clang-format: Do not binpack initialization lists
djasper added a comment. I am fine not bin-packing when the last element has a trailing comma. But lets not special case assignments. https://reviews.llvm.org/D34238 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34238: clang-format: Do not binpack initialization lists
Typz updated this revision to Diff 102672. Typz added a comment. fix unit tests https://reviews.llvm.org/D34238 Files: lib/Format/ContinuationIndenter.cpp unittests/Format/FormatTest.cpp unittests/Format/FormatTestComments.cpp Index: unittests/Format/FormatTestComments.cpp === --- unittests/Format/FormatTestComments.cpp +++ unittests/Format/FormatTestComments.cpp @@ -1032,16 +1032,31 @@ " , // comment\n" " };")); verifyFormat("static SomeType type = {aaa, // comment for aa...\n" - "bbb, ccc};"); + "bbb,\n" + "ccc};"); + verifyFormat("static SomeType type{aaa, // comment for aa...\n" + " bbb, ccc};"); verifyFormat("static SomeType type = {aaa,\n" "// comment for bb\n" - "bbb, ccc};"); + "bbb,\n" + "ccc};"); + verifyFormat("static SomeType type{aaa,\n" + " // comment for bb\n" + " bbb, ccc};"); verifyGoogleFormat( "static SomeType type = {aaa, // comment for aa...\n" - "bbb, ccc};"); + "bbb,\n" + "ccc};"); + verifyGoogleFormat( + "static SomeType type{aaa, // comment for aa...\n" + " bbb, ccc};"); verifyGoogleFormat("static SomeType type = {aaa,\n" "// comment for bb\n" - "bbb, ccc};"); + "bbb,\n" + "ccc};"); + verifyGoogleFormat("static SomeType type{aaa,\n" + " // comment for bb\n" + " bbb, ccc};"); verifyFormat("S s = {{a, b, c}, // Group #1\n" " {d, e, f}, // Group #2\n" Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -5699,7 +5699,8 @@ // A trailing comma should still lead to an enforced line break. EXPECT_EQ("vector SomeVector = {\n" "// aaa\n" -"1, 2,\n" +"1,\n" + "2,\n" "};", format("vector SomeVector = { // aaa\n" "1, 2, };")); @@ -5783,10 +5784,17 @@ verifyFormat("static const uint16_t CallerSavedRegs64Bit[] = {\n" "X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" "X86::R8, X86::R9, X86::R10, X86::R11, 0};"); - verifyFormat("static const uint16_t CallerSavedRegs64Bit[] = {\n" - "X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" - "// Separating comment.\n" - "X86::R8, X86::R9, X86::R10, X86::R11, 0};"); + verifyFormat("static const uint16_t CallerSavedRegs64Bit[] = {X86::RAX,\n" + "X86::RDX,\n" + "X86::RCX,\n" + "X86::RSI,\n" + "X86::RDI,\n" + "// Separating comment.\n" + "X86::R8,\n" + "X86::R9,\n" + "X86::R10,\n" + "X86::R11,\n" + "0};"); verifyFormat("static const uint16_t CallerSavedRegs64Bit[] = {\n" "// Leading comment\n" "X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,\n" @@ -5863,8 +5871,10 @@ " , a, aa, a, aaa}};"); // No column layout should be used here. - verifyFormat("aaa = {aaa, 0, 0,\n" - " b};"); + verifyFormat("aaa = {a,\n" + " ,\n" + "
[PATCH] D33406: PR28129 expand vector oparation to an IR constant.
dtemirbulatov updated this revision to Diff 102673. dtemirbulatov added a reviewer: hfinkel. dtemirbulatov added a comment. Update after http://lists.llvm.org/pipermail/llvm-dev/2017-June/114120.html. Added 0x1b(_CMP_FALSE_OS), 0x1f(_CMP_TRUE_US) handling. https://reviews.llvm.org/D33406 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c Index: test/CodeGen/avx-builtins.c === --- test/CodeGen/avx-builtins.c +++ test/CodeGen/avx-builtins.c @@ -1427,3 +1427,51 @@ // CHECK: extractelement <8 x float> %{{.*}}, i32 0 return _mm256_cvtss_f32(__a); } + +__m256 test_mm256_cmp_ps_true(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_true + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_pd_false(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_false + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_ps_strue(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_strue + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OS); +} + +__m256 test_mm256_cmp_pd_sfalse(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_sfalse + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OS); +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7930,12 +7930,32 @@ ID = Intrinsic::x86_sse_cmp_ps; break; case X86::BI__builtin_ia32_cmpps256: + // _CMP_TRUE_UQ, _CMP_TRUE_US would produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produces 0, 0... + if (CC == 0xf || CC == 0xb || CC == 0x1b || CC == 0x1f) { + Value *Constant = (CC == 0xf || CC == 0x1f) ? +llvm::Constant::getAllOnesValue(Builder.getInt32Ty()) : +llvm::Constant::getNullValue(Builder.getInt32Ty()); + Value *Vec = Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(), + Constant); + return Builder.CreateBitCast(Vec, Ops[0]->getType()); + } ID = Intrinsic::x86_avx_cmp_ps_256; break; case X86::BI__builtin_ia32_cmppd: ID = Intrinsic::x86_sse2_cmp_pd; break; case X86::BI__builtin_ia32_cmppd256: + // _CMP_TRUE_UQ, _CMP_TRUE_US would produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produces 0, 0... + if (CC == 0xf || CC == 0xb || CC == 0x1b || CC == 0x1f) { + Value *Constant = (CC == 0xf || CC == 0x1f) ? +llvm::Constant::getAllOnesValue(Builder.getInt64Ty()) : +llvm::Constant::getNullValue(Builder.getInt64Ty()); + Value *Vec = Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(), + Constant); + return Builder.CreateBitCast(Vec, Ops[0]->getType()); + } ID = Intrinsic::x86_avx_cmp_pd_256; break; } Index: test/CodeGen/avx-builtins.c === --- test/CodeGen/avx-builtins.c +++ test/CodeGen/avx-builtins.c @@ -1427,3 +1427,51 @@ // CHECK: extractelement <8 x float> %{{.*}}, i32 0 return _mm256_cvtss_f32(__a); } + +__m256 test_mm256_cmp_ps_true(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_true + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_pd_false(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_false + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_ps_strue(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_strue + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OS); +} + +__m256 test_mm256_cmp_pd_sfalse(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_sfalse + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OS); +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7930,12 +7930,32 @@ ID = Intrinsic::x86_sse_cmp_ps; break; case X86::BI__builtin_ia32_cmpps256: + // _CMP_TRUE_UQ, _CMP_TRUE_US would produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produces 0, 0... + if (CC == 0xf || CC == 0xb || CC == 0x1b || CC == 0x1f) { + Value *Constant = (CC == 0xf || CC == 0x1f) ? +
[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)
a.sidorin added a comment. Hello Peter, `if (!ToDecl) return nullptr;` is used if original node is always non-null. `if(!ToDecl && FromDecl) return nullptr;` is used if original node can be null. If the imported node is null, the result of import is null as well so such import is OK. `ObjectXY::Create(...Import(FromDecl))` is often used for source locations - as I guess, invalid source location is OK usually. It can also be used if we know that node should already be imported, but usually indicates a potential error. https://reviews.llvm.org/D32751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
GorNishanov accepted this revision. GorNishanov added a comment. This revision is now accepted and ready to land. LGTM Comment at: test/CodeGenCoroutines/coro-await.cpp:301 + +// Verifies that we don't chrash when returning an lvalue from a await_resume() +// expression. s/chrash/crash s/a await_resume/an await_resume/ https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)
a.sidorin updated this revision to Diff 102679. a.sidorin marked an inline comment as done. a.sidorin added a comment. Herald added a subscriber: kristof.beyls. Add a FIXME. https://reviews.llvm.org/D32751 Files: lib/AST/ASTImporter.cpp test/ASTMerge/namespace/Inputs/namespace1.cpp test/ASTMerge/namespace/Inputs/namespace2.cpp test/ASTMerge/namespace/test.cpp Index: test/ASTMerge/namespace/test.cpp === --- test/ASTMerge/namespace/test.cpp +++ test/ASTMerge/namespace/test.cpp @@ -1,6 +1,17 @@ -// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp -// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp -// RUN: not %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.1.ast %S/Inputs/namespace1.cpp +// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t.2.ast %S/Inputs/namespace2.cpp +// RUN: not %clang_cc1 -std=c++1z -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s + +static_assert(TestAliasName::z == 4); +static_assert(ContainsInline::z == 10); + +void testImport() { + typedef TestUnresolvedTypenameAndValueDecls::Derived Imported; + Imported a; // Successfull instantiation + static_assert(sizeof(Imported::foo) == sizeof(int)); + static_assert(sizeof(TestUnresolvedTypenameAndValueDecls::Derived::NewUnresolvedUsingType) == sizeof(double)); +} + // CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float') // CHECK: namespace1.cpp:16:16: note: declared here with type 'float' Index: test/ASTMerge/namespace/Inputs/namespace2.cpp === --- test/ASTMerge/namespace/Inputs/namespace2.cpp +++ test/ASTMerge/namespace/Inputs/namespace2.cpp @@ -15,3 +15,46 @@ namespace N3 { extern double z; } + +namespace Enclosing { +namespace Nested { + const int z = 4; +} +} + +namespace ContainsInline { + inline namespace Inline { +const int z = 10; + } +} + +namespace TestAliasName = Enclosing::Nested; +// NOTE: There is no warning on this alias. +namespace AliasWithSameName = Enclosing::Nested; + +namespace TestUsingDecls { + +namespace A { +void foo(); +} +namespace B { +using A::foo; // <- a UsingDecl creating a UsingShadow +} + +}// end namespace TestUsingDecls + +namespace TestUnresolvedTypenameAndValueDecls { + +template class Base; +template class Derived : public Base { +public: + using typename Base::foo; + using Base::bar; + typedef typename Derived::foo NewUnresolvedUsingType; +}; + +} // end namespace TestUnresolvedTypenameAndValueDecls + +namespace TestUsingNamespace { + using namespace Enclosing; +} Index: test/ASTMerge/namespace/Inputs/namespace1.cpp === --- test/ASTMerge/namespace/Inputs/namespace1.cpp +++ test/ASTMerge/namespace/Inputs/namespace1.cpp @@ -15,3 +15,13 @@ namespace N3 { extern float z; } + +namespace AliasWithSameName = N3; + +namespace TestUnresolvedTypenameAndValueDecls { +template class Base { +public: + typedef T foo; + void bar(); +}; +} Index: lib/AST/ASTImporter.cpp === --- lib/AST/ASTImporter.cpp +++ lib/AST/ASTImporter.cpp @@ -58,7 +58,7 @@ QualType VisitExtVectorType(const ExtVectorType *T); QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T); QualType VisitFunctionProtoType(const FunctionProtoType *T); -// FIXME: UnresolvedUsingType +QualType VisitUnresolvedUsingType(const UnresolvedUsingType *T); QualType VisitParenType(const ParenType *T); QualType VisitTypedefType(const TypedefType *T); QualType VisitTypeOfExprType(const TypeOfExprType *T); @@ -128,8 +128,8 @@ TemplateParameterList *ImportTemplateParameterList( TemplateParameterList *Params); TemplateArgument ImportTemplateArgument(const TemplateArgument &From); -TemplateArgumentLoc ImportTemplateArgumentLoc( -const TemplateArgumentLoc &TALoc, bool &Error); +Optional ImportTemplateArgumentLoc( +const TemplateArgumentLoc &TALoc); bool ImportTemplateArguments(const TemplateArgument *FromArgs, unsigned NumFromArgs, SmallVectorImpl &ToArgs); @@ -142,10 +142,12 @@ bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To); bool IsStructuralMatch(VarTemplateDecl *From, VarTemplateDecl *To); Decl *VisitDecl(Decl *D); +Decl *VisitEmptyDecl(EmptyDecl *D); Decl *VisitAccessSpecDecl(AccessSpecDecl *D); Decl *VisitStaticAssertDecl(StaticAssertDecl *D); Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D); Decl *VisitNamespaceDecl(NamespaceDecl *D); +Decl *VisitNamespaceAliasDecl(NamespaceAli
[PATCH] D32751: [ASTImporter] Support new kinds of declarations (mostly Using*)
a.sidorin added inline comments. Comment at: lib/AST/ASTImporter.cpp:2993 + return nullptr; + } + szepet wrote: > nit: As I see these cases typically handled in the way: > > ``` > FrPattern = .; > ToPattern = ..; > if(FrPattern && !ToPattern) > ``` > Just to avoid the nested ifstmt. The logic is a bit more complicated. There are 3 cases: # Both `FromPattern` and `ToPattern` are `nullptr`s. Just continue. # `FromPattern` is non-null and `ToPattern` is null. Return error (`nullptr`). # Both `FromPattern` and `ToPattern` are `nullptr`s. Do the `set...` action. So, it will require nested `if`s or a code like: ``` if (FromPattern && ToPattern) set... if (FromPattern && !ToPattern) return nullptr; ``` Comment at: lib/AST/ASTImporter.cpp:3000 +else + // FIXME: We return a nullptr here but the definition is already created + // and available with lookups. How to fix this?.. szepet wrote: > I dont see the problem with moving these up , collect nad investigate them in > a smallset before the Create function, then adding them to the created > ToUsing decl. It could be done as a follow up patch, dont want to mark it as > a blocking issue. There is a chicken and egg problem: both UsingShadowDecl and UsingDecl reference each other and UsingShadowDecl gets referenced UsingDecl as a ctor argument. If you have a good idea on how to resolve this dependency correctly, please point me. https://reviews.llvm.org/D32751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33406: PR28129 expand vector oparation to an IR constant.
spatel added a comment. Functionally, I think this is correct and complete now. See inline for some nits. Comment at: lib/CodeGen/CGBuiltin.cpp:7925 // We can't handle 8-31 immediates with native IR, use the intrinsic. Intrinsic::ID ID; Fix comment to something like: "Except for predicates that create constants, ..." Comment at: lib/CodeGen/CGBuiltin.cpp:7933 case X86::BI__builtin_ia32_cmpps256: + // _CMP_TRUE_UQ, _CMP_TRUE_US would produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produces 0, 0... would produce --> produces Comment at: lib/CodeGen/CGBuiltin.cpp:7939 +llvm::Constant::getNullValue(Builder.getInt32Ty()); + Value *Vec = Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(), + Constant); Formatting: over 80-col limit. Comment at: lib/CodeGen/CGBuiltin.cpp:7949 case X86::BI__builtin_ia32_cmppd256: + // _CMP_TRUE_UQ, _CMP_TRUE_US would produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produces 0, 0... would produce --> produces Comment at: lib/CodeGen/CGBuiltin.cpp:7955 +llvm::Constant::getNullValue(Builder.getInt64Ty()); + Value *Vec = Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(), + Constant); Formatting: over 80-col limit. https://reviews.llvm.org/D33406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305480 - [analyzer]: Improve test handling with multiple constraint managers
Author: ddcc Date: Thu Jun 15 12:05:07 2017 New Revision: 305480 URL: http://llvm.org/viewvc/llvm-project?rev=305480&view=rev Log: [analyzer]: Improve test handling with multiple constraint managers Summary: Modify the test infrastructure to properly handle tests that require z3, and merge together the output of all tests on success. This is required for D28954. Reviewers: dcoughlin, zaks.anna, NoQ, xazax.hun Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33308 Modified: cfe/trunk/test/Analysis/analyzer_test.py Modified: cfe/trunk/test/Analysis/analyzer_test.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer_test.py?rev=305480&r1=305479&r2=305480&view=diff == --- cfe/trunk/test/Analysis/analyzer_test.py (original) +++ cfe/trunk/test/Analysis/analyzer_test.py Thu Jun 15 12:05:07 2017 @@ -5,24 +5,39 @@ import lit.TestRunner class AnalyzerTest(lit.formats.ShTest): def execute(self, test, litConfig): -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=range') +results = [] -if result.code == lit.Test.FAIL: -return result +# Parse any test requirements ('REQUIRES: ') +saved_test = test +lit.TestRunner.parseIntegratedTestScript(test) + +if 'z3' not in test.requires: +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=range')) + +if results[-1].code == lit.Test.FAIL: +return results[-1] # If z3 backend available, add an additional run line for it if test.config.clang_staticanalyzer_z3 == '1': -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')) -return result +# Combine all result outputs into the last element +for x in results: +if x != results[-1]: +results[-1].output = x.output + results[-1].output + +if results: +return results[-1] +return lit.Test.Result(lit.Test.UNSUPPORTED, +"Test requires the following unavailable features: z3") def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): saved_substitutions = list(test.config.substitutions) test.config.substitutions.append(('%analyze', substitution)) result = lit.TestRunner.executeShTest(test, litConfig, - self.execute_external) +self.execute_external) test.config.substitutions = saved_substitutions return result ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33308: [analyzer]: Improve test handling with multiple constraint managers
This revision was automatically updated to reflect the committed changes. Closed by commit rL305480: [analyzer]: Improve test handling with multiple constraint managers (authored by ddcc). Changed prior to commit: https://reviews.llvm.org/D33308?vs=99394&id=102682#toc Repository: rL LLVM https://reviews.llvm.org/D33308 Files: cfe/trunk/test/Analysis/analyzer_test.py Index: cfe/trunk/test/Analysis/analyzer_test.py === --- cfe/trunk/test/Analysis/analyzer_test.py +++ cfe/trunk/test/Analysis/analyzer_test.py @@ -5,24 +5,39 @@ class AnalyzerTest(lit.formats.ShTest): def execute(self, test, litConfig): -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=range') +results = [] -if result.code == lit.Test.FAIL: -return result +# Parse any test requirements ('REQUIRES: ') +saved_test = test +lit.TestRunner.parseIntegratedTestScript(test) + +if 'z3' not in test.requires: +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=range')) + +if results[-1].code == lit.Test.FAIL: +return results[-1] # If z3 backend available, add an additional run line for it if test.config.clang_staticanalyzer_z3 == '1': -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')) -return result +# Combine all result outputs into the last element +for x in results: +if x != results[-1]: +results[-1].output = x.output + results[-1].output + +if results: +return results[-1] +return lit.Test.Result(lit.Test.UNSUPPORTED, +"Test requires the following unavailable features: z3") def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): saved_substitutions = list(test.config.substitutions) test.config.substitutions.append(('%analyze', substitution)) result = lit.TestRunner.executeShTest(test, litConfig, - self.execute_external) +self.execute_external) test.config.substitutions = saved_substitutions return result Index: cfe/trunk/test/Analysis/analyzer_test.py === --- cfe/trunk/test/Analysis/analyzer_test.py +++ cfe/trunk/test/Analysis/analyzer_test.py @@ -5,24 +5,39 @@ class AnalyzerTest(lit.formats.ShTest): def execute(self, test, litConfig): -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=range') +results = [] -if result.code == lit.Test.FAIL: -return result +# Parse any test requirements ('REQUIRES: ') +saved_test = test +lit.TestRunner.parseIntegratedTestScript(test) + +if 'z3' not in test.requires: +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=range')) + +if results[-1].code == lit.Test.FAIL: +return results[-1] # If z3 backend available, add an additional run line for it if test.config.clang_staticanalyzer_z3 == '1': -result = self.executeWithAnalyzeSubstitution( -test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') +results.append(self.executeWithAnalyzeSubstitution( +saved_test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3')) -return result +# Combine all result outputs into the last element +for x in results: +if x != results[-1]: +results[-1].output = x.output + results[-1].output + +if results: +return results[-1] +return lit.Test.Result(lit.Test.UNSUPPORTED, +"Test requires the following unavailable features: z3") def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): saved_substitutions = list(test.config.substitutions) test.config.substitutions.append(('%analyze', substitution)) result = lit.TestRunner.executeShTest(test, litConfig, - self.execute_external) +self.execute_external) test.config.substitutions = saved_substitutions return result ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
GorNishanov requested changes to this revision. GorNishanov added inline comments. This revision now requires changes to proceed. Comment at: lib/CodeGen/CGCoroutine.cpp:255 + +static QualType getCoroutineSuspendExprReturnType(const ASTContext &Ctx, + const CoroutineSuspendExpr *E) { #ifndef NDEBUG ... #endif https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
GorNishanov accepted this revision. GorNishanov added a comment. This revision is now accepted and ready to land. LGTM with changes https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
GorNishanov added a comment. Added John McCall as he made great suggestions last time I touched emitSuspendExpression https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
GorNishanov added inline comments. Comment at: test/CodeGenCoroutines/coro-await.cpp:310 + int& x = co_await a; + // CHECK: await2.ready: + // CHECK-NEXT: %[[RES2:.+]] = call dereferenceable(4) i32* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %ref.tmp{{.+}}) In release compiler, labels won't have friendly names. //CHECK: await2.ready will fail https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305482 - Apply summary-based dead stripping to regular LTO modules with summaries.
Author: pcc Date: Thu Jun 15 12:26:13 2017 New Revision: 305482 URL: http://llvm.org/viewvc/llvm-project?rev=305482&view=rev Log: Apply summary-based dead stripping to regular LTO modules with summaries. If a regular LTO module has a summary index, then instead of linking it into the combined regular LTO module right away, add it to the combined summary index and associate it with a special module that represents the combined regular LTO module. Any such modules are linked during LTO::run(), at which time we use the results of summary-based dead stripping to control whether to link prevailing symbols. Differential Revision: https://reviews.llvm.org/D33922 Added: cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/thinlto-multi-module.ll Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=305482&r1=305481&r2=305482&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 15 12:26:13 2017 @@ -964,11 +964,11 @@ Expected clang::FindThinL if (!BMsOrErr) return BMsOrErr.takeError(); - // The bitcode file may contain multiple modules, we want the one with a - // summary. + // The bitcode file may contain multiple modules, we want the one that is + // marked as being the ThinLTO module. for (BitcodeModule &BM : *BMsOrErr) { -Expected HasSummary = BM.hasSummary(); -if (HasSummary && *HasSummary) +Expected LTOInfo = BM.getLTOInfo(); +if (LTOInfo && LTOInfo->IsThinLTO) return BM; } Added: cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll?rev=305482&view=auto == --- cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll (added) +++ cfe/trunk/test/CodeGen/Inputs/thinlto-multi-module.ll Thu Jun 15 12:26:13 2017 @@ -0,0 +1,9 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @f2() { + ret void +} + +!0 = !{i32 1, !"ThinLTO", i32 0} +!llvm.module.flags = !{ !0 } Modified: cfe/trunk/test/CodeGen/thinlto-multi-module.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-multi-module.ll?rev=305482&r1=305481&r2=305482&view=diff == --- cfe/trunk/test/CodeGen/thinlto-multi-module.ll (original) +++ cfe/trunk/test/CodeGen/thinlto-multi-module.ll Thu Jun 15 12:26:13 2017 @@ -3,8 +3,8 @@ ; RUN: opt -module-summary -o %t1.o %s ; RUN: llvm-lto -thinlto -o %t %t1.o -; RUN: opt -o %t2.o %S/Inputs/thinlto_backend.ll -; RUN: llvm-cat -b -o %t1cat.o %t1.o %t2.o +; RUN: opt -module-summary -o %t2.o %S/Inputs/thinlto-multi-module.ll +; RUN: llvm-cat -b -o %t1cat.o %t2.o %t1.o ; RUN: cp %t1cat.o %t1.o ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34156: [LTO] Enable module summary emission by default for regular LTO
pcc accepted this revision. pcc added a comment. This revision is now accepted and ready to land. Please confirm that we can still self host with full LTO now that https://reviews.llvm.org/D33922 has landed. LGTM otherwise. Thanks! https://reviews.llvm.org/D34156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well
https://sarcasm.github.io/notes/dev/compilation-database.html#cmake If you enable the CMAKE_EXPORT_COMPILE_COMMANDS option in cmake (& have a sufficiently recent cmake), then CMake will generate a compile_commands.json in the root of the build tree. The test finds this & fails, instead of finding no compilation database & succeeding. (to use this, you can then symlink from the root of the source tree to point to this in your build tree - this is how I get YCM to work for my LLVM builds & could work for other clang tools as well) On Thu, Jun 15, 2017 at 7:51 AM Serge Pavlov wrote: > 2017-06-15 2:43 GMT+07:00 David Blaikie : > >> >> >> On Wed, Jun 14, 2017, 8:17 AM Serge Pavlov wrote: >> >>> 2017-06-14 4:24 GMT+07:00 David Blaikie : >>> Ah, I find that the test passes if I remove the compile_commands.json file from my build directory (I have Ninja configured to generate a compile_commands.json file). Looks like what happens is it finds the compilation database and fails hard when the database doesn't contain a compile command for the file in question. If the database is not found, it falls back to some basic command behavior, perhaps? >>> You are right, constructor of `CommonOptionsParser` calls >>> `autoDetectFromSource` or `autoDetectFromDirectory` prior to final >>> construction of `FixedCompilationDatabase. >>> >>> Is there some way this test could be fixed to cope with this, otherwise it seems to get in the way of people actually using clang tools in their LLVM/Clang build environment? >>> IIUC, presence of stale compilation database file in test directory >>> could break many tests. I don't understand why only diagnostic.cpp fails, >>> probably there is something wrong with the clang-tidy application cleanup >>> in this case? >>> >> >> Except it's neither stale nor in the test directory. >> >> It's the up to date/useful/used compile_commands.json generated by ninja >> in the root of the build tree. >> > > I miss something. If I could reproduce the problem, I would investigate it. > > >> >> >>> On Tue, Jun 13, 2017 at 7:41 AM Serge Pavlov wrote: > I cannot reproduce such fail, so I can only guess how changes made in > https://reviews.llvm.org/rL303756 and > https://reviews.llvm.org/rL303741 could cause such problem. Behavior > of `Driver::BuildCompilation` is changed so that it returns null pointer > if > errors occur during driver argument parse. It is called in > `CompilationDatabase.cpp` from `stripPositionalArgs`. The call stack at > this point is: > stripPositionalArgs > clang::tooling::FixedCompilationDatabase::loadFromCommandLine > clang::tooling::CommonOptionsParser::CommonOptionsParser > clang::tidy::clangTidyMain > main > `FixedCompilationDatabase::loadFromCommandLine` returns null and > CommonOptionsParser uses another method to create compilation database. > The > output "Compile command not found" means that no input file were found in > `ClangTool::run`. Maybe some file names are nulls? > > > Thanks, > --Serge > > 2017-06-13 3:42 GMT+07:00 David Blaikie : > >> I've been seeing errors from this test recently: >> >> Command Output (stderr): >> -- >> 1 error generated. >> Error while processing >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp.nonexistent.cpp. >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp:10:12: >> error: expected string not found in input >> // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' >> to 'int' changes value from 1.5 to 1 >> [clang-diagnostic-literal-conversion] >>^ >> :2:1: note: scanning from here >> Skipping >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp. >> Compile command not found. >> ^ >> :2:1: note: with expression "@LINE+2" equal to "12" >> Skipping >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp. >> Compile command not found. >> ^ >> >> >> Specifically, the output is: >> $ ./bin/clang-tidy >> -checks='-*,clang-diagnostic-*,google-explicit-constructor' >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp >> -- -fan-unknown-option 2>&1error: unknown >> argument: '-fan-unknown-option' >> Skipping >> /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/extra/test/clang-tidy/diagnostic.cpp. >> Compile command not found. >> >> >> Does this look like it might be related to any of your changes in >> this area? Perhaps the error due to unknown argum
Re: r305425 - [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments,
the bots complain about a leak in the new test code. Please fix/revert ASAP. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5691/steps/check-clang%20asan/logs/stdio =28905==ERROR: LeakSanitizer: detected memory leaks Direct leak of 216 byte(s) in 1 object(s) allocated from: #0 0x4eca08 in __interceptor_malloc /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66 #1 0xefcb8f in clang::MacroArgs::create(clang::MacroInfo const*, llvm::ArrayRef, bool, clang::Preprocessor&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Lex/MacroArgs.cpp:51:27 #2 0x54dc56 in (anonymous namespace)::LexerTest_DontOverallocateStringifyArgs_Test::TestBody() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Lex/LexerTest.cpp:405:19 #3 0x65154e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #4 0x65154e in testing::Test::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 #5 0x653848 in testing::TestInfo::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #6 0x654b86 in testing::TestCase::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #7 0x675586 in testing::internal::UnitTestImpl::RunAllTests() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #8 0x67487e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #9 0x67487e in testing::UnitTest::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 #10 0x634bfe in RUN_ALL_TESTS /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #11 0x634bfe in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #12 0x7f016e9cb82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) On Wed, Jun 14, 2017 at 4:09 PM, Erich Keane via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: erichkeane > Date: Wed Jun 14 18:09:01 2017 > New Revision: 305425 > > URL: http://llvm.org/viewvc/llvm-project?rev=305425&view=rev > Log: > [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, > correct getNumArguments > > StringifiedArguments is allocated (resized) based on the size the > getNumArguments function. However, this function ACTUALLY currently > returns the amount of total UnexpArgTokens which is minimum the same as > the new implementation of getNumMacroArguments, since empty/omitted > arguments > result in 1 UnexpArgToken, and included ones at minimum include 2 > (1 for the arg itself, 1 for eof). > > This patch renames the otherwise unused getNumArguments to be more clear > that it is the number of arguments that the Macro expects, and thus the > maximum > number that can be stringified. This patch also replaces the explicit > memset > (which results in value instantiation of the new tokens, PLUS clearing the > memory) with brace initialization. > > Differential Revision: https://reviews.llvm.org/D32046 > > Modified: > cfe/trunk/include/clang/Lex/MacroArgs.h > cfe/trunk/lib/Lex/MacroArgs.cpp > cfe/trunk/unittests/Lex/LexerTest.cpp > > Modified: cfe/trunk/include/clang/Lex/MacroArgs.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ > clang/Lex/MacroArgs.h?rev=305425&r1=305424&r2=305425&view=diff > > == > --- cfe/trunk/include/clang/Lex/MacroArgs.h (original) > +++ cfe/trunk/include/clang/Lex/MacroArgs.h Wed Jun 14 18:09:01 2017 > @@ -53,9 +53,12 @@ class MacroArgs { >/// Preprocessor owns which we use to avoid thrashing malloc/free. >MacroArgs *ArgCache; > > - MacroArgs(unsigned NumToks, bool varargsElided) > -: NumUnexpArgTokens(NumToks), VarargsElided(varargsElided), > - ArgCache(nullptr) {} > + /// MacroArgs - The number of arguments the invoked macro expects. > + unsigned NumMacroArgs; > + > + MacroArgs(unsigned NumToks, bool varargsElided, unsigned MacroArgs) > + : NumUnexpArgTokens(NumToks), VarargsElided(varargsElided), > +ArgCache(nullptr), NumMacroArgs(MacroArgs) {} >~MacroArgs() = default; > > public: > @@ -94,10 +97,9 @@ public: >SourceLocation ExpansionLocStart, >SourceLocation ExpansionLocEnd); > > - /// getNumArguments - Return the number of arguments passed into this > macro >
[PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments
kcc added a comment. the bots complain about a leak in the new test code. Please fix/revert ASAP. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5691/steps/check-clang%20asan/logs/stdio 28905==ERROR: LeakSanitizer: detected memory leaks == Direct leak of 216 byte(s) in 1 object(s) allocated from: #0 0x4eca08 in __interceptor_malloc /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66 #1 0xefcb8f in clang::MacroArgs::create(clang::MacroInfo const*, llvm::ArrayRef, bool, clang::Preprocessor&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Lex/MacroArgs.cpp:51:27 #2 0x54dc56 in (anonymous namespace)::LexerTest_DontOverallocateStringifyArgs_Test::TestBody() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Lex/LexerTest.cpp:405:19 #3 0x65154e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #4 0x65154e in testing::Test::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 #5 0x653848 in testing::TestInfo::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #6 0x654b86 in testing::TestCase::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #7 0x675586 in testing::internal::UnitTestImpl::RunAllTests() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #8 0x67487e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #9 0x67487e in testing::UnitTest::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 #10 0x634bfe in RUN_ALL_TESTS /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #11 0x634bfe in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #12 0x7f016e9cb82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Repository: rL LLVM https://reviews.llvm.org/D32046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33304: [clang-tidy][Part1] Add a new module Android and three new checks.
yawanng updated this revision to Diff 102690. yawanng added a comment. Format change. https://reviews.llvm.org/D33304 Files: clang-tidy/CMakeLists.txt clang-tidy/android/AndroidTidyModule.cpp clang-tidy/android/CMakeLists.txt clang-tidy/android/FileOpenFlagCheck.cpp clang-tidy/android/FileOpenFlagCheck.h clang-tidy/plugin/CMakeLists.txt clang-tidy/tool/CMakeLists.txt clang-tidy/tool/ClangTidyMain.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/android-file-open-flag.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/index.rst test/clang-tidy/android-file-open-flag.cpp unittests/clang-tidy/CMakeLists.txt Index: unittests/clang-tidy/CMakeLists.txt === --- unittests/clang-tidy/CMakeLists.txt +++ unittests/clang-tidy/CMakeLists.txt @@ -25,6 +25,7 @@ clangFrontend clangLex clangTidy + clangTidyAndroidModule clangTidyGoogleModule clangTidyLLVMModule clangTidyMiscModule Index: test/clang-tidy/android-file-open-flag.cpp === --- /dev/null +++ test/clang-tidy/android-file-open-flag.cpp @@ -0,0 +1,110 @@ +// RUN: %check_clang_tidy %s android-file-open-flag %t + +#define O_RDWR 1 +#define O_EXCL 2 +#define __O_CLOEXEC 3 +#define O_CLOEXEC __O_CLOEXEC + +extern "C" int open(const char *fn, int flags, ...); +extern "C" int open64(const char *fn, int flags, ...); +extern "C" int openat(int dirfd, const char *pathname, int flags, ...); + +void a() { + open("filename", O_RDWR); + // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: O_RDWR | O_CLOEXEC + open("filename", O_RDWR | O_EXCL); + // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'open' should use O_CLOEXEC where + // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC +} + +void b() { + open64("filename", O_RDWR); + // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: O_RDWR | O_CLOEXEC + open64("filename", O_RDWR | O_EXCL); + // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'open64' should use O_CLOEXEC where + // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC +} + +void c() { + openat(0, "filename", O_RDWR); + // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: O_RDWR | O_CLOEXEC + openat(0, "filename", O_RDWR | O_EXCL); + // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: 'openat' should use O_CLOEXEC where + // CHECK-FIXES: O_RDWR | O_EXCL | O_CLOEXEC +} + +void f() { + open("filename", 3); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'open' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: 3 | O_CLOEXEC + open64("filename", 3); + // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'open64' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: 3 | O_CLOEXEC + openat(0, "filename", 3); + // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'openat' should use O_CLOEXEC where possible [android-file-open-flag] + // CHECK-FIXES: 3 | O_CLOEXEC + + int flag = 3; + open("filename", flag); + // CHECK-MESSAGES-NOT: warning: + open64("filename", flag); + // CHECK-MESSAGES-NOT: warning: + openat(0, "filename", flag); + // CHECK-MESSAGES-NOT: warning: +} + +namespace i { +int open(const char *pathname, int flags, ...); +int open64(const char *pathname, int flags, ...); +int openat(int dirfd, const char *pathname, int flags, ...); + +void d() { + open("filename", O_RDWR); + // CHECK-MESSAGES-NOT: warning: + open64("filename", O_RDWR); + // CHECK-MESSAGES-NOT: warning: + openat(0, "filename", O_RDWR); + // CHECK-MESSAGES-NOT: warning: +} + +} // namespace i + +void e() { + open("filename", O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + open("filename", O_RDWR | O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + open("filename", O_RDWR | O_CLOEXEC | O_EXCL); + // CHECK-MESSAGES-NOT: warning: + open64("filename", O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + open64("filename", O_RDWR | O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + open64("filename", O_RDWR | O_CLOEXEC | O_EXCL); + // CHECK-MESSAGES-NOT: warning: + openat(0, "filename", O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + openat(0, "filename", O_RDWR | O_CLOEXEC); + // CHECK-MESSAGES-NOT: warning: + openat(0, "filename", O_RDWR | O_CLOEXEC | O_EXCL); + // CHECK-MESSAGES-NOT: warning: +} + +class G { +public: + int open(const char *pathname, int flags, ...); + int open64(const char *pathname, int flags, ...); + int openat(int dirfd, const char *pathname, int flags, ...); + + void h() { +open("filename", O_RDWR); +// CHECK-MESSAGES-NOT: warning: +open64("filename", O_RDWR); +// CHECK-MESSAGES-NOT: warning: +openat(0, "filename", O_RDWR); +// CHECK-MESSAGES-NOT: warning: + } +}; Index: docs/clang-tidy/index.r
RE: r305425 - [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments,
Ah, right… This function mallocs, and is usually tossed in the Preprocessor Cache, but I’m doing an end-run around that this time. I’ll see if it is better to put it into the PP Cache, or just call ‘free’ on it. Thanks! -Erich From: Kostya Serebryany [mailto:k...@google.com] Sent: Thursday, June 15, 2017 10:44 AM To: Keane, Erich Cc: cfe-commits Subject: Re: r305425 - [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, the bots complain about a leak in the new test code. Please fix/revert ASAP. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5691/steps/check-clang%20asan/logs/stdio =28905==ERROR: LeakSanitizer: detected memory leaks Direct leak of 216 byte(s) in 1 object(s) allocated from: #0 0x4eca08 in __interceptor_malloc /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66 #1 0xefcb8f in clang::MacroArgs::create(clang::MacroInfo const*, llvm::ArrayRef, bool, clang::Preprocessor&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Lex/MacroArgs.cpp:51:27 #2 0x54dc56 in (anonymous namespace)::LexerTest_DontOverallocateStringifyArgs_Test::TestBody() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Lex/LexerTest.cpp:405:19 #3 0x65154e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #4 0x65154e in testing::Test::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 #5 0x653848 in testing::TestInfo::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #6 0x654b86 in testing::TestCase::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #7 0x675586 in testing::internal::UnitTestImpl::RunAllTests() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #8 0x67487e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #9 0x67487e in testing::UnitTest::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 #10 0x634bfe in RUN_ALL_TESTS /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #11 0x634bfe in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #12 0x7f016e9cb82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) On Wed, Jun 14, 2017 at 4:09 PM, Erich Keane via cfe-commits mailto:cfe-commits@lists.llvm.org>> wrote: Author: erichkeane Date: Wed Jun 14 18:09:01 2017 New Revision: 305425 URL: http://llvm.org/viewvc/llvm-project?rev=305425&view=rev Log: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments StringifiedArguments is allocated (resized) based on the size the getNumArguments function. However, this function ACTUALLY currently returns the amount of total UnexpArgTokens which is minimum the same as the new implementation of getNumMacroArguments, since empty/omitted arguments result in 1 UnexpArgToken, and included ones at minimum include 2 (1 for the arg itself, 1 for eof). This patch renames the otherwise unused getNumArguments to be more clear that it is the number of arguments that the Macro expects, and thus the maximum number that can be stringified. This patch also replaces the explicit memset (which results in value instantiation of the new tokens, PLUS clearing the memory) with brace initialization. Differential Revision: https://reviews.llvm.org/D32046 Modified: cfe/trunk/include/clang/Lex/MacroArgs.h cfe/trunk/lib/Lex/MacroArgs.cpp cfe/trunk/unittests/Lex/LexerTest.cpp Modified: cfe/trunk/include/clang/Lex/MacroArgs.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroArgs.h?rev=305425&r1=305424&r2=305425&view=diff == --- cfe/trunk/include/clang/Lex/MacroArgs.h (original) +++ cfe/trunk/include/clang/Lex/MacroArgs.h Wed Jun 14 18:09:01 2017 @@ -53,9 +53,12 @@ class MacroArgs { /// Preprocessor owns which we use to avoid thrashing malloc/free. MacroArgs *ArgCache; - MacroArgs(unsigned NumToks, bool varargsElided) -: NumUnexpArgTokens(NumToks), VarargsElided(varargsElided), - ArgCache(nullptr) {} + /// MacroArgs - The number of arguments the invoked macro expects. + unsigned NumMacroArgs; + + MacroArgs(unsigned NumToks, bool varargsElided, unsigned MacroArgs) + : NumUnexpArgTokens(NumToks), VarargsE
[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis
zaks.anna added a comment. > -(Anna) Scan-build-py integration of the functionality is nearly finished > (see https://github.com/rizsotto/scan-build/issues/83) (--ctu switch performs > both analysis phases at once). This I think could go in a different patch, > but until we could keep the ctu-build.py and ctu-analyze.py scripts. Do you > agree? It's important to bring this patch into the LLVM repo so that it becomes part of the clang/llvm project and is used. The whole point of adding CTU integration to scan-build-py is to make sure that there is a single tool that all/most users could use; adding the patch to a fork does not accomplish that goal. Also, I am not a fan of developing on downstream branches and that is against the LLVM Developer policy due to all the reasons described here: http://www.llvm.org/docs/DeveloperPolicy.html#incremental-development. This development style leads to fragmentation of the community and the project. Unfortunately, we often see cases where large patches developed out of tree never make it in as a result of not following this policy and it would be great to avoid this in the future. > This I think could go in a different patch, but until we could keep the > ctu-build.py and ctu-analyze.py scripts. Do you agree? It would be best to just add the scan-build-py support to the tree, especially, since the new scrips are not tested. > -(Anna) Dumping the ASTs to the disk. We tried a version where, ASTs are not > dumped in the 1st phase, but is recreated each time a function definition is > needed from an external TU. It works fine, but the analysis time went up by > 20-30% on open source C projects. I am curious which optimization strategies you considered. An idea that @NoQ came up with was to serialize only the most used translation units. Another idea is to choose the TUs that a particular file has most dependencies on and only inline functions from those. What mode would you prefer? Would you pay the 20%-30% in speed but reduce the huge disk consumption? That might be a good option, especially, if you have not exhausted the ideas on how to optimize. > Is it OK to add this functionality in a next patch? Or should we it as an > optional feature right now? This depends on what the plan for going forward is. Specifically, if we do not need the serialization mode, you could remove that from this patch and add the new mode. If you think the serialization mode is essential going forward, we could have the other mode in a separate patch. (It would be useful to split out the serialization mode work into a separate patch so that we could revert it later on if we see that the other mode is better.) I see some changes to the compiler proper, such as ASTImporter, ASTContext, SourceManager. We should split those changes into a separate patch and ask for review from people working on those components. You can point back to this patch, which would contain the analyzer related changes, and state that the other patch is blocking this work. https://reviews.llvm.org/D30691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34182: [analyzer] Performance optimizations for the CloneChecker
teemperor updated this revision to Diff 102700. teemperor marked an inline comment as done. teemperor added a comment. - made saveHash static. https://reviews.llvm.org/D34182 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp === --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -78,9 +78,10 @@ // because reportSuspiciousClones() wants to search them for errors. std::vector AllCloneGroups; - Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(), - MinComplexityConstraint(MinComplexity), - MinGroupSizeConstraint(2), OnlyLargestCloneConstraint()); + Detector.findClones( + AllCloneGroups, RecursiveCloneTypeIIHashConstraint(), + MinGroupSizeConstraint(2), MinComplexityConstraint(MinComplexity), + RecursiveCloneTypeIIVerifyConstraint(), OnlyLargestCloneConstraint()); if (ReportSuspiciousClones) reportSuspiciousClones(BR, Mgr, AllCloneGroups); Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -381,9 +381,18 @@ return HashCode; } -size_t RecursiveCloneTypeIIConstraint::saveHash( -const Stmt *S, const Decl *D, -std::vector> &StmtsByHash) { +/// Generates and saves a hash code for the given Stmt. +/// \param S The given Stmt. +/// \param D The Decl containing S. +/// \param StmtsByHash Output parameter that will contain the hash codes for +///each StmtSequence in the given Stmt. +/// \return The hash code of the given Stmt. +/// +/// If the given Stmt is a CompoundStmt, this method will also generate +/// hashes for all possible StmtSequences in the children of this Stmt. +static size_t +saveHash(const Stmt *S, const Decl *D, + std::vector> &StmtsByHash) { llvm::MD5 Hash; ASTContext &Context = D->getASTContext(); @@ -474,6 +483,14 @@ void RecursiveCloneTypeIIConstraint::constrain( std::vector &Sequences) { + RecursiveCloneTypeIIHashConstraint Hash; + Hash.constrain(Sequences); + RecursiveCloneTypeIIVerifyConstraint Verify; + Verify.constrain(Sequences); +} + +void RecursiveCloneTypeIIHashConstraint::constrain( +std::vector &Sequences) { // FIXME: Maybe we can do this in-place and don't need this additional vector. std::vector Result; @@ -513,8 +530,7 @@ for (; i < StmtsByHash.size(); ++i) { // A different hash value means we have reached the end of the sequence. -if (PrototypeHash != StmtsByHash[i].first || -!areSequencesClones(StmtsByHash[i].second, Current.second)) { +if (PrototypeHash != StmtsByHash[i].first) { // The current sequence could be the start of a new CloneGroup. So we // decrement i so that we visit it again in the outer loop. // Note: i can never be 0 at this point because we are just comparing @@ -537,6 +553,14 @@ Sequences = Result; } +void RecursiveCloneTypeIIVerifyConstraint::constrain( +std::vector &Sequences) { + CloneConstraint::splitCloneGroups( + Sequences, [](const StmtSequence &A, const StmtSequence &B) { +return areSequencesClones(A, B); + }); +} + size_t MinComplexityConstraint::calculateStmtComplexity( const StmtSequence &Seq, const std::string &ParentMacroStack) { if (Seq.empty()) Index: include/clang/Analysis/CloneDetection.h === --- include/clang/Analysis/CloneDetection.h +++ include/clang/Analysis/CloneDetection.h @@ -254,20 +254,37 @@ /// Searches all children of the given clones for type II clones (i.e. they are /// identical in every aspect beside the used variable names). +/// +/// This constraint is also available to be executed in two phases, see +/// RecursiveCloneTypeIIHashConstraint and RecursiveCloneTypeIIVerifyConstraint +/// for more. class RecursiveCloneTypeIIConstraint { +public: + void constrain(std::vector &Sequences); +}; - /// Generates and saves a hash code for the given Stmt. - /// \param S The given Stmt. - /// \param D The Decl containing S. - /// \param StmtsByHash Output parameter that will contain the hash codes for - ///each StmtSequence in the given Stmt. - /// \return The hash code of the given Stmt. - /// - /// If the given Stmt is a CompoundStmt, this method will also generate - /// hashes for all possible StmtSequences in the children of this Stmt. - size_t saveHash(const Stmt *S, const Decl *D, - std::vector> &StmtsByHash); +/// This constraint performs only the hashing part of the +/// RecursiveCloneTypeIIConstraint. +/// +/// It is supposed to be fast and can be used at the fron
r305491 - LexerTest memory leak fix-
Author: erichkeane Date: Thu Jun 15 13:34:47 2017 New Revision: 305491 URL: http://llvm.org/viewvc/llvm-project?rev=305491&view=rev Log: LexerTest memory leak fix- A new LexerTest unittest introduced a memory leak. This patch uses a unique_ptr with a custom deleter to ensure it is properly deleted. Modified: cfe/trunk/unittests/Lex/LexerTest.cpp Modified: cfe/trunk/unittests/Lex/LexerTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=305491&r1=305490&r2=305491&view=diff == --- cfe/trunk/unittests/Lex/LexerTest.cpp (original) +++ cfe/trunk/unittests/Lex/LexerTest.cpp Thu Jun 15 13:34:47 2017 @@ -402,7 +402,9 @@ TEST_F(LexerTest, DontOverallocateString ArgTokens.push_back(tok); } - MacroArgs *MA = MacroArgs::create(MI, ArgTokens, false, *PP); + auto MacroArgsDeleter = [&PP](MacroArgs *M) { M->destroy(*PP); }; + std::unique_ptr MA( + MacroArgs::create(MI, ArgTokens, false, *PP), MacroArgsDeleter); Token Result = MA->getStringifiedArgument(0, *PP, {}, {}); EXPECT_EQ(tok::string_literal, Result.getKind()); EXPECT_STREQ("\"\\\"StrArg\\\"\"", Result.getLiteralData()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments
Thanks for the heads up! Fixed in 305491. Turns out a function that AllocateMacroInfo returns a pointer, but the PP still owns it. MacroArgs::create returns a pointer, and expects the user to delete it. I added a unique_ptr with a custom delete to call the macro-args 'destroy' function. -Original Message- From: Kostya Serebryany via Phabricator [mailto:revi...@reviews.llvm.org] Sent: Thursday, June 15, 2017 10:44 AM To: Keane, Erich ; r...@google.com; rich...@metafoo.co.uk; arpha...@gmail.com Cc: k...@google.com; cfe-commits@lists.llvm.org Subject: [PATCH] D32046: [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, correct getNumArguments kcc added a comment. the bots complain about a leak in the new test code. Please fix/revert ASAP. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5691/steps/check-clang%20asan/logs/stdio 28905==ERROR: LeakSanitizer: detected memory leaks == Direct leak of 216 byte(s) in 1 object(s) allocated from: #0 0x4eca08 in __interceptor_malloc /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:66 #1 0xefcb8f in clang::MacroArgs::create(clang::MacroInfo const*, llvm::ArrayRef, bool, clang::Preprocessor&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Lex/MacroArgs.cpp:51:27 #2 0x54dc56 in (anonymous namespace)::LexerTest_DontOverallocateStringifyArgs_Test::TestBody() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/unittests/Lex/LexerTest.cpp:405:19 #3 0x65154e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #4 0x65154e in testing::Test::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2474 #5 0x653848 in testing::TestInfo::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2656:11 #6 0x654b86 in testing::TestCase::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2774:28 #7 0x675586 in testing::internal::UnitTestImpl::RunAllTests() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4649:43 #8 0x67487e in HandleExceptionsInMethodIfSupported /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2458:12 #9 0x67487e in testing::UnitTest::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:4257 #10 0x634bfe in RUN_ALL_TESTS /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46 #11 0x634bfe in main /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/UnitTestMain/TestMain.cpp:51 #12 0x7f016e9cb82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f) Repository: rL LLVM https://reviews.llvm.org/D32046 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
EricWF marked 2 inline comments as done. EricWF added inline comments. Comment at: test/CodeGenCoroutines/coro-await.cpp:310 + int& x = co_await a; + // CHECK: await2.ready: + // CHECK-NEXT: %[[RES2:.+]] = call dereferenceable(4) i32* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %ref.tmp{{.+}}) GorNishanov wrote: > In release compiler, labels won't have friendly names. //CHECK: await2.ready > will fail I'm not sure I understand. Are you saying that Clang generates different IR depending on how it's built (ie release vs debug)? https://reviews.llvm.org/D34194 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
EricWF updated this revision to Diff 102701. EricWF added a comment. - Address most inline comments. https://reviews.llvm.org/D34194 Files: lib/AST/ExprClassification.cpp lib/CodeGen/CGCoroutine.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCoroutines/coro-await.cpp Index: test/CodeGenCoroutines/coro-await.cpp === --- test/CodeGenCoroutines/coro-await.cpp +++ test/CodeGenCoroutines/coro-await.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 \ +// RUN: -emit-llvm %s -o - -disable-llvm-passes -Wno-coroutine -Wno-unused | FileCheck %s namespace std { namespace experimental { @@ -278,3 +279,40 @@ suspend_always lval; co_await lval; } + +struct AwaitResumeReturnsLValue { + bool await_ready(); + void await_suspend(std::experimental::coroutine_handle<>); + int& await_resume(); +}; + + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +void get_return_object(); +init_susp initial_suspend(); +final_susp final_suspend(); +void return_void(); +AwaitResumeReturnsLValue yield_value(int); + }; +}; + +// Verifies that we don't crash when returning an lvalue from an await_resume() +// expression. +// CHECK-LABEL: define void @_Z18AwaitReturnsLValued(double) +void AwaitReturnsLValue(double) { + AwaitResumeReturnsLValue a; + // CHECK: await.ready: + // CHECK-NEXT: %[[RES1:.+]] = call dereferenceable(4) i32* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %a) + // CHECK-NEXT: store i32* %[[RES1]], i32** %x, align 8 + int& x = co_await a; + // CHECK: await2.ready: + // CHECK-NEXT: %[[RES2:.+]] = call dereferenceable(4) i32* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %ref.tmp{{.+}}) + // CHECK-NEXT: store i32* %[[RES2]], i32** %y, align 8 + int& y = co_await AwaitResumeReturnsLValue{}; + // CHECK: yield.ready: + // CHECK-NEXT: %[[RES3:.+]] = call dereferenceable(4) i32* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %ref.tmp{{.+}}) + // CHECK-NEXT: store i32* %[[RES3]], i32** %z, align 8 + int& z = co_yield 42; +} Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2550,9 +2550,11 @@ RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot = AggValueSlot::ignored(), bool ignoreResult = false); + LValue EmitCoawaitLValue(const CoawaitExpr *E); RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot = AggValueSlot::ignored(), bool ignoreResult = false); + LValue EmitCoyieldLValue(const CoyieldExpr *E); RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID); void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false); Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1158,6 +1158,11 @@ case Expr::MaterializeTemporaryExprClass: return EmitMaterializeTemporaryExpr(cast(E)); + + case Expr::CoawaitExprClass: +return EmitCoawaitLValue(cast(E)); + case Expr::CoyieldExprClass: +return EmitCoyieldLValue(cast(E)); } } Index: lib/CodeGen/CGCoroutine.cpp === --- lib/CodeGen/CGCoroutine.cpp +++ lib/CodeGen/CGCoroutine.cpp @@ -148,10 +148,16 @@ // // See llvm's docs/Coroutines.rst for more details. // -static RValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, +namespace { + struct LValueOrRValue { +LValue LV; +RValue RV; + }; +} +static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, CoroutineSuspendExpr const &S, AwaitKind Kind, AggValueSlot aggSlot, -bool ignoreResult) { +bool ignoreResult, bool forLValue) { auto *E = S.getCommonExpr(); // FIXME: rsmith 5/22/2017. Does it still make sense for us to have a @@ -217,29 +223,66 @@ // Emit await_resume expression. CGF.EmitBlock(ReadyBlock); - return CGF.EmitAnyExpr(S.getResumeExpr(), aggSlot, ignoreResult); + LValueOrRValue Res; + if (forLValue) +Res.LV = CGF.EmitLValue(S.getResumeExpr()); + else +Res.RV = CGF.EmitAnyExpr(S.getResumeExpr(), aggSlot, ignoreResult); + return Res; } RValue CodeGenFunction::EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot,
[PATCH] D34052: [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions
dblaikie accepted this revision. dblaikie added a comment. This revision is now accepted and ready to land. Looks fine - thanks https://reviews.llvm.org/D34052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D34052: [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions
On Mon, Jun 12, 2017 at 9:15 PM Dean Michael Berris via Phabricator < revi...@reviews.llvm.org> wrote: > dberris added a reviewer: dblaikie. > dberris added a subscriber: dblaikie. > dberris added a comment. > > @dblaikie -- do you have time to have a look? > Sure sure - no need to ping a patch more than about weekly. If it's addressed to me I'll pretty reliably see it & get to it when I have time. (: - Dave > > > https://reviews.llvm.org/D34052 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34194: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
EricWF updated this revision to Diff 102705. EricWF added a comment. - Fix the test when -discard-value-names is present, at least my part of the test. https://reviews.llvm.org/D34194 Files: lib/AST/ExprClassification.cpp lib/CodeGen/CGCoroutine.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCoroutines/coro-await.cpp Index: test/CodeGenCoroutines/coro-await.cpp === --- test/CodeGenCoroutines/coro-await.cpp +++ test/CodeGenCoroutines/coro-await.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 \ +// RUN: -emit-llvm %s -o - -disable-llvm-passes -Wno-coroutine -Wno-unused | FileCheck %s namespace std { namespace experimental { @@ -278,3 +279,50 @@ suspend_always lval; co_await lval; } + +struct RefTag { }; + +struct AwaitResumeReturnsLValue { + bool await_ready(); + void await_suspend(std::experimental::coroutine_handle<>); + RefTag& await_resume(); +}; + + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +void get_return_object(); +init_susp initial_suspend(); +final_susp final_suspend(); +void return_void(); +AwaitResumeReturnsLValue yield_value(int); + }; +}; + +// Verifies that we don't crash when returning an lvalue from an await_resume() +// expression. +// CHECK-LABEL: define void @_Z18AwaitReturnsLValued(double) +void AwaitReturnsLValue(double) { + AwaitResumeReturnsLValue a; + // CHECK: %[[AVAR:.+]] = alloca %struct.AwaitResumeReturnsLValue, + // CHECK: %[[XVAR:.+]] = alloca %struct.RefTag*, + + // CHECK: %[[YVAR:.+]] = alloca %struct.RefTag*, + // CHECK-NEXT: %[[TMP1:.+]] = alloca %struct.AwaitResumeReturnsLValue, + + // CHECK: %[[ZVAR:.+]] = alloca %struct.RefTag*, + // CHECK-NEXT: %[[TMP2:.+]] = alloca %struct.AwaitResumeReturnsLValue, + + // CHECK: %[[RES1:.+]] = call dereferenceable({{.*}}) %struct.RefTag* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %[[AVAR]]) + // CHECK-NEXT: store %struct.RefTag* %[[RES1]], %struct.RefTag** %[[XVAR]], + RefTag& x = co_await a; + + // CHECK: %[[RES2:.+]] = call dereferenceable({{.*}}) %struct.RefTag* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %[[TMP1]]) + // CHECK-NEXT: store %struct.RefTag* %[[RES2]], %struct.RefTag** %[[YVAR]], + + RefTag& y = co_await AwaitResumeReturnsLValue{}; + // CHECK: %[[RES3:.+]] = call dereferenceable({{.*}}) %struct.RefTag* @_ZN24AwaitResumeReturnsLValue12await_resumeEv(%struct.AwaitResumeReturnsLValue* %[[TMP2]]) + // CHECK-NEXT: store %struct.RefTag* %[[RES3]], %struct.RefTag** %[[ZVAR]], + RefTag& z = co_yield 42; +} Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2550,9 +2550,11 @@ RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot = AggValueSlot::ignored(), bool ignoreResult = false); + LValue EmitCoawaitLValue(const CoawaitExpr *E); RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot = AggValueSlot::ignored(), bool ignoreResult = false); + LValue EmitCoyieldLValue(const CoyieldExpr *E); RValue EmitCoroutineIntrinsic(const CallExpr *E, unsigned int IID); void EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false); Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -1158,6 +1158,11 @@ case Expr::MaterializeTemporaryExprClass: return EmitMaterializeTemporaryExpr(cast(E)); + + case Expr::CoawaitExprClass: +return EmitCoawaitLValue(cast(E)); + case Expr::CoyieldExprClass: +return EmitCoyieldLValue(cast(E)); } } Index: lib/CodeGen/CGCoroutine.cpp === --- lib/CodeGen/CGCoroutine.cpp +++ lib/CodeGen/CGCoroutine.cpp @@ -148,10 +148,16 @@ // // See llvm's docs/Coroutines.rst for more details. // -static RValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, +namespace { + struct LValueOrRValue { +LValue LV; +RValue RV; + }; +} +static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, CoroutineSuspendExpr const &S, AwaitKind Kind, AggValueSlot aggSlot, -bool ignoreResult) { +bool ignoreResult, bool forLValue) { auto *E = S.getCommonExpr(); // FIXME: rsmith 5/22/2017. Does it still make sense for us to have a @@ -217,29
r305496 - [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile
Author: ericwf Date: Thu Jun 15 14:43:36 2017 New Revision: 305496 URL: http://llvm.org/viewvc/llvm-project?rev=305496&view=rev Log: [coroutines] Allow co_await and co_yield expressions that return an lvalue to compile Summary: The title says it all. Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Subscribers: rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D34194 Modified: cfe/trunk/lib/AST/ExprClassification.cpp cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGenCoroutines/coro-await.cpp Modified: cfe/trunk/lib/AST/ExprClassification.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprClassification.cpp?rev=305496&r1=305495&r2=305496&view=diff == --- cfe/trunk/lib/AST/ExprClassification.cpp (original) +++ cfe/trunk/lib/AST/ExprClassification.cpp Thu Jun 15 14:43:36 2017 @@ -190,7 +190,6 @@ static Cl::Kinds ClassifyInternal(ASTCon case Expr::ArrayInitIndexExprClass: case Expr::NoInitExprClass: case Expr::DesignatedInitUpdateExprClass: - case Expr::CoyieldExprClass: return Cl::CL_PRValue; // Next come the complicated cases. @@ -414,7 +413,8 @@ static Cl::Kinds ClassifyInternal(ASTCon return ClassifyInternal(Ctx, cast(E)->getInit(0)); case Expr::CoawaitExprClass: -return ClassifyInternal(Ctx, cast(E)->getResumeExpr()); + case Expr::CoyieldExprClass: +return ClassifyInternal(Ctx, cast(E)->getResumeExpr()); } llvm_unreachable("unhandled expression kind in classification"); Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=305496&r1=305495&r2=305496&view=diff == --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Thu Jun 15 14:43:36 2017 @@ -148,10 +148,16 @@ static SmallString<32> buildSuspendPrefi // // See llvm's docs/Coroutines.rst for more details. // -static RValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, +namespace { + struct LValueOrRValue { +LValue LV; +RValue RV; + }; +} +static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Coro, CoroutineSuspendExpr const &S, AwaitKind Kind, AggValueSlot aggSlot, -bool ignoreResult) { +bool ignoreResult, bool forLValue) { auto *E = S.getCommonExpr(); // FIXME: rsmith 5/22/2017. Does it still make sense for us to have a @@ -217,7 +223,12 @@ static RValue emitSuspendExpression(Code // Emit await_resume expression. CGF.EmitBlock(ReadyBlock); - return CGF.EmitAnyExpr(S.getResumeExpr(), aggSlot, ignoreResult); + LValueOrRValue Res; + if (forLValue) +Res.LV = CGF.EmitLValue(S.getResumeExpr()); + else +Res.RV = CGF.EmitAnyExpr(S.getResumeExpr(), aggSlot, ignoreResult); + return Res; } RValue CodeGenFunction::EmitCoawaitExpr(const CoawaitExpr &E, @@ -225,13 +236,13 @@ RValue CodeGenFunction::EmitCoawaitExpr( bool ignoreResult) { return emitSuspendExpression(*this, *CurCoro.Data, E, CurCoro.Data->CurrentAwaitKind, aggSlot, - ignoreResult); + ignoreResult, /*forLValue*/false).RV; } RValue CodeGenFunction::EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot, bool ignoreResult) { return emitSuspendExpression(*this, *CurCoro.Data, E, AwaitKind::Yield, - aggSlot, ignoreResult); + aggSlot, ignoreResult, /*forLValue*/false).RV; } void CodeGenFunction::EmitCoreturnStmt(CoreturnStmt const &S) { @@ -240,6 +251,38 @@ void CodeGenFunction::EmitCoreturnStmt(C EmitBranchThroughCleanup(CurCoro.Data->FinalJD); } + +#ifndef NDEBUG +static QualType getCoroutineSuspendExprReturnType(const ASTContext &Ctx, + const CoroutineSuspendExpr *E) { + const auto *RE = E->getResumeExpr(); + // Is it possible for RE to be a CXXBindTemporaryExpr wrapping + // a MemberCallExpr? + assert(isa(RE) && "unexpected suspend expression type"); + return cast(RE)->getCallReturnType(Ctx); +} +#endif + +LValue +CodeGenFunction::EmitCoawaitLValue(const CoawaitExpr *E) { + assert(getCoroutineSuspendExprReturnType(getContext(), E)->isReferenceType() && + "Can't have a scalar return unless the return type is a " + "reference type!"); + return emitSuspendExpression(*this, *CurCoro.Data, *E, + CurCoro.Data->CurrentAwaitKind, AggValueSlot::ignored(), +
[PATCH] D34091: Support for querying the exception specification type through libclang
ajbennieston updated this revision to Diff 102707. ajbennieston added a comment. Fixes for review comments. https://reviews.llvm.org/D34091 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_exception_specification_kind.py include/clang-c/Index.h test/Index/get-cursor.cpp tools/c-index-test/c-index-test.c tools/libclang/CXType.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -175,6 +175,7 @@ clang_getCursorDefinition clang_getCursorDisplayName clang_getCursorExtent +clang_getCursorExceptionSpecificationType clang_getCursorKind clang_getCursorKindSpelling clang_getCursorLanguage @@ -210,6 +211,7 @@ clang_getEnumConstantDeclUnsignedValue clang_getEnumConstantDeclValue clang_getEnumDeclIntegerType +clang_getExceptionSpecificationType clang_getFieldDeclBitWidth clang_getExpansionLocation clang_getFile Index: tools/libclang/CXType.cpp === --- tools/libclang/CXType.cpp +++ tools/libclang/CXType.cpp @@ -684,6 +684,24 @@ return MakeCXType(QualType(), cxcursor::getCursorTU(C)); } +int clang_getExceptionSpecificationType(CXType X) { +QualType T = GetQualType(X); +if (T.isNull()) +return -1; + +if (const auto* FD = T->getAs()) +return static_cast(FD->getExceptionSpecType()); + +return -1; +} + +int clang_getCursorExceptionSpecificationType(CXCursor C) { +if (clang_isDeclaration(C.kind)) +return clang_getExceptionSpecificationType(clang_getCursorType(C)); + +return -1; +} + unsigned clang_isPODType(CXType X) { QualType T = GetQualType(X); if (T.isNull()) Index: tools/c-index-test/c-index-test.c === --- tools/c-index-test/c-index-test.c +++ tools/c-index-test/c-index-test.c @@ -809,6 +809,37 @@ if (clang_Cursor_isObjCOptional(Cursor)) printf(" (@optional)"); +switch (clang_getCursorExceptionSpecificationType(Cursor)) +{ + case CXCursor_ExceptionSpecificationKind_None: +break; + + case CXCursor_ExceptionSpecificationKind_DynamicNone: +printf(" (noexcept dynamic none)"); +break; + + case CXCursor_ExceptionSpecificationKind_Dynamic: +printf(" (noexcept dynamic)"); +break; + + case CXCursor_ExceptionSpecificationKind_MSAny: +printf(" (noexcept dynamic any)"); +break; + + case CXCursor_ExceptionSpecificationKind_BasicNoexcept: +printf(" (noexcept)"); +break; + + case CXCursor_ExceptionSpecificationKind_ComputedNoexcept: +printf(" (computed-noexcept)"); +break; + + case CXCursor_ExceptionSpecificationKind_Unevaluated: + case CXCursor_ExceptionSpecificationKind_Uninstantiated: + case CXCursor_ExceptionSpecificationKind_Unparsed: +break; +} + { CXString language; CXString definedIn; Index: test/Index/get-cursor.cpp === --- test/Index/get-cursor.cpp +++ test/Index/get-cursor.cpp @@ -145,6 +145,13 @@ const int operator""_toint(unsigned long long val) { return int(val); } +// noexcept specifications +void f_noexcept() noexcept; +template void f_computed_noexcept(T t) noexcept(noexcept(t+t)); +void f_dynamic_noexcept_none() throw(); +void f_dynamic_noexcept() throw(int); +void f_dynamic_noexcept_any() throw(...); + // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s // CHECK-COMPLETION-1: CXXConstructor=X:6:3 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )} @@ -209,11 +216,11 @@ // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25]) -// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 -curs
r305498 - [coroutines] Remove pass-through operator co_await; Replace it with the input expression
Author: ericwf Date: Thu Jun 15 15:00:54 2017 New Revision: 305498 URL: http://llvm.org/viewvc/llvm-project?rev=305498&view=rev Log: [coroutines] Remove pass-through operator co_await; Replace it with the input expression Reviewers: GorNishanov, rsmith Reviewed By: GorNishanov Differential Revision: https://reviews.llvm.org/D34216 Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=305498&r1=305497&r2=305498&view=diff == --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Thu Jun 15 15:00:54 2017 @@ -160,19 +160,6 @@ static LValueOrRValue emitSuspendExpress bool ignoreResult, bool forLValue) { auto *E = S.getCommonExpr(); - // FIXME: rsmith 5/22/2017. Does it still make sense for us to have a - // UO_Coawait at all? As I recall, the only purpose it ever had was to - // represent a dependent co_await expression that couldn't yet be resolved to - // a CoawaitExpr. But now we have (and need!) a separate DependentCoawaitExpr - // node to store unqualified lookup results, it seems that the UnaryOperator - // portion of the representation serves no purpose (and as seen in this patch, - // it's getting in the way). Can we remove it? - - // Skip passthrough operator co_await (present when awaiting on an LValue). - if (auto *UO = dyn_cast(E)) -if (UO->getOpcode() == UO_Coawait) - E = UO->getSubExpr(); - auto Binder = CodeGenFunction::OpaqueValueMappingData::bind(CGF, S.getOpaqueValue(), E); auto UnbindOnExit = llvm::make_scope_exit([&] { Binder.unbind(CGF); }); Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=305498&r1=305497&r2=305498&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jun 15 15:00:54 2017 @@ -12057,11 +12057,17 @@ ExprResult Sema::CreateBuiltinUnaryOp(So } break; case UO_Extension: - case UO_Coawait: resultType = Input.get()->getType(); VK = Input.get()->getValueKind(); OK = Input.get()->getObjectKind(); break; + case UO_Coawait: +// It's unnessesary to represent the pass-through operator co_await in the +// AST; just return the input expression instead. +assert(!Input.get()->getType()->isDependentType() && + "the co_await expression must be non-dependant before " + "building operator co_await"); +return Input; } if (resultType.isNull() || Input.isInvalid()) return ExprError(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34156: [LTO] Enable module summary emission by default for regular LTO
tobiasvk added a comment. In https://reviews.llvm.org/D34156#781415, @pcc wrote: > Please confirm that we can still self host with full LTO now that > https://reviews.llvm.org/D33922 has landed. Good point. And the answer seems to be no :/ ld.lld: .../llvm/lib/Linker/IRMover.cpp:242: llvm::Type *(anonymous namespace)::TypeMapTy::get(llvm::Type *, SmallPtrSet &): Assertion `!(Pair.first != Ty && Pair.second == Ty) && "mapping to a source type"' failed. This is with `cmake -DCLANG_ENABLE_BOOTSTRAP=1-DBOOTSTRAP_LLVM_ENABLE_LLD=1-DBOOTSTRAP_LLVM_ENABLE_LTO=1 (...) && ninja stage2`. https://reviews.llvm.org/D34156 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r305500 - Use _LIBCPP_FALLTHROUGH() to avoid warnings about [[gnu::fallthrough]] being unsupported
Author: ericwf Date: Thu Jun 15 15:18:10 2017 New Revision: 305500 URL: http://llvm.org/viewvc/llvm-project?rev=305500&view=rev Log: Use _LIBCPP_FALLTHROUGH() to avoid warnings about [[gnu::fallthrough]] being unsupported Modified: libcxxabi/trunk/src/cxa_demangle.cpp Modified: libcxxabi/trunk/src/cxa_demangle.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=305500&r1=305499&r2=305500&view=diff == --- libcxxabi/trunk/src/cxa_demangle.cpp (original) +++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Jun 15 15:18:10 2017 @@ -2258,7 +2258,7 @@ parse_type(const char* first, const char break; } } -[[gnu::fallthrough]]; +_LIBCPP_FALLTHROUGH(); default: // must check for builtin-types before class-enum-types to avoid // ambiguities with operator-names ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34233: [CFI] Add ability to explicitly link classes
egoktas added a comment. To address pcc's questions, I have sent an email to llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2017-June/114168.html. https://reviews.llvm.org/D34233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33989: [OpenCL] Allow targets to select address space per type
yaxunl added inline comments. Comment at: include/clang/Basic/TargetInfo.h:1041 +default: + return LangAS::Default; +} bader wrote: > yaxunl wrote: > > I think the default (including even_t, clk_event_t, queue_t, reserved_id_t) > > should be global since these opaque OpenCL objects are pointers to some > > shared resources. These pointers may be an automatic variable themselves > > but the memory they point to should be global. Since these objects are > > dynamically allocated, assuming them in private address space implies > > runtime needs to maintain a private memory pool for each work item and > > allocate objects from there. Considering the huge number of work items in > > typical OpenCL applications, it would be very inefficient to implement > > these objects in private memory pool. On the other hand, a global memory > > pool seems much reasonable. > > > > Anastasia/Alexey, any comments on this? Thanks. > I remember we discussed this a couple of time in the past. > The address space for variables of these types is not clearly stated in the > spec, so I think the right way to treat it - it's implementation defined. > On the other hand your reasoning on using global address space as default AS > makes sense in general - so can we put additional clarification to the spec > to align it with the proposed implementation? I think it is unnecessary to specify the implementation details in the OpenCL spec. It is also unnecessary for SPIR-V spec since the pointee address space of OpenCL opaque struct is not encoded in SPIR-V. We can use the commonly accepted address space definition in the TargetInfo base class. If a target chooses to use different address space for specific opaque objects, it can override it in its own virtual function. https://reviews.llvm.org/D33989 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33406: PR28129 expand vector oparation to an IR constant.
dtemirbulatov updated this revision to Diff 102717. dtemirbulatov added a comment. Update formatting, comments https://reviews.llvm.org/D33406 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/avx-builtins.c Index: test/CodeGen/avx-builtins.c === --- test/CodeGen/avx-builtins.c +++ test/CodeGen/avx-builtins.c @@ -1427,3 +1427,51 @@ // CHECK: extractelement <8 x float> %{{.*}}, i32 0 return _mm256_cvtss_f32(__a); } + +__m256 test_mm256_cmp_ps_true(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_true + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_pd_false(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_false + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OQ); +} + +__m256 test_mm256_cmp_ps_strue(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_ps_strue + // CHECK: store <8 x float> zeroinitializer, <8 x float>* %tmp, align 32 + return _mm256_cmp_ps(a, b, _CMP_FALSE_OS); +} + +__m256 test_mm256_cmp_pd_sfalse(__m256 a, __m256 b) { + // CHECK-LABEL: @test_mm256_cmp_pd_sfalse + // CHECK: store <4 x double> zeroinitializer, <4 x double>* %tmp, align 32 + return _mm256_cmp_pd(a, b, _CMP_FALSE_OS); +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7923,19 +7923,40 @@ } // We can't handle 8-31 immediates with native IR, use the intrinsic. +// Except for predicates that create constants. Intrinsic::ID ID; switch (BuiltinID) { default: llvm_unreachable("Unsupported intrinsic!"); case X86::BI__builtin_ia32_cmpps: ID = Intrinsic::x86_sse_cmp_ps; break; case X86::BI__builtin_ia32_cmpps256: + // _CMP_TRUE_UQ, _CMP_TRUE_US produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produce 0, 0... + if (CC == 0xf || CC == 0xb || CC == 0x1b || CC == 0x1f) { + Value *Constant = (CC == 0xf || CC == 0x1f) ? +llvm::Constant::getAllOnesValue(Builder.getInt32Ty()) : +llvm::Constant::getNullValue(Builder.getInt32Ty()); + Value *Vec = Builder.CreateVectorSplat( +Ops[0]->getType()->getVectorNumElements(), Constant); + return Builder.CreateBitCast(Vec, Ops[0]->getType()); + } ID = Intrinsic::x86_avx_cmp_ps_256; break; case X86::BI__builtin_ia32_cmppd: ID = Intrinsic::x86_sse2_cmp_pd; break; case X86::BI__builtin_ia32_cmppd256: + // _CMP_TRUE_UQ, _CMP_TRUE_US produce -1,-1... vector + // on any input and _CMP_FALSE_OQ, _CMP_FALSE_OS produce 0, 0... + if (CC == 0xf || CC == 0xb || CC == 0x1b || CC == 0x1f) { + Value *Constant = (CC == 0xf || CC == 0x1f) ? +llvm::Constant::getAllOnesValue(Builder.getInt64Ty()) : +llvm::Constant::getNullValue(Builder.getInt64Ty()); + Value *Vec = Builder.CreateVectorSplat( +Ops[0]->getType()->getVectorNumElements(), Constant); + return Builder.CreateBitCast(Vec, Ops[0]->getType()); + } ID = Intrinsic::x86_avx_cmp_pd_256; break; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34185: [Parser][ObjC] Avoid crashing when skipping to EOF while parsing an ObjC interface/implementation
arphaman updated this revision to Diff 102718. arphaman added a comment. Use the 'Eof' token to make sure that the "expected '}'" error is presented not at the end of the file, but at the start of the `@interface`/`@implementation`. Repository: rL LLVM https://reviews.llvm.org/D34185 Files: lib/Parse/ParseObjc.cpp test/Parser/objc-at-implementation-eof-crash.m test/Parser/objc-at-interface-eof-crash.m Index: test/Parser/objc-at-interface-eof-crash.m === --- /dev/null +++ test/Parser/objc-at-interface-eof-crash.m @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify -Wno-objc-root-class %s + +@interface ClassA + +- (void)fileExistsAtPath:(int)x; + +@end + +@interface ClassB + +@end + +@implementation ClassB // expected-note {{implementation started here}} + +- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}} + mgr fileExistsAtPath:0 +} // expected-error {{expected ']'}} + +@interface ClassC // expected-error {{missing '@end'}} // expected-error {{expected '}'}} + +@end Index: test/Parser/objc-at-implementation-eof-crash.m === --- /dev/null +++ test/Parser/objc-at-implementation-eof-crash.m @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify -Wno-objc-root-class %s + +@interface ClassA + +- (void)fileExistsAtPath:(int)x; + +@end + +@interface ClassB + +@end + +@implementation ClassB // expected-note {{implementation started here}} + +- (void) method:(ClassA *)mgr { // expected-note {{to match this '{'}} + mgr fileExistsAtPath:0 +} // expected-error {{expected ']'}} + +@implementation ClassC // expected-error {{missing '@end'}} // expected-error {{expected '}'}} // expected-warning {{cannot find interface declaration for 'ClassC'}} + +@end Index: lib/Parse/ParseObjc.cpp === --- lib/Parse/ParseObjc.cpp +++ lib/Parse/ParseObjc.cpp @@ -217,6 +217,8 @@ assert(Tok.isObjCAtKeyword(tok::objc_interface) && "ParseObjCAtInterfaceDeclaration(): Expected @interface"); CheckNestedObjCContexts(AtLoc); + if (isEofOrEom()) +return nullptr; ConsumeToken(); // the "interface" identifier // Code completion after '@interface'. @@ -2101,6 +2103,8 @@ assert(Tok.isObjCAtKeyword(tok::objc_implementation) && "ParseObjCAtImplementationDeclaration(): Expected @implementation"); CheckNestedObjCContexts(AtLoc); + if (isEofOrEom()) +return nullptr; ConsumeToken(); // the "implementation" identifier // Code completion after '@implementation'. @@ -3627,6 +3631,14 @@ SourceLocation OrigLoc = Tok.getLocation(); assert(!LM.Toks.empty() && "ParseLexedObjCMethodDef - Empty body!"); + // Store an artificial EOF token to ensure that we don't run off the end of + // the method's body when we come to parse it. + Token Eof; + Eof.startToken(); + Eof.setKind(tok::eof); + Eof.setEofData(MCDecl); + Eof.setLocation(Tok.getLocation()); + LM.Toks.push_back(Eof); // Append the current token at the end of the new token stream so that it // doesn't get lost. LM.Toks.push_back(Tok); @@ -3658,7 +3670,10 @@ Actions.ActOnDefaultCtorInitializers(MCDecl); ParseFunctionStatementBody(MCDecl, BodyScope); } - + + // Clean up the remaining EOF token. + if (Tok.is(tok::eof) && Tok.getEofData() == MCDecl) +ConsumeAnyToken(); if (Tok.getLocation() != OrigLoc) { // Due to parsing error, we either went over the cached tokens or // there are still cached tokens left. If it's the latter case skip the ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple
EricWF created this revision. This fixes llvm.org/PR33469. https://reviews.llvm.org/D34249 Files: src/experimental/filesystem/operations.cpp Index: src/experimental/filesystem/operations.cpp === --- src/experimental/filesystem/operations.cpp +++ src/experimental/filesystem/operations.cpp @@ -19,7 +19,15 @@ #include #include #include /* values for fchmodat */ -#if !defined(UTIME_OMIT) + +// We can use the presence of UTIME_OMIT to detect platforms that do not +// provide utimensat, with some exceptions on OS X. +#if !defined(UTIME_OMIT) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1030) +#define _LIBCPP_HAS_NO_UTIMENSAT +#endif + +#if defined(_LIBCPP_HAS_NO_UTIMENSAT) #include // for ::utimes as used in __last_write_time #endif @@ -682,9 +690,7 @@ using namespace std::chrono; std::error_code m_ec; -// We can use the presence of UTIME_OMIT to detect platforms that do not -// provide utimensat. -#if !defined(UTIME_OMIT) +#if defined(_LIBCPP_HAS_NO_UTIMENSAT) // This implementation has a race condition between determining the // last access time and attempting to set it to the same value using // ::utimes Index: src/experimental/filesystem/operations.cpp === --- src/experimental/filesystem/operations.cpp +++ src/experimental/filesystem/operations.cpp @@ -19,7 +19,15 @@ #include #include #include /* values for fchmodat */ -#if !defined(UTIME_OMIT) + +// We can use the presence of UTIME_OMIT to detect platforms that do not +// provide utimensat, with some exceptions on OS X. +#if !defined(UTIME_OMIT) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1030) +#define _LIBCPP_HAS_NO_UTIMENSAT +#endif + +#if defined(_LIBCPP_HAS_NO_UTIMENSAT) #include // for ::utimes as used in __last_write_time #endif @@ -682,9 +690,7 @@ using namespace std::chrono; std::error_code m_ec; -// We can use the presence of UTIME_OMIT to detect platforms that do not -// provide utimensat. -#if !defined(UTIME_OMIT) +#if defined(_LIBCPP_HAS_NO_UTIMENSAT) // This implementation has a race condition between determining the // last access time and attempting to set it to the same value using // ::utimes ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305504 - [index] Index static_assert declarations
Author: arphaman Date: Thu Jun 15 15:50:43 2017 New Revision: 305504 URL: http://llvm.org/viewvc/llvm-project?rev=305504&view=rev Log: [index] Index static_assert declarations static_assert declarations have to be visited while indexing so that we can gather the references to declarations that are present in their assert expression. Differential Revision: https://reviews.llvm.org/D33913 Modified: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/test/Index/Core/index-source.cpp Modified: cfe/trunk/lib/Index/IndexDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305504&r1=305503&r2=305504&view=diff == --- cfe/trunk/lib/Index/IndexDecl.cpp (original) +++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 15:50:43 2017 @@ -682,6 +682,13 @@ public: bool VisitImportDecl(const ImportDecl *D) { return IndexCtx.importedModule(D); } + + bool VisitStaticAssertDecl(const StaticAssertDecl *D) { +IndexCtx.indexBody(D->getAssertExpr(), + dyn_cast(D->getDeclContext()), + D->getLexicalDeclContext()); +return true; + } }; } // anonymous namespace Modified: cfe/trunk/test/Index/Core/index-source.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305504&r1=305503&r2=305504&view=diff == --- cfe/trunk/test/Index/Core/index-source.cpp (original) +++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 15:50:43 2017 @@ -433,3 +433,19 @@ template T varDecl = T(); } // end namespace ensureDefaultTemplateParamsAreRecordedOnce + +struct StaticAssertRef { + static constexpr bool constVar = true; +}; + +static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0 +// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref | rel: 0 + +void staticAssertInFn() { + static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33913: [index] Index static_assert declarations
This revision was automatically updated to reflect the committed changes. Closed by commit rL305504: [index] Index static_assert declarations (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D33913?vs=101458&id=102720#toc Repository: rL LLVM https://reviews.llvm.org/D33913 Files: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/test/Index/Core/index-source.cpp Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -682,6 +682,13 @@ bool VisitImportDecl(const ImportDecl *D) { return IndexCtx.importedModule(D); } + + bool VisitStaticAssertDecl(const StaticAssertDecl *D) { +IndexCtx.indexBody(D->getAssertExpr(), + dyn_cast(D->getDeclContext()), + D->getLexicalDeclContext()); +return true; + } }; } // anonymous namespace Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -433,3 +433,19 @@ T varDecl = T(); } // end namespace ensureDefaultTemplateParamsAreRecordedOnce + +struct StaticAssertRef { + static constexpr bool constVar = true; +}; + +static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0 +// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref | rel: 0 + +void staticAssertInFn() { + static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +} Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -682,6 +682,13 @@ bool VisitImportDecl(const ImportDecl *D) { return IndexCtx.importedModule(D); } + + bool VisitStaticAssertDecl(const StaticAssertDecl *D) { +IndexCtx.indexBody(D->getAssertExpr(), + dyn_cast(D->getDeclContext()), + D->getLexicalDeclContext()); +return true; + } }; } // anonymous namespace Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -433,3 +433,19 @@ T varDecl = T(); } // end namespace ensureDefaultTemplateParamsAreRecordedOnce + +struct StaticAssertRef { + static constexpr bool constVar = true; +}; + +static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0 +// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref | rel: 0 + +void staticAssertInFn() { + static_assert(StaticAssertRef::constVar, "index static asserts"); +// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305507 - Added braces to work around gcc warning in googletest: suggest explicit braces to avoid ambiguous 'else'. NFC.
Author: gkistanova Date: Thu Jun 15 16:01:24 2017 New Revision: 305507 URL: http://llvm.org/viewvc/llvm-project?rev=305507&view=rev Log: Added braces to work around gcc warning in googletest: suggest explicit braces to avoid ambiguous 'else'. NFC. Modified: cfe/trunk/unittests/AST/CommentLexer.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp cfe/trunk/unittests/Tooling/LookupTest.cpp Modified: cfe/trunk/unittests/AST/CommentLexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentLexer.cpp?rev=305507&r1=305506&r2=305507&view=diff == --- cfe/trunk/unittests/AST/CommentLexer.cpp (original) +++ cfe/trunk/unittests/AST/CommentLexer.cpp Thu Jun 15 16:01:24 2017 @@ -320,9 +320,10 @@ TEST_F(CommentLexerTest, DoxygenCommand4 ASSERT_EQ(array_lengthof(Text), Toks.size()); for (size_t j = 0, e = Toks.size(); j != e; j++) { - if(Toks[j].is(tok::text)) + if(Toks[j].is(tok::text)) { ASSERT_EQ(StringRef(Text[j]), Toks[j].getText()) << "index " << i; + } } } } Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=305507&r1=305506&r2=305507&view=diff == --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h (original) +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h Thu Jun 15 16:01:24 2017 @@ -320,10 +320,12 @@ public: ExpectedName(ExpectedName) {} void onEndOfTranslationUnit() override { -if (ExpectedCount != -1) +if (ExpectedCount != -1) { EXPECT_EQ(ExpectedCount, Count); -if (!ExpectedName.empty()) +} +if (!ExpectedName.empty()) { EXPECT_EQ(ExpectedName, Name); +} Count = 0; Name.clear(); } @@ -346,8 +348,9 @@ public: } BoundNodes::IDToNodeMap::const_iterator I = M.find(Id); EXPECT_NE(M.end(), I); - if (I != M.end()) + if (I != M.end()) { EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get()); + } return true; } EXPECT_TRUE(M.count(Id) == 0 || Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=305507&r1=305506&r2=305507&view=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Thu Jun 15 16:01:24 2017 @@ -300,8 +300,9 @@ struct ScopedDir { EXPECT_FALSE(EC); } ~ScopedDir() { -if (Path != "") +if (Path != "") { EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); +} } operator StringRef() { return Path.str(); } }; @@ -316,8 +317,9 @@ struct ScopedLink { EXPECT_FALSE(EC); } ~ScopedLink() { -if (Path != "") +if (Path != "") { EXPECT_FALSE(llvm::sys::fs::remove(Path.str())); +} } operator StringRef() { return Path.str(); } }; Modified: cfe/trunk/unittests/Tooling/LookupTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/LookupTest.cpp?rev=305507&r1=305506&r2=305507&view=diff == --- cfe/trunk/unittests/Tooling/LookupTest.cpp (original) +++ cfe/trunk/unittests/Tooling/LookupTest.cpp Thu Jun 15 16:01:24 2017 @@ -143,8 +143,9 @@ TEST(LookupTest, replaceNestedClassName) Visitor.OnRecordTypeLoc = [&](RecordTypeLoc Type) { // Filter Types by name since there are other `RecordTypeLoc` in the test // file. -if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") +if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") { EXPECT_EQ("x::Bar", replaceRecordTypeLoc(Type, "::a::x::Bar")); +} }; Visitor.runOver("namespace a { namespace b {\n" "class Foo;\n" @@ -155,8 +156,9 @@ TEST(LookupTest, replaceNestedClassName) // Filter Types by name since there are other `RecordTypeLoc` in the test // file. // `a::b::Foo` in using shadow decl is not `TypeLoc`. -if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") +if (Type.getDecl()->getQualifiedNameAsString() == "a::b::Foo") { EXPECT_EQ("Bar", replaceRecordTypeLoc(Type, "::a::x::Bar")); +} }; Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n" "namespace c { using a::b::Foo; Foo f();; }\n"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305508 - [index] Record C++17 global binding declarations
Author: arphaman Date: Thu Jun 15 16:19:01 2017 New Revision: 305508 URL: http://llvm.org/viewvc/llvm-project?rev=305508&view=rev Log: [index] Record C++17 global binding declarations The global C++17 binding declarations should be indexed as variable symbols. Differential Revision: https://reviews.llvm.org/D33920 Modified: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/lib/Index/IndexSymbol.cpp cfe/trunk/test/Index/Core/index-source.cpp Modified: cfe/trunk/lib/Index/IndexDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=305508&r1=305507&r2=305508&view=diff == --- cfe/trunk/lib/Index/IndexDecl.cpp (original) +++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Jun 15 16:19:01 2017 @@ -293,6 +293,12 @@ public: return true; } + bool VisitDecompositionDecl(const DecompositionDecl *D) { +for (const auto *Binding : D->bindings()) + TRY_DECL(Binding, IndexCtx.handleDecl(Binding)); +return Base::VisitDecompositionDecl(D); + } + bool VisitFieldDecl(const FieldDecl *D) { SmallVector Relations; gatherTemplatePseudoOverrides(D, Relations); Modified: cfe/trunk/lib/Index/IndexSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=305508&r1=305507&r2=305508&view=diff == --- cfe/trunk/lib/Index/IndexSymbol.cpp (original) +++ cfe/trunk/lib/Index/IndexSymbol.cpp Thu Jun 15 16:19:01 2017 @@ -301,6 +301,10 @@ SymbolInfo index::getSymbolInfo(const De Info.Kind = SymbolKind::TypeAlias; Info.Lang = SymbolLanguage::CXX; break; +case Decl::Binding: + Info.Kind = SymbolKind::Variable; + Info.Lang = SymbolLanguage::CXX; + break; default: break; } Modified: cfe/trunk/test/Index/Core/index-source.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=305508&r1=305507&r2=305508&view=diff == --- cfe/trunk/test/Index/Core/index-source.cpp (original) +++ cfe/trunk/test/Index/Core/index-source.cpp Thu Jun 15 16:19:01 2017 @@ -1,4 +1,4 @@ -// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s +// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] | | Def | rel: 0 class Cls { public: @@ -449,3 +449,29 @@ void staticAssertInFn() { // CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref,RelCont | rel: 1 // CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# } + +namespace cpp17structuredBinding { + +struct Cpp17StructuredBinding { + int x, y; + + Cpp17StructuredBinding(int x, int y): x(x), y(y) { } +}; + +auto [structuredBinding1, structuredBinding2] = Cpp17StructuredBinding(Record::C, 0); +// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 | | Decl,RelChild | rel: 1 +// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding +// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 | | Decl,RelChild | rel: 1 +// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding + +void localStructuredBindingAndRef() { + int ref = structuredBinding1; +// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 | | Ref,Read,RelCont | rel: 1 +// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef# + auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, structuredBinding2); +// CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 | | Ref,Read,RelCont | rel: 1 +// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef# +// CHECK-NOT: localBinding +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33920: [index] Record C++17 binding declarations
This revision was automatically updated to reflect the committed changes. Closed by commit rL305508: [index] Record C++17 global binding declarations (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D33920?vs=101478&id=102722#toc Repository: rL LLVM https://reviews.llvm.org/D33920 Files: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/lib/Index/IndexSymbol.cpp cfe/trunk/test/Index/Core/index-source.cpp Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -293,6 +293,12 @@ return true; } + bool VisitDecompositionDecl(const DecompositionDecl *D) { +for (const auto *Binding : D->bindings()) + TRY_DECL(Binding, IndexCtx.handleDecl(Binding)); +return Base::VisitDecompositionDecl(D); + } + bool VisitFieldDecl(const FieldDecl *D) { SmallVector Relations; gatherTemplatePseudoOverrides(D, Relations); Index: cfe/trunk/lib/Index/IndexSymbol.cpp === --- cfe/trunk/lib/Index/IndexSymbol.cpp +++ cfe/trunk/lib/Index/IndexSymbol.cpp @@ -301,6 +301,10 @@ Info.Kind = SymbolKind::TypeAlias; Info.Lang = SymbolLanguage::CXX; break; +case Decl::Binding: + Info.Kind = SymbolKind::Variable; + Info.Lang = SymbolLanguage::CXX; + break; default: break; } Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -1,4 +1,4 @@ -// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s +// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] | | Def | rel: 0 class Cls { public: @@ -449,3 +449,29 @@ // CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef | | Ref,RelCont | rel: 1 // CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn# } + +namespace cpp17structuredBinding { + +struct Cpp17StructuredBinding { + int x, y; + + Cpp17StructuredBinding(int x, int y): x(x), y(y) { } +}; + +auto [structuredBinding1, structuredBinding2] = Cpp17StructuredBinding(Record::C, 0); +// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 | | Decl,RelChild | rel: 1 +// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding +// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 | | Decl,RelChild | rel: 1 +// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding + +void localStructuredBindingAndRef() { + int ref = structuredBinding1; +// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 | | Ref,Read,RelCont | rel: 1 +// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef# + auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, structuredBinding2); +// CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 | | Ref,Read,RelCont | rel: 1 +// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef# +// CHECK-NOT: localBinding +} + +} Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -293,6 +293,12 @@ return true; } + bool VisitDecompositionDecl(const DecompositionDecl *D) { +for (const auto *Binding : D->bindings()) + TRY_DECL(Binding, IndexCtx.handleDecl(Binding)); +return Base::VisitDecompositionDecl(D); + } + bool VisitFieldDecl(const FieldDecl *D) { SmallVector Relations; gatherTemplatePseudoOverrides(D, Relations); Index: cfe/trunk/lib/Index/IndexSymbol.cpp === --- cfe/trunk/lib/Index/IndexSymbol.cpp +++ cfe/trunk/lib/Index/IndexSymbol.cpp @@ -301,6 +301,10 @@ Info.Kind = SymbolKind::TypeAlias; Info.Lang = SymbolLanguage::CXX; break; +case Decl::Binding: + Info.Kind = SymbolKind::Variable; + Info.Lang = SymbolLanguage::CXX; + break; default: break; } Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -1,4 +1,4 @@ -// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7
[PATCH] D34091: Support for querying the exception specification type through libclang
aaron.ballman added inline comments. Comment at: include/clang-c/Index.h:213 + /** + * \brief The exception specification has not yet been evaluated + */ This comment is now missing the full-stop at the end of the sentence (you dropped one too many periods). Comment at: tools/libclang/CXType.cpp:693 + +if (const FunctionProtoType* FD = T->getAs()) { +return static_cast(FD->getExceptionSpecType()); aaron.ballman wrote: > Use `const auto *` and elide the braces. You should run your patch through clang-format; the asterisk should bind to `FD` rather than `auto` and the indentation is too large in the patch. https://reviews.llvm.org/D34091 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305511 - [Completion] Code complete the members for a dependent type after a '::'
Author: arphaman Date: Thu Jun 15 16:40:54 2017 New Revision: 305511 URL: http://llvm.org/viewvc/llvm-project?rev=305511&view=rev Log: [Completion] Code complete the members for a dependent type after a '::' This commit is a follow up to r302797 which added support for dependent completions after the '.' and '->' operators. This commit adds support for dependent completions after the '::' operator. Differential Revision: https://reviews.llvm.org/D34173 Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/test/CodeCompletion/member-access.cpp Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=305511&r1=305510&r2=305511&view=diff == --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original) +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Jun 15 16:40:54 2017 @@ -4542,8 +4542,10 @@ void Sema::CodeCompleteQualifiedId(Scope bool EnteringContext) { if (!SS.getScopeRep() || !CodeCompleter) return; - - DeclContext *Ctx = computeDeclContext(SS, EnteringContext); + + // Always pretend to enter a context to ensure that a dependent type + // resolves to a dependent record. + DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true); if (!Ctx) return; @@ -4573,7 +4575,9 @@ void Sema::CodeCompleteQualifiedId(Scope Results.ExitScope(); CodeCompletionDeclConsumer Consumer(Results, CurContext); - LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer); + LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer, + /*IncludeGlobalScope=*/true, + /*IncludeDependentBases=*/true); HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(), Modified: cfe/trunk/test/CodeCompletion/member-access.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.cpp?rev=305511&r1=305510&r2=305511&view=diff == --- cfe/trunk/test/CodeCompletion/member-access.cpp (original) +++ cfe/trunk/test/CodeCompletion/member-access.cpp Thu Jun 15 16:40:54 2017 @@ -145,4 +145,22 @@ public: // CHECK-CC6: o2 : [#BaseTemplate#]o2 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s } + + static void staticFn(T &obj); + + struct Nested { }; }; + +template +void dependentColonColonCompletion() { + Template::staticFn(); +// CHECK-CC7: function : [#void#]function() +// CHECK-CC7: Nested : Nested +// CHECK-CC7: o1 : [#BaseTemplate#]o1 +// CHECK-CC7: o2 : [#BaseTemplate#]o2 +// CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>) +// CHECK-CC7: Template : Template +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s + typename Template::Nested m; +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34173: [Completion] Code complete the members for a dependent type after a '::'
This revision was automatically updated to reflect the committed changes. Closed by commit rL305511: [Completion] Code complete the members for a dependent type after a '::' (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D34173?vs=102410&id=102724#toc Repository: rL LLVM https://reviews.llvm.org/D34173 Files: cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/test/CodeCompletion/member-access.cpp Index: cfe/trunk/test/CodeCompletion/member-access.cpp === --- cfe/trunk/test/CodeCompletion/member-access.cpp +++ cfe/trunk/test/CodeCompletion/member-access.cpp @@ -145,4 +145,22 @@ // CHECK-CC6: o2 : [#BaseTemplate#]o2 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s } + + static void staticFn(T &obj); + + struct Nested { }; }; + +template +void dependentColonColonCompletion() { + Template::staticFn(); +// CHECK-CC7: function : [#void#]function() +// CHECK-CC7: Nested : Nested +// CHECK-CC7: o1 : [#BaseTemplate#]o1 +// CHECK-CC7: o2 : [#BaseTemplate#]o2 +// CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>) +// CHECK-CC7: Template : Template +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s + typename Template::Nested m; +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s +} Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp === --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp @@ -4542,8 +4542,10 @@ bool EnteringContext) { if (!SS.getScopeRep() || !CodeCompleter) return; - - DeclContext *Ctx = computeDeclContext(SS, EnteringContext); + + // Always pretend to enter a context to ensure that a dependent type + // resolves to a dependent record. + DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true); if (!Ctx) return; @@ -4573,7 +4575,9 @@ Results.ExitScope(); CodeCompletionDeclConsumer Consumer(Results, CurContext); - LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer); + LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer, + /*IncludeGlobalScope=*/true, + /*IncludeDependentBases=*/true); HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(), Index: cfe/trunk/test/CodeCompletion/member-access.cpp === --- cfe/trunk/test/CodeCompletion/member-access.cpp +++ cfe/trunk/test/CodeCompletion/member-access.cpp @@ -145,4 +145,22 @@ // CHECK-CC6: o2 : [#BaseTemplate#]o2 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:142:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s } + + static void staticFn(T &obj); + + struct Nested { }; }; + +template +void dependentColonColonCompletion() { + Template::staticFn(); +// CHECK-CC7: function : [#void#]function() +// CHECK-CC7: Nested : Nested +// CHECK-CC7: o1 : [#BaseTemplate#]o1 +// CHECK-CC7: o2 : [#BaseTemplate#]o2 +// CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>) +// CHECK-CC7: Template : Template +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:156:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s + typename Template::Nested m; +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:164:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s +} Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp === --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp @@ -4542,8 +4542,10 @@ bool EnteringContext) { if (!SS.getScopeRep() || !CodeCompleter) return; - - DeclContext *Ctx = computeDeclContext(SS, EnteringContext); + + // Always pretend to enter a context to ensure that a dependent type + // resolves to a dependent record. + DeclContext *Ctx = computeDeclContext(SS, /*EnteringContext=*/true); if (!Ctx) return; @@ -4573,7 +4575,9 @@ Results.ExitScope(); CodeCompletionDeclConsumer Consumer(Results, CurContext); - LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer); + LookupVisibleDecls(Ctx, LookupOrdinaryName, Consumer, + /*IncludeGlobalScope=*/true, + /*IncludeDependentBases=*/true); HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20596: [libcxx] Refactor locale switching, creation, and destruction
bcraig abandoned this revision. bcraig added a comment. This is very stale at this point, and isn't blocking anything. Closing. https://reviews.llvm.org/D20596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC
bcraig added a comment. ping https://reviews.llvm.org/D32411 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34251: Add a new driver option to disable warning about c++17's non-throwing exception specification in function signature
ahatanak created this revision. The option allows disabling just the warning about non-throwing exception specification in function signature instead of disabling all c++1z compatibility warnings with -Wno-c++1z-compat. I'm not sure "-Wc++1z-compat-exception-spec" sounds right. Maybe -Wc++1z-compat-mangling, -Wc++1z-mangling, or -Wc++1z-compat-exception-spec-function is better? rdar://problem/32628743 https://reviews.llvm.org/D34251 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/cxx1z-noexcept-function-type.cpp Index: test/SemaCXX/cxx1z-noexcept-function-type.cpp === --- test/SemaCXX/cxx1z-noexcept-function-type.cpp +++ test/SemaCXX/cxx1z-noexcept-function-type.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions %s // RUN: %clang_cc1 -std=c++1z -verify -fexceptions -fcxx-exceptions %s -Wno-dynamic-exception-spec +// RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions -Wno-c++1z-compat-exception-spec -DNO_EXCEPTION_SPEC %s #if __cplusplus > 201402L @@ -81,7 +82,7 @@ auto f5() -> void (*)() throw(); auto f6() -> void (&)() throw(); auto f7() -> void (X::*)() throw(); -#if __cplusplus <= 201402L +#if __cplusplus <= 201402L && !defined(NO_EXCEPTION_SPEC) // expected-warning@-8 {{mangled name of 'f1' will change in C++17 due to non-throwing exception specification in function signature}} // expected-warning@-8 {{mangled name of 'f2' will change in C++17 due to non-throwing exception specification in function signature}} // expected-warning@-8 {{mangled name of 'f3' will change in C++17 due to non-throwing exception specification in function signature}} Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -507,7 +507,7 @@ InGroup, DefaultIgnore; def warn_cxx1z_compat_exception_spec_in_signature : Warning< "mangled name of %0 will change in C++17 due to non-throwing exception " - "specification in function signature">, InGroup; + "specification in function signature">, InGroup; def warn_global_constructor : Warning< "declaration requires a global constructor">, Index: include/clang/Basic/DiagnosticGroups.td === --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -149,6 +149,7 @@ def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">; def FormatExtraArgs : DiagGroup<"format-extra-args">; def FormatZeroLength : DiagGroup<"format-zero-length">; +def CXX1zCompatExceptionSpec : DiagGroup<"c++1z-compat-exception-spec">; // Warnings for C++1y code which is not compatible with prior C++ standards. def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">; @@ -211,7 +212,8 @@ [CXXPre1zCompatPedantic]>; def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister, - DeprecatedIncrementBool]>; + DeprecatedIncrementBool, + CXX1zCompatExceptionSpec]>; def ExitTimeDestructors : DiagGroup<"exit-time-destructors">; def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">; Index: test/SemaCXX/cxx1z-noexcept-function-type.cpp === --- test/SemaCXX/cxx1z-noexcept-function-type.cpp +++ test/SemaCXX/cxx1z-noexcept-function-type.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions %s // RUN: %clang_cc1 -std=c++1z -verify -fexceptions -fcxx-exceptions %s -Wno-dynamic-exception-spec +// RUN: %clang_cc1 -std=c++14 -verify -fexceptions -fcxx-exceptions -Wno-c++1z-compat-exception-spec -DNO_EXCEPTION_SPEC %s #if __cplusplus > 201402L @@ -81,7 +82,7 @@ auto f5() -> void (*)() throw(); auto f6() -> void (&)() throw(); auto f7() -> void (X::*)() throw(); -#if __cplusplus <= 201402L +#if __cplusplus <= 201402L && !defined(NO_EXCEPTION_SPEC) // expected-warning@-8 {{mangled name of 'f1' will change in C++17 due to non-throwing exception specification in function signature}} // expected-warning@-8 {{mangled name of 'f2' will change in C++17 due to non-throwing exception specification in function signature}} // expected-warning@-8 {{mangled name of 'f3' will change in C++17 due to non-throwing exception specification in function signature}} Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -507,7 +507,7 @@ InGroup, DefaultIgnore; def warn_cxx1z_compat_exception_spec_in_signatur
[PATCH] D34252: Add arbitrary file/path support to clang-format style file selection
dciliske created this revision. Herald added a subscriber: klimek. The Format library has no way to specify a specific file to be used as the style source. It climbs the path looking for ‘.clang_format’. This patch adds the ability to specify a specific file to use for clang Format utilities. This patch is in direct response to https://bugs.llvm.org//show_bug.cgi?id=28107 (along with my own personal need). New style argument feature: Use -style=file, to load style configuration from an explicitly defined file. https://reviews.llvm.org/D34252 Files: lib/Format/Format.cpp Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1967,6 +1967,8 @@ ".clang-format file located in one of the parent\n" "directories of the source file (or current\n" "directory for stdin).\n" +"Use -style=file, to load style \n" +"configuration from an explicitly defined file.\n" "Use -style=\"{key: value, ...}\" to set specific\n" "parameters, e.g.:\n" " -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\""; @@ -2014,8 +2016,44 @@ } if (!StyleName.equals_lower("file")) { +SmallString<128> ConfigFile(StyleName.substr(5)); +if (StyleName.startswith_lower("file,")) { + DEBUG(llvm::dbgs() << "Trying explicit file" << ConfigFile << "...\n"); + + auto Status = FS->status(ConfigFile.str()); + bool FoundConfigFile = +Status && (Status->getType() == llvm::sys::fs::file_type::regular_file); + if (FoundConfigFile) { +llvm::ErrorOr> Text = + FS->getBufferForFile(ConfigFile.str()); +if (std::error_code EC = Text.getError()) { + DEBUG(llvm::dbgs() << "Text Error getting contents.\n"); + return make_string_error(EC.message()); +} +if (std::error_code ec = +parseConfiguration(Text.get()->getBuffer(), &Style)) { + if (ec == ParseError::Unsuitable) { + +DEBUG(llvm::dbgs() << "Config file error.\n"); +return make_string_error( +"Configuration file does not support " + +getLanguageName(Style.Language) + ": " + +ConfigFile); + } + DEBUG(llvm::dbgs() << "Error reading " << ConfigFile << ".\n"); + return make_string_error("Error reading " + ConfigFile + ": " + + ec.message()); +} +DEBUG(llvm::dbgs() << "Using configuration file " << ConfigFile << "\n"); +return Style; + } + DEBUG(llvm::dbgs() << "Could not find file: " << ConfigFile << "\n"); + return FallbackStyle; +} if (!getPredefinedStyle(StyleName, Style.Language, &Style)) return make_string_error("Invalid value for -style"); + +DEBUG(llvm::dbgs() << "Using configuration file " << ConfigFile << "\n"); return Style; } Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1967,6 +1967,8 @@ ".clang-format file located in one of the parent\n" "directories of the source file (or current\n" "directory for stdin).\n" +"Use -style=file, to load style \n" +"configuration from an explicitly defined file.\n" "Use -style=\"{key: value, ...}\" to set specific\n" "parameters, e.g.:\n" " -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\""; @@ -2014,8 +2016,44 @@ } if (!StyleName.equals_lower("file")) { +SmallString<128> ConfigFile(StyleName.substr(5)); +if (StyleName.startswith_lower("file,")) { + DEBUG(llvm::dbgs() << "Trying explicit file" << ConfigFile << "...\n"); + + auto Status = FS->status(ConfigFile.str()); + bool FoundConfigFile = +Status && (Status->getType() == llvm::sys::fs::file_type::regular_file); + if (FoundConfigFile) { +llvm::ErrorOr> Text = + FS->getBufferForFile(ConfigFile.str()); +if (std::error_code EC = Text.getError()) { + DEBUG(llvm::dbgs() << "Text Error getting contents.\n"); + return make_string_error(EC.message()); +} +if (std::error_code ec = +parseConfiguration(Text.get()->getBuffer(), &Style)) { + if (ec == ParseError::Unsuitable) { + +DEBUG(llvm::dbgs() << "Config file error.\n"); +return make_string_error( +"Configuration file does not support " + +getLanguageName(Style.Language) + ": " + +ConfigFile); + } + DEBUG(llvm::dbgs() << "Error reading " << ConfigFile << ".\n"); + return make_string_error("Error reading " + ConfigFile + ": " + + ec.message()); +} +DEBUG(llvm::dbgs() << "Using configuration file " << ConfigFile << "\n"); +return Style; + } + DEBUG(llvm::dbgs() << "Could not find file: " << ConfigFile << "\n"); + return Fal
[PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple
dexonsmith added a comment. This is the right idea, although it only covers macOS. Any ideas for how to test this? Comment at: src/experimental/filesystem/operations.cpp:23-28 +// We can use the presence of UTIME_OMIT to detect platforms that do not +// provide utimensat, with some exceptions on OS X. +#if !defined(UTIME_OMIT) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1030) +#define _LIBCPP_HAS_NO_UTIMENSAT +#endif Sadly this isn't quite sufficient. As per Jack's suggested SDK patch in the PR, we need to enumerate the platforms :/. I think this should be the right logic for the four Darwin platforms: (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \ (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0) || \ (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < __TVOS_11_0) || \ (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13) https://reviews.llvm.org/D34249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34185: [Parser][ObjC] Avoid crashing when skipping to EOF while parsing an ObjC interface/implementation
ahatanak added inline comments. Comment at: lib/Parse/ParseObjc.cpp:220 CheckNestedObjCContexts(AtLoc); + if (isEofOrEom()) +return nullptr; Do you need this check here (and below)? Comment at: lib/Parse/ParseObjc.cpp:3674 + + // Clean up the remaining EOF token. + if (Tok.is(tok::eof) && Tok.getEofData() == MCDecl) I think you want to clean up the EOF token after the code below which skips the leftover tokens, regardless of whether Tok is EOF. You can do it unconditionally since Tok.getLocation() == OrigLoc and you know the token is the EOF inserted above. Repository: rL LLVM https://reviews.llvm.org/D34185 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple
EricWF added inline comments. Comment at: src/experimental/filesystem/operations.cpp:23-28 +// We can use the presence of UTIME_OMIT to detect platforms that do not +// provide utimensat, with some exceptions on OS X. +#if !defined(UTIME_OMIT) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1030) +#define _LIBCPP_HAS_NO_UTIMENSAT +#endif dexonsmith wrote: > Sadly this isn't quite sufficient. As per Jack's suggested SDK patch in the > PR, we need to enumerate the platforms :/. I think this should be the right > logic for the four Darwin platforms: > > (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && > __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_11_0) || \ > (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && > __WATCH_OS_VERSION_MIN_REQUIRED < __WATCHOS_4_0) || \ > (defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < > __TVOS_11_0) || \ > (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && > __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13) > Do we have to do the below dance for all of those macros? ``` #if !defined(__FOO_VERSION_MIN_REQUIRED) && defined(__ENVIROMENT_FOO_VERSION_MIN_REQUIRED) #define __FOO_VERSION_MIN_REQUIRED __ENVIROMENT_FOO_VERSION_REQUIRED #endif ``` https://reviews.llvm.org/D34249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33406: PR28129 expand vector oparation to an IR constant.
spatel accepted this revision. spatel added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D33406 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34256: [PR33394] Avoid lexing editor placeholders when running the preprocessor only
arphaman created this revision. r300667 added support for editor placeholder to Clang. That commit didn’t take into account that users who use Clang for preprocessing only (-E) will get the “editor placeholder in source file” error when preprocessing their source (PR33394). This commit ensures that Clang doesn't lex editor placeholders when running a preprocessor only action. It also ensures that tokens like `<#>` and `<##>` won't form valid placeholders. rdar://32718000 Repository: rL LLVM https://reviews.llvm.org/D34256 Files: include/clang/Lex/PreprocessorOptions.h lib/Frontend/CompilerInvocation.cpp lib/Lex/Lexer.cpp test/Frontend/pp-only-no-editor-placeholders.c test/Parser/editor-placeholder-recovery.cpp Index: test/Parser/editor-placeholder-recovery.cpp === --- test/Parser/editor-placeholder-recovery.cpp +++ test/Parser/editor-placeholder-recovery.cpp @@ -69,3 +69,11 @@ // expected-error@-2 {{editor placeholder in source file}} #endif } + +// These two are not valid placeholders: +void notPlaceholders1() { +<#> // expected-error {{expected expression}} // expected-error {{expected expression}} +} +void notPlaceholders2() { +<##> // expected-error {{expected expression}} // expected-error {{expected expression}} +} Index: test/Frontend/pp-only-no-editor-placeholders.c === --- /dev/null +++ test/Frontend/pp-only-no-editor-placeholders.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -E -verify -o - %s | FileCheck %s +// expected-no-diagnostics + +<#placeholder#>; // CHECK: <#placeholder#>; Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -19,6 +19,7 @@ #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/LiteralSupport.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Compiler.h" @@ -2750,9 +2751,12 @@ bool Lexer::lexEditorPlaceholder(Token &Result, const char *CurPtr) { assert(CurPtr[-1] == '<' && CurPtr[0] == '#' && "Not a placeholder!"); - if (!PP || LexingRawMode) + if (!PP || !PP->getPreprocessorOpts().LexEditorPlaceholders || LexingRawMode) return false; - const char *End = findPlaceholderEnd(CurPtr + 1, BufferEnd); + const char *NextPtr = CurPtr + 1; + if (NextPtr < BufferEnd && (NextPtr[0] == '>' || NextPtr[0] == '#')) +return false; + const char *End = findPlaceholderEnd(NextPtr, BufferEnd); if (!End) return false; const char *Start = CurPtr - 1; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2379,9 +2379,51 @@ Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders); } +static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { + switch (Action) { + case frontend::ASTDeclList: + case frontend::ASTDump: + case frontend::ASTPrint: + case frontend::ASTView: + case frontend::EmitAssembly: + case frontend::EmitBC: + case frontend::EmitHTML: + case frontend::EmitLLVM: + case frontend::EmitLLVMOnly: + case frontend::EmitCodeGenOnly: + case frontend::EmitObj: + case frontend::FixIt: + case frontend::GenerateModule: + case frontend::GenerateModuleInterface: + case frontend::GeneratePCH: + case frontend::GeneratePTH: + case frontend::ParseSyntaxOnly: + case frontend::ModuleFileInfo: + case frontend::VerifyPCH: + case frontend::PluginAction: + case frontend::PrintDeclContext: + case frontend::RewriteObjC: + case frontend::RewriteTest: + case frontend::RunAnalysis: + case frontend::MigrateSource: +return false; + + case frontend::DumpRawTokens: + case frontend::DumpTokens: + case frontend::InitOnly: + case frontend::PrintPreamble: + case frontend::PrintPreprocessedInput: + case frontend::RewriteMacros: + case frontend::RunPreprocessorOnly: +return true; + } + llvm_unreachable("invalid frontend action"); +} + static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, FileManager &FileMgr, - DiagnosticsEngine &Diags) { + DiagnosticsEngine &Diags, + frontend::ActionKind Action) { using namespace options; Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch); Opts.ImplicitPTHInclude = Args.getLastArgValue(OPT_include_pth); @@ -2454,52 +2496,23 @@ else Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library; } + + // Always avoid lexing editor placeholders when we're just running the + // preprocessor as we never want to emit the + // "editor placeholder in source file" error in PP only
[PATCH] D34256: [PR33394] Avoid lexing editor placeholders when running the preprocessor only
benlangmuir added a comment. I agree with not detecting these during PP-only, but there's nothing wrong with `<#>`. It's either not a placeholder, or it's part of a placeholder like `<#>#>`, which is a placeholder containing the text ">". Similarly, `<##` could be the start of an empty placeholder `<##>`. Repository: rL LLVM https://reviews.llvm.org/D34256 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284060 - Implement MS _BitScan intrinsics
On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes wrote: > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits > wrote: >> SGTM too. Regarding Duncan's last question -- I can't think of any such >> customer. :) If you all think the right thing for clang to do is to infer >> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me! Thinking more about this; what if we mark such builtins as unsupported for "LP64 (Darwin) + ms_extensions" and then you provide the definitions via intrin.h (we can generate a compiler macro for this scenario and conditionalize the include_next as we do for _MSC_VER)? Do you use this header at all? Are there any other MS related flags that get passed to the compiler? > SGTM as well! > >> >> Thanks all! >> Schwieb >> >> -Original Message- >> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com] >> Sent: Monday, June 12, 2017 1:55 PM >> To: Reid Kleckner >> Cc: Saleem Abdulrasool ; Albert Gutowski >> ; David Majnemer ; >> cfe-commits ; Erik Schwiebert >> >> Subject: Re: r284060 - Implement MS _BitScan intrinsics >> >> >>> On Jun 12, 2017, at 12:44, Reid Kleckner wrote: >>> On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool wrote: I'm worried about changing this signature all the time. I suspect that it will cause the following to be emitted for valid code: warning: incompatible pointer types passing 'unsigned long *' to parameter of type 'unsigned int *' [-Wincompatible-pointer-types] Switching the signature on LP64 sounds much better to me. >>> >>> Right, we have to do this. It needs to be `long` on Windows. >> >> SGTM. We'll go that way. > > +1 here! > >>> On Jun 8, 2017, at 12:21, Erik Schwiebert wrote: >>> >>> It’s probably also better to not try to infer our weird desired behavior. >>> It should probably be controlled by a specific driver directive, like >>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new >>> directive means that nobody can accidentally get this behavior if they for >>> some reason do want LLP64 behavior with Windows intrinsics. >> >> This seems overly complicated. Is there a customer that: >> - is on LP64, >> - is using -fms-extensions, >> - is using these intrinsics, and >> - wants them to be 64-bit longs instead of 32-bit ints? >> Put another way: who would use these intrinsics on LP64 and *not* want to >> mimic LLP64? >> >> If everyone using the intrinsics on LP64 is going to have to specify >> -fms-extensions-lp64-intrinsics, then we should just imply it. >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > > > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc -- Bruno Cardoso Lopes http://www.brunocardoso.cc ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier
jyu2 updated this revision to Diff 102754. jyu2 added a comment. Address Aaron's comments. https://reviews.llvm.org/D3 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/AnalysisBasedWarnings.cpp test/CXX/except/except.spec/p11.cpp test/SemaCXX/warn-throw-out-noexcept-func.cpp Index: lib/Sema/AnalysisBasedWarnings.cpp === --- lib/Sema/AnalysisBasedWarnings.cpp +++ lib/Sema/AnalysisBasedWarnings.cpp @@ -279,6 +279,152 @@ } //===--===// +// Check for throw in a non-throwing function. +//===--===// +enum ThrowState { + FoundNoPathForThrow, + FoundPathForThrow, + FoundPathWithNoThrowOutFunction, +}; + +static bool isThrowCaught(const CXXThrowExpr *Throw, + const CXXCatchStmt *Catch) { + const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull(); + const Type *ThrowType = nullptr; + if (Throw->getSubExpr()) +ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull(); + + if (ThrowType == nullptr) +return false; + if (ThrowType && ThrowType->isReferenceType()) +ThrowType = ThrowType->castAs() +->getPointeeType() +->getUnqualifiedDesugaredType(); + if (CaughtType == nullptr) +return true; + if (CaughtType && CaughtType->isReferenceType()) +CaughtType = CaughtType->castAs() + ->getPointeeType() + ->getUnqualifiedDesugaredType(); + if (CaughtType == ThrowType) +return true; + const CXXRecordDecl *CaughtAsRecordType = + CaughtType->getPointeeCXXRecordDecl(); + const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl(); + if (CaughtAsRecordType && ThrowTypeAsRecordType) +return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType); + return false; +} + +static bool isThrowCaughtByHandlers(const CXXThrowExpr *CE, +const CXXTryStmt *TryStmt) { + for (unsigned H = 0, E = TryStmt->getNumHandlers(); H < E; ++H) { +if (isThrowCaught(CE, TryStmt->getHandler(H))) + return true; + } + return false; +} + +static bool doesThrowEscapePath(CFGBlock Block, SourceLocation &OpLoc) { + for (const clang::CFGElement &B : Block) { +if (B.getKind() != CFGElement::Statement) + continue; +const CXXThrowExpr *CE = +dyn_cast(B.getAs()->getStmt()); +if (!CE) + continue; + +OpLoc = CE->getThrowLoc(); +for (const auto &I : Block.succs()) { + if (!I.isReachable()) +continue; + if (const CXXTryStmt *Terminator = + dyn_cast_or_null(I->getTerminator())) +if (isThrowCaughtByHandlers(CE, Terminator)) + return false; +} +return true; + } + return false; +} + +static bool hasThrowOutNonThrowingFunc(SourceLocation &OpLoc, CFG *BodyCFG) { + + unsigned ExitID = BodyCFG->getExit().getBlockID(); + + SmallVector States(BodyCFG->getNumBlockIDs(), + FoundNoPathForThrow); + States[BodyCFG->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction; + + SmallVector Stack; + Stack.push_back(&BodyCFG->getEntry()); + while (!Stack.empty()) { +CFGBlock *CurBlock = Stack.back(); +Stack.pop_back(); + +unsigned ID = CurBlock->getBlockID(); +ThrowState CurState = States[ID]; +if (CurState == FoundPathWithNoThrowOutFunction) { + if (ExitID == ID) +continue; + + if (doesThrowEscapePath(*CurBlock, OpLoc)) +CurState = FoundPathForThrow; +} + +// Loop over successor blocks and add them to the Stack if their state +// changes. +for (const auto &I : CurBlock->succs()) + if (I.isReachable()) { +unsigned NextID = I->getBlockID(); +if (NextID == ExitID && CurState == FoundPathForThrow) { + States[NextID] = CurState; +} else if (States[NextID] < CurState) { + States[NextID] = CurState; + Stack.push_back(I); +} + } + } + // Return true if the exit node is reachable, and only reachable through + // a throw expression. + return States[ExitID] == FoundPathForThrow; +} + +static void EmitDiagForCXXThrowInNonThrowingFunc(SourceLocation OpLoc, Sema &S, + const FunctionDecl *FD) { + if (!S.getSourceManager().isInSystemHeader(OpLoc)) { +S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD; +if (S.getLangOpts().CPlusPlus11 && +(isa(FD) || + FD->getDeclName().getCXXOverloadedOperator() == OO_Delete || + FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) + S.Diag(FD->getLocation(), diag::note_throw_in_dtor); +else + S.Diag(FD->getLocation(), diag::note_throw_in_function); + } +} + +static void checkThrowInNonThrowingFunc(Sema &S, const FunctionDecl *FD, +
[PATCH] D34237: Mark the operations of __wrap_iter as constexpr
EricWF added a comment. Could you re-upload this with a updated diff against trunk, and one with more context. https://reviews.llvm.org/D34237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34262: [ubsan] PR33081: Skip the standard type checks for volatile
vsk created this revision. Skip checks for null dereference, alignment violation, object size violation, and dynamic type violation if the pointer points to volatile data. https://bugs.llvm.org/show_bug.cgi?id=33081 https://reviews.llvm.org/D34262 Files: lib/CodeGen/CGExpr.cpp test/CodeGen/ubsan-volatile.c Index: test/CodeGen/ubsan-volatile.c === --- /dev/null +++ test/CodeGen/ubsan-volatile.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsanitize=null,alignment,object-size,vptr -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: @volatile_null_deref +void volatile_null_deref() { + // CHECK: [[P:%.*]] = alloca i32* + // CHECK-NEXT: [[V:%.*]] = load i32*, i32** [[P]] + // CHECK-NEXT: load volatile i32, i32* [[V]] + // CHECK-NEXT: ret void + volatile int *p; + *p; +} Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -549,6 +549,11 @@ if (Ptr->getType()->getPointerAddressSpace()) return; + // Don't check pointers to volatile data. The behavior here is implementation- + // defined. + if (Ty.isVolatileQualified()) +return; + SanitizerScope SanScope(this); SmallVector, 3> Checks; Index: test/CodeGen/ubsan-volatile.c === --- /dev/null +++ test/CodeGen/ubsan-volatile.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsanitize=null,alignment,object-size,vptr -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: @volatile_null_deref +void volatile_null_deref() { + // CHECK: [[P:%.*]] = alloca i32* + // CHECK-NEXT: [[V:%.*]] = load i32*, i32** [[P]] + // CHECK-NEXT: load volatile i32, i32* [[V]] + // CHECK-NEXT: ret void + volatile int *p; + *p; +} Index: lib/CodeGen/CGExpr.cpp === --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -549,6 +549,11 @@ if (Ptr->getType()->getPointerAddressSpace()) return; + // Don't check pointers to volatile data. The behavior here is implementation- + // defined. + if (Ty.isVolatileQualified()) +return; + SanitizerScope SanScope(this); SmallVector, 3> Checks; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier
jyu2 updated this revision to Diff 102759. jyu2 marked 13 inline comments as done. https://reviews.llvm.org/D3 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/AnalysisBasedWarnings.cpp test/CXX/except/except.spec/p11.cpp test/SemaCXX/warn-throw-out-noexcept-func.cpp Index: lib/Sema/AnalysisBasedWarnings.cpp === --- lib/Sema/AnalysisBasedWarnings.cpp +++ lib/Sema/AnalysisBasedWarnings.cpp @@ -279,6 +279,152 @@ } //===--===// +// Check for throw in a non-throwing function. +//===--===// +enum ThrowState { + FoundNoPathForThrow, + FoundPathForThrow, + FoundPathWithNoThrowOutFunction, +}; + +static bool isThrowCaught(const CXXThrowExpr *Throw, + const CXXCatchStmt *Catch) { + const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull(); + const Type *ThrowType = nullptr; + if (Throw->getSubExpr()) +ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull(); + + if (ThrowType == nullptr) +return false; + if (ThrowType && ThrowType->isReferenceType()) +ThrowType = ThrowType->castAs() +->getPointeeType() +->getUnqualifiedDesugaredType(); + if (CaughtType == nullptr) +return true; + if (CaughtType && CaughtType->isReferenceType()) +CaughtType = CaughtType->castAs() + ->getPointeeType() + ->getUnqualifiedDesugaredType(); + if (CaughtType == ThrowType) +return true; + const CXXRecordDecl *CaughtAsRecordType = + CaughtType->getPointeeCXXRecordDecl(); + const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl(); + if (CaughtAsRecordType && ThrowTypeAsRecordType) +return ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType); + return false; +} + +static bool isThrowCaughtByHandlers(const CXXThrowExpr *CE, +const CXXTryStmt *TryStmt) { + for (unsigned H = 0, E = TryStmt->getNumHandlers(); H < E; ++H) { +if (isThrowCaught(CE, TryStmt->getHandler(H))) + return true; + } + return false; +} + +static bool doesThrowEscapePath(CFGBlock Block, SourceLocation &OpLoc) { + for (const auto &B : Block) { +if (B.getKind() != CFGElement::Statement) + continue; +const CXXThrowExpr *CE = +dyn_cast(B.getAs()->getStmt()); +if (!CE) + continue; + +OpLoc = CE->getThrowLoc(); +for (const auto &I : Block.succs()) { + if (!I.isReachable()) +continue; + if (const CXXTryStmt *Terminator = + dyn_cast_or_null(I->getTerminator())) +if (isThrowCaughtByHandlers(CE, Terminator)) + return false; +} +return true; + } + return false; +} + +static bool hasThrowOutNonThrowingFunc(SourceLocation &OpLoc, CFG *BodyCFG) { + + unsigned ExitID = BodyCFG->getExit().getBlockID(); + + SmallVector States(BodyCFG->getNumBlockIDs(), + FoundNoPathForThrow); + States[BodyCFG->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction; + + SmallVector Stack; + Stack.push_back(&BodyCFG->getEntry()); + while (!Stack.empty()) { +CFGBlock *CurBlock = Stack.back(); +Stack.pop_back(); + +unsigned ID = CurBlock->getBlockID(); +ThrowState CurState = States[ID]; +if (CurState == FoundPathWithNoThrowOutFunction) { + if (ExitID == ID) +continue; + + if (doesThrowEscapePath(*CurBlock, OpLoc)) +CurState = FoundPathForThrow; +} + +// Loop over successor blocks and add them to the Stack if their state +// changes. +for (const auto &I : CurBlock->succs()) + if (I.isReachable()) { +unsigned NextID = I->getBlockID(); +if (NextID == ExitID && CurState == FoundPathForThrow) { + States[NextID] = CurState; +} else if (States[NextID] < CurState) { + States[NextID] = CurState; + Stack.push_back(I); +} + } + } + // Return true if the exit node is reachable, and only reachable through + // a throw expression. + return States[ExitID] == FoundPathForThrow; +} + +static void EmitDiagForCXXThrowInNonThrowingFunc(SourceLocation OpLoc, Sema &S, + const FunctionDecl *FD) { + if (!S.getSourceManager().isInSystemHeader(OpLoc)) { +S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD; +if (S.getLangOpts().CPlusPlus11 && +(isa(FD) || + FD->getDeclName().getCXXOverloadedOperator() == OO_Delete || + FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete)) + S.Diag(FD->getLocation(), diag::note_throw_in_dtor); +else + S.Diag(FD->getLocation(), diag::note_throw_in_function); + } +} + +static void checkThrowInNonThrowingFunc(Sema &S, const FunctionDecl *FD, +
[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier
jyu2 marked 7 inline comments as done. jyu2 added inline comments. Comment at: lib/Sema/AnalysisBasedWarnings.cpp:296 + + if (ThrowType->isReferenceType()) +ThrowType = ThrowType->castAs() aaron.ballman wrote: > If `ThrowType` can be null, there should be a null pointer check here. If it > cannot be null, you should use `getTypePtr()` above instead of > `getTypePtrOrNull()`. Good catch. Add code and test to handle this Comment at: lib/Sema/AnalysisBasedWarnings.cpp:312 +isCaught = ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType); + return isCaught; +} aaron.ballman wrote: > There's really no point to using a local variable for this. You can return > `true` above and return `false` here. Right. Changed Comment at: lib/Sema/AnalysisBasedWarnings.cpp:315 + +static bool isThrowBeCaughtByHandlers(const CXXThrowExpr *CE, + const CXXTryStmt *TryStmt) { aaron.ballman wrote: > `isThrowCaughtByHandlers` (drop the Be) removed "Be" https://reviews.llvm.org/D3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation
ddcc added inline comments. Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:356 QualType ResultTy) { - if (!State->isTainted(RHS) && !State->isTainted(LHS)) -return UnknownVal(); zaks.anna wrote: > I am concerned that removing the guard will regress performance in the > vanilla case. (Note that Z3 support as well as taint are not on by default.) > > I am curious how much of the regression you've measured could be gained back > if we make this conditional. To clarify, the changes made in this patch aren't specific to Z3 support, especially simplifying `SymbolCast` and `IntSymExpr`. With the exception of `PR24184.cpp` and `plist-macros.cpp`, all testcases pass with both the default and Z3 constraint managers. However, creating additional constraints does have performance overhead, and it may be useful to consider the parameters for gating this functionality. On a combined execution (Range + Z3) through the testcases, except the two mentioned above, the runtime is 327 sec with this patch applied, and 195 sec without this patch applied. On a separate execution through the testcases with only the Z3 constraint manager, I get runtimes 320 and 191, respectively. For testing purposes, I also tried the following code, which has combined runtime 311 sec, but loses the accuracy improvements with the Range constraint manager on `bitwise-ops.c`, `conditional-path-notes.c`, `explain-svals.cpp`, and `std-c-library-functions.c`. ``` ConstraintManager &CM = getStateManager().getConstraintManager(); if (!State->isTainted(RHS) && !State->isTainted(LHS) && !CM.isZ3()) ``` Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:363 // instead of generating an Unknown value and propagate the taint info to it. - const unsigned MaxComp = 1; // 10 28X zaks.anna wrote: > Reducing the MaxComp is going to regress taint analysis.. > > > I've updated this revision to account for the recent SVal simplification > > commit by @NoQ, > > Which commit introduced the regression? > > > but now there is an exponential blowup problem that prevents testcase > > PR24184.cpp from terminating, > > What triggers the regression? Removing the if statement above? Does the > regression only effect the Z3 "mode" (I am guessing not since you said "due > to an interaction between Simplifier::VisitNonLocSymbolVal() and > SValBuilder::makeSymExprValNN()")? > > Reducing the MaxComp is going to regress taint analysis.. I think the original intention was to increase `MaxComp`, not decrease it, but I will restore the original value here. > What triggers the regression? Removing the if statement above? Does the > regression only effect the Z3 "mode" No, the regression isn't specifically due to this code, but with @NoQ 's patch for `SVal` simplification (rL300178), and this commit extending it to handle `SymbolCast` and `IntSymExpr`, the cast of `ST *` used in the loop of case 3 of PR24184.cpp becomes "simplified" (inlined) repeatedly on each recursive iteration through `Simplifier::VisitNonLocSymbolVal()` -> `SValBuilder::makeSymExprValNN()`, causing a big slowdown in runtime performance. The naive way to prevent it is to drop `MaxComp` (but this isn't reasonable, since it needs to be absurdly low, e.g. `10`). Alternatively, simplification for `SymbolCast` can be dropped from this commit (but it will eliminate some of the other analysis improvements), or, most likely, introduce another parameter to reduce recursion between these two functions. https://reviews.llvm.org/D28953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34263: [preprocessor] When preprocessor option 'SingleFileParseMode' is enabled, parse all directive blocks if the condition uses undefined macros
akyrtzi created this revision. This is useful for being able to parse the preprocessor directive blocks even the header that defined the macro that they check for hasn't been included. https://reviews.llvm.org/D34263 Files: include/clang/Lex/Preprocessor.h lib/Lex/PPDirectives.cpp lib/Lex/PPExpressions.cpp test/Index/singe-file-parse.m Index: test/Index/singe-file-parse.m === --- test/Index/singe-file-parse.m +++ test/Index/singe-file-parse.m @@ -9,3 +9,103 @@ // CHECK: [[@LINE+1]]:8: ObjCInstanceMethodDecl=some_meth -(void)some_meth; @end + +#if 1 +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test1 +@interface Test1 @end +#else +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test2 @end +#endif + +#if 0 +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test3 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test4 +@interface Test4 @end +#endif + +#if SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test5 +@interface Test5 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test6 +@interface Test6 @end +#endif + +#define SOMETHING_DEFINED 1 +#if SOMETHING_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test7 +@interface Test7 @end +#else +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test8 @end +#endif + +#if defined(SOMETHING_NOT_DEFINED) +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test9 +@interface Test9 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test10 +@interface Test10 @end +#endif + +#if defined(SOMETHING_DEFINED) +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test11 +@interface Test11 @end +#else +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test12 @end +#endif + +#if SOMETHING_NOT_DEFINED1 +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test13 +@interface Test13 @end +#elif SOMETHING_NOT_DEFINED2 +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test14 +@interface Test14 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test15 +@interface Test15 @end +#endif + +#ifdef SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test19 +@interface Test19 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test20 +@interface Test20 @end +#endif + +#ifdef SOMETHING_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test21 +@interface Test21 @end +#else +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test22 @end +#endif + +#ifndef SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test23 +@interface Test23 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test24 +@interface Test24 @end +#endif + +#ifndef SOMETHING_DEFINED +// CHECK-NOT: [[@LINE+1]]:12: +@interface Test25 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test26 +@interface Test26 @end +#endif + +#if 1 < SOMETHING_NOT_DEFINED +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test27 +@interface Test27 @end +#else +// CHECK: [[@LINE+1]]:12: ObjCInterfaceDecl=Test28 +@interface Test28 @end +#endif Index: lib/Lex/PPExpressions.cpp === --- lib/Lex/PPExpressions.cpp +++ lib/Lex/PPExpressions.cpp @@ -73,6 +73,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, Token &PeekTok, bool ValueLive, + bool &IncludedUndefinedIds, Preprocessor &PP); /// DefinedTracker - This struct is used while parsing expressions to keep track @@ -93,6 +94,7 @@ /// TheMacro - When the state is DefinedMacro or NotDefinedMacro, this /// indicates the macro that was checked. IdentifierInfo *TheMacro; + bool IncludedUndefinedIds = false; }; /// EvaluateDefined - Process a 'defined(sym)' expression. @@ -128,6 +130,7 @@ MacroDefinition Macro = PP.getMacroDefinition(II); Result.Val = !!Macro; Result.Val.setIsUnsigned(false); // Result is signed intmax_t. + DT.IncludedUndefinedIds = !Macro; // If there is a macro, mark it used. if (Result.Val != 0 && ValueLive) @@ -255,6 +258,8 @@ Result.Val.setIsUnsigned(false); // "0" is signed intmax_t 0. Result.setIdentifier(II); Result.setRange(PeekTok.getLocation()); +DT.IncludedUndefinedIds = (II->getTokenID() != tok::kw_true && + II->getTokenID() != tok::kw_false); PP.LexNonComment(PeekTok); return false; } @@ -400,7 +405,8 @@ // Just use DT unmodified as our result. } else { // Otherwise, we have something like (x+y), and we consumed '(x'. - if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP)) + if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, + DT.IncludedUndefinedIds, PP)) return true; if (PeekTok.isNot(tok::r_paren)) { @@ -532,6 +538,7 @@ /// evaluation, such as division by zero warnings. static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, Tok
[libcxx] r305536 - Allow coroutine_handle to support creation from const references to the promise_type
Author: ericwf Date: Thu Jun 15 19:36:17 2017 New Revision: 305536 URL: http://llvm.org/viewvc/llvm-project?rev=305536&view=rev Log: Allow coroutine_handle to support creation from const references to the promise_type It seems conceivable that a user would need to get a coroutine handle having only a const reference to the promise_type, for example from within a const member function of the promise. This patch allows that use case. A coroutine_handle can be used in essentially the same way a coroutine_handle, ie to start and destroy the coroutine. The constness of the promise doesn't/shouldn't propagate to the handle. Modified: libcxx/trunk/include/experimental/coroutine libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp Modified: libcxx/trunk/include/experimental/coroutine URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=305536&r1=305535&r2=305536&view=diff == --- libcxx/trunk/include/experimental/coroutine (original) +++ libcxx/trunk/include/experimental/coroutine Thu Jun 15 19:36:17 2017 @@ -250,9 +250,11 @@ public: _LIBCPP_ALWAYS_INLINE static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT { +typedef typename remove_cv<_Promise>::type _RawPromise; coroutine_handle __tmp; -__tmp.__handle_ = __builtin_coro_promise(_VSTD::addressof(__promise), - __alignof(_Promise), true); +__tmp.__handle_ = __builtin_coro_promise( +_VSTD::addressof(const_cast<_RawPromise&>(__promise)), + __alignof(_Promise), true); return __tmp; } }; Modified: libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp?rev=305536&r1=305535&r2=305536&view=diff == --- libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp (original) +++ libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.prom/promise.pass.cpp Thu Jun 15 19:36:17 2017 @@ -28,6 +28,39 @@ namespace coro = std::experimental; +struct MyCoro { + struct promise_type { +void unhandled_exception() {} +void return_void() {} +coro::suspend_never initial_suspend() { return {}; } +coro::suspend_never final_suspend() { return {}; } +MyCoro get_return_object() { + do_runtime_test(); + return {}; +} +void do_runtime_test() { + // Test that a coroutine_handle can be created from a const + // promise_type and that it represents the same coroutine as + // coroutine_handle + using CH = coro::coroutine_handle; + using CCH = coro::coroutine_handle; + const auto &cthis = *this; + CH h = CH::from_promise(*this); + CCH h2 = CCH::from_promise(*this); + CCH h3 = CCH::from_promise(cthis); + assert(&h.promise() == this); + assert(&h2.promise() == this); + assert(&h3.promise() == this); + assert(h.address() == h2.address()); + assert(h2.address() == h3.address()); +} + }; +}; + +MyCoro do_runtime_test() { + co_await coro::suspend_never{}; +} + template void do_test(coro::coroutine_handle&& H) { @@ -46,4 +79,6 @@ void do_test(coro::coroutine_handle{}); + do_test(coro::coroutine_handle{}); + do_runtime_test(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34256: [PR33394] Avoid lexing editor placeholders when running the preprocessor only
arphaman updated this revision to Diff 102764. arphaman added a comment. Fair enough. I removed the special checks for `<#>` and `<##>`. Repository: rL LLVM https://reviews.llvm.org/D34256 Files: include/clang/Lex/PreprocessorOptions.h lib/Frontend/CompilerInvocation.cpp lib/Lex/Lexer.cpp test/Frontend/pp-only-no-editor-placeholders.c Index: test/Frontend/pp-only-no-editor-placeholders.c === --- /dev/null +++ test/Frontend/pp-only-no-editor-placeholders.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -E -verify -o - %s | FileCheck %s +// expected-no-diagnostics + +<#placeholder#>; // CHECK: <#placeholder#>; Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -19,6 +19,7 @@ #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/LiteralSupport.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Compiler.h" @@ -2750,7 +2751,7 @@ bool Lexer::lexEditorPlaceholder(Token &Result, const char *CurPtr) { assert(CurPtr[-1] == '<' && CurPtr[0] == '#' && "Not a placeholder!"); - if (!PP || LexingRawMode) + if (!PP || !PP->getPreprocessorOpts().LexEditorPlaceholders || LexingRawMode) return false; const char *End = findPlaceholderEnd(CurPtr + 1, BufferEnd); if (!End) Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2379,9 +2379,51 @@ Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders); } +static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { + switch (Action) { + case frontend::ASTDeclList: + case frontend::ASTDump: + case frontend::ASTPrint: + case frontend::ASTView: + case frontend::EmitAssembly: + case frontend::EmitBC: + case frontend::EmitHTML: + case frontend::EmitLLVM: + case frontend::EmitLLVMOnly: + case frontend::EmitCodeGenOnly: + case frontend::EmitObj: + case frontend::FixIt: + case frontend::GenerateModule: + case frontend::GenerateModuleInterface: + case frontend::GeneratePCH: + case frontend::GeneratePTH: + case frontend::ParseSyntaxOnly: + case frontend::ModuleFileInfo: + case frontend::VerifyPCH: + case frontend::PluginAction: + case frontend::PrintDeclContext: + case frontend::RewriteObjC: + case frontend::RewriteTest: + case frontend::RunAnalysis: + case frontend::MigrateSource: +return false; + + case frontend::DumpRawTokens: + case frontend::DumpTokens: + case frontend::InitOnly: + case frontend::PrintPreamble: + case frontend::PrintPreprocessedInput: + case frontend::RewriteMacros: + case frontend::RunPreprocessorOnly: +return true; + } + llvm_unreachable("invalid frontend action"); +} + static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, FileManager &FileMgr, - DiagnosticsEngine &Diags) { + DiagnosticsEngine &Diags, + frontend::ActionKind Action) { using namespace options; Opts.ImplicitPCHInclude = Args.getLastArgValue(OPT_include_pch); Opts.ImplicitPTHInclude = Args.getLastArgValue(OPT_include_pth); @@ -2454,52 +2496,23 @@ else Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library; } + + // Always avoid lexing editor placeholders when we're just running the + // preprocessor as we never want to emit the + // "editor placeholder in source file" error in PP only mode. + if (isStrictlyPreprocessorAction(Action)) +Opts.LexEditorPlaceholders = false; } static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, ArgList &Args, frontend::ActionKind Action) { using namespace options; - switch (Action) { - case frontend::ASTDeclList: - case frontend::ASTDump: - case frontend::ASTPrint: - case frontend::ASTView: - case frontend::EmitAssembly: - case frontend::EmitBC: - case frontend::EmitHTML: - case frontend::EmitLLVM: - case frontend::EmitLLVMOnly: - case frontend::EmitCodeGenOnly: - case frontend::EmitObj: - case frontend::FixIt: - case frontend::GenerateModule: - case frontend::GenerateModuleInterface: - case frontend::GeneratePCH: - case frontend::GeneratePTH: - case frontend::ParseSyntaxOnly: - case frontend::ModuleFileInfo: - case frontend::VerifyPCH: - case frontend::PluginAction: - case frontend::PrintDeclContext: - case frontend::RewriteObjC: - case frontend::RewriteTest: - case frontend::RunAnalysis: - case frontend::MigrateSource: -Opts.ShowCPP = 0; -break; - - case frontend::DumpRawTokens: - case frontend::DumpTokens:
Re: [libcxx] r276238 - Implement std::string_view as described in http://wg21.link/P0254R1. Reviewed as https://reviews.llvm.org/D21459
> On Jul 20, 2016, at 22:31, Marshall Clow via cfe-commits > wrote: > > Modified: libcxx/trunk/include/string > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=276238&r1=276237&r2=276238&view=diff > == > > @@ -435,6 +461,7 @@ basic_string operator "" s( co > */ > > #include <__config> > +#include This breaks the following, valid, C++14 code: #include #include using namespace std; using std::experimental::string_view; void f() { string_view sv; } Should #include even when we're not in C++17 mode? Why? > #include > #include > #include // For EOF. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34262: [ubsan] PR33081: Skip the standard type checks for volatile
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. Looks good, and I did ask Richard about this in person before filing the bug and he was in favor of it, so feel free to commit. If I'd known how easy it was to implement and how few tests it would break, I would've made the patch instead of filing it. :) Thanks for getting around to it. Comment at: test/CodeGen/ubsan-volatile.c:9 + // CHECK-NEXT: ret void + volatile int *p; + *p; IMO the CHECKs would be cleaner if this were a parameter. You can do `CHECK-NOT: call{{.*}}ubsan` or something. https://reviews.llvm.org/D34262 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets
arphaman created this revision. This patch adds a new warning flag called `-Wunguarded-availability-new`. If `-Wunguarded-availability` is off, this warning only warns about uses of APIs that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and tvOS >= 11. This warning is on by default. We decided to use this kind of solution as we didn't want to turn on `-Wunguarded-availability` by default, as we didn't want our users to get warnings about uses of old APIs in their existing projects. Repository: rL LLVM https://reviews.llvm.org/D34264 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclAttr.cpp test/SemaObjC/unguarded-availability-new.m Index: test/SemaObjC/unguarded-availability-new.m === --- /dev/null +++ test/SemaObjC/unguarded-availability-new.m @@ -0,0 +1,129 @@ +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -xobjective-c++ -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s + +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability-new -DNO_WARNING -fblocks -fsyntax-only -verify %s + +// unguarded-availability implies unguarded-availability-new: +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -Wno-unguarded-availability-new -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s + +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-ios11 -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.12 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s + +// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios10.3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s + +// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos10 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s + +// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s +// RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s + +#ifdef MAC +#define PLATFORM macos +#define NEXT 10.14 + +#define AVAILABLE_PREV __attribute__((availability(macos, introduced = 10.12))) +#define AVAILABLE_CURRENT __attribute__((availability(macos, introduced = 10.13))) +#define AVAILABLE_NEXT __attribute__((availability(macos, introduced = 10.14))) +#endif + +#ifdef IOS +#define PLATFORM ios +#define NEXT 12 + +#define AVAILABLE_PREV __attribute__((availability(ios, introduced = 10))) +#define AVAILABLE_CURRENT __attribute__((availability(ios, introduced = 11))) +#define AVAILABLE_NEXT __attribute__((availability(ios, introduced = 12))) +#endif + +#ifdef TVOS +#define PLATFORM tvos +#define NEXT 13 + +#define AVAILABLE_PREV __attribute__((availability(tvos, introduced = 10))) +#define AVAILABLE_CURRENT __attribute__((availability(tvos, introduced = 11))) +#define AVAILABLE_NEXT __attribute__((availability(tvos, introduced = 13))) +#endif + +#ifdef WATCHOS +#define PLATFORM watchos +#define NEXT 5 + +#define AVAILABLE_PREV __attribute__((availability(watchos, introduced = 3))) +#define AVAILABLE_CURRENT __attribute__((availability(watchos, introduced = 4))) +#define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5))) +#endif + +void previouslyAvailable() AVAIL
[PATCH] D34264: Introduce -Wunguarded-availability-new, which is like -Wunguarded-availability, except that it's enabled by default for new deployment targets
erik.pilkington added inline comments. Comment at: lib/Sema/SemaDeclAttr.cpp:7315 + default: +assert(!Triple.isMacOSX() && "MacOS should be handled in the switch"); +// New targets should always warn about availability. This assert seems a bit redundant, no? Comment at: lib/Sema/SemaDeclAttr.cpp:7350 +unsigned DiagKind = +!SemaRef.Diags.isIgnored(diag::warn_unguarded_availability_new, + Range.getBegin()) && There is a version of this for decls that aren't referenced in a function, such as: ``` typedef int __attribute__((availability(macos, introducced=1000))) new_int; new_int x; // warn // Also: struct S { new_int x; // warn }; ``` -Wunguarded-availability-new should also work with this, right? If we do want to support that, maybe we should add this check to ShouldDiagnoseAvailabilityOfDecl(), which is called by both paths. Repository: rL LLVM https://reviews.llvm.org/D34264 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33816: [Sema][ObjC] Don't allow -Wunguarded-availability to be silenced with redeclarations
erik.pilkington added a comment. Ping! https://reviews.llvm.org/D33816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r276238 - Implement std::string_view as described in http://wg21.link/P0254R1. Reviewed as https://reviews.llvm.org/D21459
It *shouldn't* include , that's a given. IIRC, and Marshall would know better, I believe it was untenable to maintain a version of that didn't depend on after making the changes required for C++17. However inspecting now it does seem possible that the entanglement is avoidable.Though it's also likely I'm just not seeing the whole picture. /Eric On Thu, Jun 15, 2017 at 6:42 PM, Duncan P. N. Exon Smith < dexonsm...@apple.com> wrote: > > > On Jul 20, 2016, at 22:31, Marshall Clow via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > > > > Modified: libcxx/trunk/include/string > > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ > string?rev=276238&r1=276237&r2=276238&view=diff > > > == > > > > @@ -435,6 +461,7 @@ basic_string operator "" s( co > > */ > > > > #include <__config> > > +#include > > This breaks the following, valid, C++14 code: > > #include > #include > using namespace std; > using std::experimental::string_view; > void f() { string_view sv; } > > Should #include even when we're not in C++17 mode? > Why? > > > #include > > #include > > #include // For EOF. > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34266: Static Analyzer - Localizability Checker: New Localizable APIs for macOS High Sierra & iOS 11
kulpreet created this revision. - Added in new iOS and macOS APIs that require a localized string - Ran unit tests Repository: rL LLVM https://reviews.llvm.org/D34266 Files: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp === --- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -281,6 +281,9 @@ IdentifierInfo *setLabelNSSegmentedControl[] = { &Ctx.Idents.get("setLabel"), &Ctx.Idents.get("forSegment")}; ADD_METHOD(NSSegmentedControl, setLabelNSSegmentedControl, 2, 0) + IdentifierInfo *setToolTipNSSegmentedControl[] = { + &Ctx.Idents.get("setToolTip"), &Ctx.Idents.get("forSegment")}; + ADD_METHOD(NSSegmentedControl, setToolTipNSSegmentedControl, 2, 0) NEW_RECEIVER(NSButtonCell) ADD_UNARY_METHOD(NSButtonCell, setTitle, 0) @@ -562,6 +565,46 @@ IdentifierInfo *setTitleUISegmentedControl[] = { &Ctx.Idents.get("setTitle"), &Ctx.Idents.get("forSegmentAtIndex")}; ADD_METHOD(UISegmentedControl, setTitleUISegmentedControl, 2, 0) + + NEW_RECEIVER(NSAccessibilityCustomRotorItemResult) + IdentifierInfo + *initWithItemLoadingTokenNSAccessibilityCustomRotorItemResult[] = { + &Ctx.Idents.get("initWithItemLoadingToken"), + &Ctx.Idents.get("customLabel")}; + ADD_METHOD(NSAccessibilityCustomRotorItemResult, + initWithItemLoadingTokenNSAccessibilityCustomRotorItemResult, 2, 1) + ADD_UNARY_METHOD(NSAccessibilityCustomRotorItemResult, setCustomLabel, 0) + + NEW_RECEIVER(UIContextualAction) + IdentifierInfo *contextualActionWithStyleUIContextualAction[] = { + &Ctx.Idents.get("contextualActionWithStyle"), &Ctx.Idents.get("title"), + &Ctx.Idents.get("handler")}; + ADD_METHOD(UIContextualAction, contextualActionWithStyleUIContextualAction, 3, + 1) + ADD_UNARY_METHOD(UIContextualAction, setTitle, 0) + + NEW_RECEIVER(NSAccessibilityCustomRotor) + IdentifierInfo *initWithLabelNSAccessibilityCustomRotor[] = { + &Ctx.Idents.get("initWithLabel"), &Ctx.Idents.get("itemSearchDelegate")}; + ADD_METHOD(NSAccessibilityCustomRotor, + initWithLabelNSAccessibilityCustomRotor, 2, 0) + ADD_UNARY_METHOD(NSAccessibilityCustomRotor, setLabel, 0) + + NEW_RECEIVER(NSWindowTab) + ADD_UNARY_METHOD(NSWindowTab, setTitle, 0) + ADD_UNARY_METHOD(NSWindowTab, setToolTip, 0) + + NEW_RECEIVER(NSAccessibilityCustomAction) + IdentifierInfo *initWithNameNSAccessibilityCustomAction[] = { + &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("handler")}; + ADD_METHOD(NSAccessibilityCustomAction, + initWithNameNSAccessibilityCustomAction, 2, 0) + IdentifierInfo *initWithNameTargetNSAccessibilityCustomAction[] = { + &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("target"), + &Ctx.Idents.get("selector")}; + ADD_METHOD(NSAccessibilityCustomAction, + initWithNameTargetNSAccessibilityCustomAction, 3, 0) + ADD_UNARY_METHOD(NSAccessibilityCustomAction, setName, 0) } #define LSF_INSERT(function_name) LSF.insert(&Ctx.Idents.get(function_name)); Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp === --- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -281,6 +281,9 @@ IdentifierInfo *setLabelNSSegmentedControl[] = { &Ctx.Idents.get("setLabel"), &Ctx.Idents.get("forSegment")}; ADD_METHOD(NSSegmentedControl, setLabelNSSegmentedControl, 2, 0) + IdentifierInfo *setToolTipNSSegmentedControl[] = { + &Ctx.Idents.get("setToolTip"), &Ctx.Idents.get("forSegment")}; + ADD_METHOD(NSSegmentedControl, setToolTipNSSegmentedControl, 2, 0) NEW_RECEIVER(NSButtonCell) ADD_UNARY_METHOD(NSButtonCell, setTitle, 0) @@ -562,6 +565,46 @@ IdentifierInfo *setTitleUISegmentedControl[] = { &Ctx.Idents.get("setTitle"), &Ctx.Idents.get("forSegmentAtIndex")}; ADD_METHOD(UISegmentedControl, setTitleUISegmentedControl, 2, 0) + + NEW_RECEIVER(NSAccessibilityCustomRotorItemResult) + IdentifierInfo + *initWithItemLoadingTokenNSAccessibilityCustomRotorItemResult[] = { + &Ctx.Idents.get("initWithItemLoadingToken"), + &Ctx.Idents.get("customLabel")}; + ADD_METHOD(NSAccessibilityCustomRotorItemResult, + initWithItemLoadingTokenNSAccessibilityCustomRotorItemResult, 2, 1) + ADD_UNARY_METHOD(NSAccessibilityCustomRotorItemResult, setCustomLabel, 0) + + NEW_RECEIVER(UIContextualAction) + IdentifierInfo *contextualActionWithStyleUIContextualAction[] = { + &Ctx.Idents.get("contextualActionWithStyle"), &Ctx.Idents.get("title"), + &Ctx.Idents.get("handler")}; + ADD_METHOD(UIContextualAction, contextualActionWithStyleUIContextualAction, 3, + 1) + ADD_UNARY_METHOD(UIContextualAction, setTitle, 0) + + NEW_RECEIVER(NSAc
[PATCH] D34237: Mark the operations of __wrap_iter as constexpr
EricWF added a comment. A large portion of this patch is UB. Any function that unconditionally calls `__get_db()` can never be a valid constant expression, hence UB. Is there a smaller set of operations or `__wrap_iter` that *must* be made constexpr? Or do they all need to be? Comment at: include/algorithm:1765 template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 typename enable_if These definitions should probably be moved to `` where they are declared. I'm not sure why they lived in `` to begin with. Comment at: include/iterator:1202 template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 bool These forward declarations seem unnecessary since they're also forward declared as friend functions inside `__wrap_iter` https://reviews.llvm.org/D34237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r305539 - Allow the libc++ C header wrappers to be included when compiling C.
Author: ericwf Date: Thu Jun 15 20:57:41 2017 New Revision: 305539 URL: http://llvm.org/viewvc/llvm-project?rev=305539&view=rev Log: Allow the libc++ C header wrappers to be included when compiling C. C99 at least. C89 still fails due to the use of block comments. NOTE: Having libc++ on the include path when compiling C is not recommended or ever really supported. However it happens often enough that this change is warrented. Added: libcxx/trunk/test/libcxx/include_as_c.sh.cpp Modified: libcxx/trunk/include/__config Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305539&r1=305538&r2=305539&view=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Thu Jun 15 20:57:41 2017 @@ -1135,8 +1135,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit # define _LIBCPP_HAS_NO_COROUTINES #endif -#endif // __cplusplus - // Decide whether to use availability macros. #if !defined(_LIBCPP_BUILDING_LIBRARY) && \ !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ @@ -1240,4 +1238,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit # endif #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) + +#endif // __cplusplus + #endif // _LIBCPP_CONFIG Added: libcxx/trunk/test/libcxx/include_as_c.sh.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/include_as_c.sh.cpp?rev=305539&view=auto == --- libcxx/trunk/test/libcxx/include_as_c.sh.cpp (added) +++ libcxx/trunk/test/libcxx/include_as_c.sh.cpp Thu Jun 15 20:57:41 2017 @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// Test that the C wrapper headers can be included when compiling them as C. + +// NOTE: It's not common or recommended to have libc++ in the header search +// path when compiling C files, but it does happen often enough. + +// RUN: %cxx -c -xc %s -fsyntax-only %flags %compile_flags -std=c99 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits