r291427 - Implement C++ DR1391 (wg21.link/cwg1391)
Author: rsmith Date: Mon Jan 9 02:01:21 2017 New Revision: 291427 URL: http://llvm.org/viewvc/llvm-project?rev=291427&view=rev Log: Implement C++ DR1391 (wg21.link/cwg1391) Check for implicit conversion sequences for non-dependent function template parameters between deduction and substitution. The idea is to accept as many cases as possible, on the basis that substitution failure outside the immediate context is much more common during substitution than during implicit conversion sequence formation. This re-commits r290808, reverted in r290811 and r291412, with a couple of fixes for handling of explicitly-specified non-trailing template argument packs. Modified: cfe/trunk/include/clang/Sema/Overload.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/test/CXX/drs/dr13xx.cpp cfe/trunk/test/Misc/diag-template-diffing.cpp cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp cfe/trunk/test/SemaCXX/attr-noreturn.cpp cfe/trunk/test/SemaCXX/overload-call.cpp cfe/trunk/test/SemaCXX/overload-member-call.cpp cfe/trunk/test/SemaTemplate/deduction.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp cfe/trunk/www/cxx_dr_status.html Modified: cfe/trunk/include/clang/Sema/Overload.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=291427&r1=291426&r2=291427&view=diff == --- cfe/trunk/include/clang/Sema/Overload.h (original) +++ cfe/trunk/include/clang/Sema/Overload.h Mon Jan 9 02:01:21 2017 @@ -531,6 +531,13 @@ namespace clang { Ambiguous.construct(); } +void setAsIdentityConversion(QualType T) { + setStandard(); + Standard.setAsIdentityConversion(); + Standard.setFromType(T); + Standard.setAllToTypes(T); +} + /// \brief Whether the target is really a std::initializer_list, and the /// sequence only represents the worst element conversion. bool isStdInitializerListElement() const { @@ -607,6 +614,11 @@ namespace clang { ovl_fail_inhctor_slice, }; + /// A list of implicit conversion sequences for the arguments of an + /// OverloadCandidate. + typedef llvm::MutableArrayRef + ConversionSequenceList; + /// OverloadCandidate - A single candidate in an overload set (C++ 13.3). struct OverloadCandidate { /// Function - The actual function that this candidate @@ -631,18 +643,13 @@ namespace clang { /// is a surrogate, but only if IsSurrogate is true. CXXConversionDecl *Surrogate; -/// Conversions - The conversion sequences used to convert the -/// function arguments to the function parameters, the pointer points to a -/// fixed size array with NumConversions elements. The memory is owned by -/// the OverloadCandidateSet. -ImplicitConversionSequence *Conversions; +/// The conversion sequences used to convert the function arguments +/// to the function parameters. +ConversionSequenceList Conversions; /// The FixIt hints which can be used to fix the Bad candidate. ConversionFixItGenerator Fix; -/// NumConversions - The number of elements in the Conversions array. -unsigned NumConversions; - /// Viable - True to indicate that this overload candidate is viable. bool Viable; @@ -701,9 +708,9 @@ namespace clang { /// hasAmbiguousConversion - Returns whether this overload /// candidate requires an ambiguous conversion or not. bool hasAmbiguousConversion() const { - for (unsigned i = 0, e = NumConversions; i != e; ++i) { -if (!Conversions[i].isInitialized()) return false; -if (Conversions[i].isAmbiguous()) return true; + for (auto &C : Conversions) { +if (!C.isInitialized()) return false; +if (C.isAmbiguous()) return true; } return false; } @@ -752,7 +759,7 @@ namespace clang { SmallVector Candidates; llvm::SmallPtrSet Functions; -// Allocator for OverloadCandidate::Conversions and DiagnoseIfAttr* arrays. +// Allocator for ConversionSequenceLists and DiagnoseIfAttr* arrays. // We store the first few of each of these inline to avoid allocation for // small sets. llvm::BumpPtrAllocator SlabAllocator; @@ -823,18 +830,32 @@ namespace clang { size_t size() const { return Candidates.size(); } bool empty() const { return Candidates.empty(); } +/// \brief Allocate storage for conversion sequences for NumConversions +/// conversions. +ConversionSequenceList +allocateConversionSequences(unsigned NumConversions) { + ImplicitConversionSequence *Conversions = + slabAllocate(NumConversions); + + // Construct the new objects. + for (unsigned I = 0; I != NumConversions; ++I) +new (&Conversions[I]) ImplicitConversionSequence(); + + return ConversionSequenceList(Conversions, NumConversi
[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC
rsmith added a comment. This makes sense to me in principle, but I'd like @chandlerc to weigh in. https://reviews.llvm.org/D26244 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D28279: [clang-move] Support moving type alias declarations.
Testing phab parsing... On Wed, Jan 4, 2017 at 4:01 PM Haojian Wu via Phabricator via cfe-commits < cfe-commits@lists.llvm.org> wrote: > This revision was automatically updated to reflect the committed changes. > Closed by commit rL290967: [clang-move] Support moving type alias > declarations. (authored by hokein). > > Changed prior to commit: > https://reviews.llvm.org/D28279?vs=83016&id=83053#toc > > Repository: > rL LLVM > > https://reviews.llvm.org/D28279 > > Files: > clang-tools-extra/trunk/clang-move/ClangMove.cpp > clang-tools-extra/trunk/test/clang-move/Inputs/type_alias.h > clang-tools-extra/trunk/test/clang-move/move-type-alias.cpp > clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.h:63 +/// Common pre(post)-action for different OpenMP constructs. +class CommonActionTy final : public PrePostActionTy { + llvm::Value *EnterCallee; I don't think it is good to name it CommonActionTy, I think it is something specific to NVPTX codegen. Could you give it some specific name + move it somewhere to NVPTX-related part of code (to .cpp file, if possible) Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:539-542 +llvm::Value *EndArgs[] = {emitUpdateLocation(CGF, Loc), ThreadID}; +CGF.EmitRuntimeCall( +createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel), +EndArgs); arpith-jacob wrote: > ABataev wrote: > > It is better to emit this code as PrePostAction, so it is called upon exit > > of any cleanup scope > Alexey, do you mean clean up during the execution of the serialized parallel > region? Is something like this what you have in mind? Thanks. > > auto &&SeqGen = [this, Fn, &CapturedVars, &RTLoc, &Loc](CodeGenFunction > &CGF, > PrePostActionTy &) { > auto &&CodeGen = [..](..) { > llvm::Value *Args[] = {RTLoc, ThreadID}; > CGF.EmitRuntimeCall( > > createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_serialized_parallel), > Args); > > llvm::SmallVector OutlinedFnArgs; > OutlinedFnArgs.push_back( > llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo())); > OutlinedFnArgs.push_back( > llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo())); > OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end()); > CGF.EmitCallOrInvoke(Fn, OutlinedFnArgs); > }; > > RegionCodeGenTy RCG(CodeGen); > CommonActionTy Action( > nullptr, llvm::None, > > createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel), > {emitUpdateLocation(CGF, Loc), ThreadID}); > RCG.setAction(Action); > RCG(CGF); > }; > Yes, exactly. Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:365 +llvm::FunctionType *FnTy = +llvm::FunctionType::get(llvm::Type::getInt1Ty(CGM.getLLVMContext()), +TypeParams, /*isVarArg*/ false); Does it really return I1 type? Or I8? https://reviews.llvm.org/D28145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28243: [OpenMP] Add missing regression test for pragma distribute, clause firstprivate
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D28243 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28252: [OpenMP] Sema and parsing for 'target teams distribute simd' pragma
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG with a nit Comment at: lib/Sema/SemaOpenMP.cpp:6444 + + CapturedStmt *CS = cast(AStmt); + // 1.2.2 OpenMP Language Terminology auto * https://reviews.llvm.org/D28252 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28255: [OpenMP] support the 'is_device_ptr' clause with 'target parallel for' pragma
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D28255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28419: clang-tools-extra: add gitattributes to disable EOL conversions on checkout of test source files
ioeric added a comment. I'm not entirely sure about this change... looping in Manuel. https://reviews.llvm.org/D28419 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28465: clang-format: [JS] ASI after imports
mprobst created this revision. mprobst added a reviewer: klimek. mprobst added a subscriber: cfe-commits. Automatic semicolon insertion should break import and export statements: Before, this would format on one line: // Note: no semi after 'x' below! import {x} from 'x' export function foo() {} Into: import {x} from 'x' export function foo() {} With this change, the statements get separated. This also improves automatic semicolon insertion to consider closing braces preceding declarations and statements. https://reviews.llvm.org/D28465 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -858,6 +858,24 @@ "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export function z() {}"); + verifyFormat( + "export {x}\n" + "class Y {}", + " export {x}\n" + " class Y {\n}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -737,17 +737,18 @@ return; } if (Next->is(tok::exclaim) && PreviousMustBeValue) -addUnwrappedLine(); +return addUnwrappedLine(); bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next); bool NextEndsTemplateExpr = Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); if (NextMustBeValue && !NextEndsTemplateExpr && !PreviousStartsTemplateExpr && (PreviousMustBeValue || Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) -addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -addUnwrappedLine(); +return addUnwrappedLine(); + if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && + isJSDeclOrStmt(Keywords, Next)) +return addUnwrappedLine(); } void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ !FormatTok->isStringLiteral()) return; - while (!eof() && FormatTok->isNot(tok::semi)) { + while (!eof()) { +if (FormatTok->is(tok::semi)) + return; +if (Line->Tokens.size() == 0) { + // Common issue: Automatic Semicolon Insertion wrapped the line, so the + // import statement should terminate. + return; +} if (FormatTok->is(tok::l_brace)) { FormatTok->BlockKind = BK_Block; parseBracedList(); Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -858,6 +858,24 @@ "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export function z() {}"); + verifyFormat( + "export {x}\n" + "class Y {}", + " export {x}\n" + " class Y {\n}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -737,17 +737,18 @@ return; } if (Next->is(tok::exclaim) && PreviousMustBeValue) -addUnwrappedLine(); +return addUnwrappedLine(); bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next); bool NextEndsTemplateExpr = Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); if (NextMustBeValue && !NextEndsTemplateExpr && !PreviousStartsTemplateExpr && (PreviousMustBeValue || Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) -addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -addUnwrappedLine(); +return addUnwrappedLine(); + if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && + isJSDeclOrStmt(Keywords, Next)) +return addUnwrappedLine(); } void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ !FormatTok->isStringLiteral()) return; - while (!eof() && FormatTok->isNot(tok::semi)) { + while (!eof()) { +if (FormatTok->is(tok::semi)) + re
[PATCH] D28465: clang-format: [JS] ASI after imports
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D28465 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291428 - clang-format: [JS] ASI after imports
Author: mprobst Date: Mon Jan 9 02:56:36 2017 New Revision: 291428 URL: http://llvm.org/viewvc/llvm-project?rev=291428&view=rev Log: clang-format: [JS] ASI after imports Summary: Automatic semicolon insertion should break import and export statements: Before, this would format on one line: // Note: no semi after 'x' below! import {x} from 'x' export function foo() {} Into: import {x} from 'x' export function foo() {} With this change, the statements get separated. This also improves automatic semicolon insertion to consider closing braces preceding declarations and statements. Reviewers: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28465 Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=291428&r1=291427&r2=291428&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jan 9 02:56:36 2017 @@ -737,7 +737,7 @@ void UnwrappedLineParser::readTokenWithJ return; } if (Next->is(tok::exclaim) && PreviousMustBeValue) -addUnwrappedLine(); +return addUnwrappedLine(); bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next); bool NextEndsTemplateExpr = Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); @@ -745,9 +745,10 @@ void UnwrappedLineParser::readTokenWithJ (PreviousMustBeValue || Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) -addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -addUnwrappedLine(); +return addUnwrappedLine(); + if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && + isJSDeclOrStmt(Keywords, Next)) +return addUnwrappedLine(); } void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ void UnwrappedLineParser::parseJavaScrip !FormatTok->isStringLiteral()) return; - while (!eof() && FormatTok->isNot(tok::semi)) { + while (!eof()) { +if (FormatTok->is(tok::semi)) + return; +if (Line->Tokens.size() == 0) { + // Common issue: Automatic Semicolon Insertion wrapped the line, so the + // import statement should terminate. + return; +} if (FormatTok->is(tok::l_brace)) { FormatTok->BlockKind = BK_Block; parseBracedList(); Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=291428&r1=291427&r2=291428&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 9 02:56:36 2017 @@ -858,6 +858,24 @@ TEST_F(FormatTestJS, AutomaticSemicolonI "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export function z() {}"); + verifyFormat( + "export {x}\n" + "class Y {}", + " export {x}\n" + " class Y {\n}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28465: clang-format: [JS] ASI after imports
This revision was automatically updated to reflect the committed changes. Closed by commit rL291428: clang-format: [JS] ASI after imports (authored by mprobst). Changed prior to commit: https://reviews.llvm.org/D28465?vs=83593&id=83594#toc Repository: rL LLVM https://reviews.llvm.org/D28465 Files: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -737,17 +737,18 @@ return; } if (Next->is(tok::exclaim) && PreviousMustBeValue) -addUnwrappedLine(); +return addUnwrappedLine(); bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next); bool NextEndsTemplateExpr = Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); if (NextMustBeValue && !NextEndsTemplateExpr && !PreviousStartsTemplateExpr && (PreviousMustBeValue || Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) -addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -addUnwrappedLine(); +return addUnwrappedLine(); + if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && + isJSDeclOrStmt(Keywords, Next)) +return addUnwrappedLine(); } void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ !FormatTok->isStringLiteral()) return; - while (!eof() && FormatTok->isNot(tok::semi)) { + while (!eof()) { +if (FormatTok->is(tok::semi)) + return; +if (Line->Tokens.size() == 0) { + // Common issue: Automatic Semicolon Insertion wrapped the line, so the + // import statement should terminate. + return; +} if (FormatTok->is(tok::l_brace)) { FormatTok->BlockKind = BK_Block; parseBracedList(); Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -858,6 +858,24 @@ "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export function z() {}"); + verifyFormat( + "export {x}\n" + "class Y {}", + " export {x}\n" + " class Y {\n}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -737,17 +737,18 @@ return; } if (Next->is(tok::exclaim) && PreviousMustBeValue) -addUnwrappedLine(); +return addUnwrappedLine(); bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next); bool NextEndsTemplateExpr = Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); if (NextMustBeValue && !NextEndsTemplateExpr && !PreviousStartsTemplateExpr && (PreviousMustBeValue || Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus, tok::minusminus))) -addUnwrappedLine(); - if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -addUnwrappedLine(); +return addUnwrappedLine(); + if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && + isJSDeclOrStmt(Keywords, Next)) +return addUnwrappedLine(); } void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ !FormatTok->isStringLiteral()) return; - while (!eof() && FormatTok->isNot(tok::semi)) { + while (!eof()) { +if (FormatTok->is(tok::semi)) + return; +if (Line->Tokens.size() == 0) { + // Common issue: Automatic Semicolon Insertion wrapped the line, so the + // import statement should terminate. + return; +} if (FormatTok->is(tok::l_brace)) { FormatTok->BlockKind = BK_Block; parseBracedList(); Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -858,6 +858,24 @@ "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export fun
r291429 - clang-format: [JS] fix broken test.
Author: mprobst Date: Mon Jan 9 03:00:58 2017 New Revision: 291429 URL: http://llvm.org/viewvc/llvm-project?rev=291429&view=rev Log: clang-format: [JS] fix broken test. Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=291429&r1=291428&r2=291429&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 9 03:00:58 2017 @@ -859,7 +859,9 @@ TEST_F(FormatTestJS, AutomaticSemicolonI "a = null\n" " return 1"); verifyFormat( - "x = {a: 1}\n" + "x = {\n" + " a: 1\n" + "}\n" "class Y {}", " x = {a : 1}\n" " class Y { }"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28418: Fixing test to work when the compiler defaults to a different C++ standard version
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG https://reviews.llvm.org/D28418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28208: Remove isIgnored()-test that is more expensive than the analysis behind it
djasper closed this revision. djasper added a comment. Landed as r290842. https://reviews.llvm.org/D28208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28315: Update tools to use new getStyle API
ioeric added a comment. I ran `ninja check-all` with https://reviews.llvm.org/D28081 and https://reviews.llvm.org/D28315 (in Linux), and some lit tests failed, namely: Clang :: Format/style-on-command-line.cpp Clang Tools :: clang-apply-replacements/basic.cpp Clang Tools :: clang-apply-replacements/conflict.cpp Clang Tools :: clang-apply-replacements/crlf.cpp Clang Tools :: clang-apply-replacements/format.cpp Clang Tools :: clang-rename/ClassReplacements.cpp Error message I am seeing: `Expected must be checked before access or destruction.` Could you double check? Thanks! Comment at: change-namespace/ChangeNamespace.cpp:892 + llvm::errs() << llvm::toString(Style.takeError()) << "\n"; + continue; +} I'd still like to apply replacements that are not cleaned up. Could you add the following line before continue, thanks! :) ``` FileToReplacements[FilePath] = Replaces; ``` https://reviews.llvm.org/D28315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications
alexfh requested changes to this revision. alexfh added inline comments. This revision now requires changes to proceed. Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:100 + StringRef ReplacementStr = + IsNoThrow ? NoexceptMacro.empty() ? "noexcept" : NoexceptMacro +: DtorOrOperatorDel ? "noexcept(false)" : ""; Did you consider auto-detection approach like in `getFallthroughAttrSpelling` in tools/clang/lib/Sema/AnalysisBasedWarnings.cpp? Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:105 + if (IsNoThrow || NoexceptMacro.empty()) +FixIt = FixItHint::CreateReplacement(CharSourceRange(Range, true), + ReplacementStr); I suspect this won't work when the range is not contiguous, e.g. starts in a macro definition and ends outside of it: #define T throw void f() T(a, b) {} Can you try this test (or construct something similar that will actually break this code)? In case it doesn't work, `Lexer::makeFileCharRange` is the standard way to get a contiguous file range corresponding to a source range (if possible). Comment at: docs/clang-tidy/checks/modernize-use-noexcept.rst:6-8 +The check converts dynamic exception specifications, e.g., +``throw()``, ``throw([,...])``, or ``throw(...)``, to +``noexcept``, ``noexcept(false)``, blank, or a user defined macro. This description doesn't say why `noexcept` is better. https://reviews.llvm.org/D20693 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291430 - [analyzer] Add checker for iterators dereferenced beyond their range.
Author: xazax Date: Mon Jan 9 03:52:32 2017 New Revision: 291430 URL: http://llvm.org/viewvc/llvm-project?rev=291430&view=rev Log: [analyzer] Add checker for iterators dereferenced beyond their range. Patch by: Adam Balogh! Differential Revision: https://reviews.llvm.org/D25660 Added: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp cfe/trunk/test/Analysis/iterator-past-end.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp cfe/trunk/test/Analysis/inlining/stl.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=291430&r1=291429&r2=291430&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Jan 9 03:52:32 2017 @@ -278,6 +278,14 @@ def VirtualCallChecker : Checker<"Virtua } // end: "optin.cplusplus" +let ParentPackage = CplusplusAlpha in { + +def IteratorPastEndChecker : Checker<"IteratorPastEnd">, + HelpText<"Check iterators used past end">, + DescFile<"IteratorPastEndChecker.cpp">; + +} // end: "alpha.cplusplus" + //===--===// // Valist checkers. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=291430&r1=291429&r2=291430&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Jan 9 03:52:32 2017 @@ -39,6 +39,7 @@ add_clang_library(clangStaticAnalyzerChe GenericTaintChecker.cpp GTestChecker.cpp IdenticalExprChecker.cpp + IteratorPastEndChecker.cpp IvarInvalidationChecker.cpp LLVMConventionsChecker.cpp LocalizationChecker.cpp Added: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp?rev=291430&view=auto == --- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp (added) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp Mon Jan 9 03:52:32 2017 @@ -0,0 +1,842 @@ +//===-- IteratorPastEndChecker.cpp *- C++ -*--// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// Defines a checker for using iterators outside their range (past end). Usage +// means here dereferencing, incrementing etc. +// +//===--===// + +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" + +#include + +using namespace clang; +using namespace ento; + +namespace { +struct IteratorPosition { +private: + enum Kind { InRange, OutofRange } K; + IteratorPosition(Kind InK) : K(InK) {} + +public: + bool isInRange() const { return K == InRange; } + bool isOutofRange() const { return K == OutofRange; } + + static IteratorPosition getInRange() { return IteratorPosition(InRange); } + static IteratorPosition getOutofRange() { +return IteratorPosition(OutofRange); + } + + bool operator==(const IteratorPosition &X) const { return K == X.K; } + bool operator!=(const IteratorPosition &X) const { return K != X.K; } + void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddInteger(K); } +}; + +typedef llvm::PointerUnion RegionOrSymbol; + +struct IteratorComparison { +private: + RegionOrSymbol Left, Right; + bool Equality; + +public: + IteratorComparison(RegionOrSymbol L, RegionOrSymbol R, bool Eq) + : Left(L), Right(R), Equality(Eq) {} + + RegionOrSymbol getLeft() const { return Left; } + RegionOrSymbol getRight() const { return Right; } + bool isEquality() const { return Equality; } + bool operator==(const IteratorComparison &X) const { +return Left == X.Left && Right == X.Right && Equality == X.Equality; + } + bool operator!=(const IteratorComparison &X) const { +return Left != X.Left || Right != X.
[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.
This revision was automatically updated to reflect the committed changes. Closed by commit rL291430: [analyzer] Add checker for iterators dereferenced beyond their range. (authored by xazax). Changed prior to commit: https://reviews.llvm.org/D25660?vs=81224&id=83596#toc Repository: rL LLVM https://reviews.llvm.org/D25660 Files: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp cfe/trunk/test/Analysis/inlining/stl.cpp cfe/trunk/test/Analysis/iterator-past-end.cpp Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td === --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -278,6 +278,14 @@ } // end: "optin.cplusplus" +let ParentPackage = CplusplusAlpha in { + +def IteratorPastEndChecker : Checker<"IteratorPastEnd">, + HelpText<"Check iterators used past end">, + DescFile<"IteratorPastEndChecker.cpp">; + +} // end: "alpha.cplusplus" + //===--===// // Valist checkers. Index: cfe/trunk/test/Analysis/inlining/stl.cpp === --- cfe/trunk/test/Analysis/inlining/stl.cpp +++ cfe/trunk/test/Analysis/inlining/stl.cpp @@ -6,8 +6,7 @@ void clang_analyzer_eval(bool); void testVector(std::vector &nums) { - if (nums.begin()) return; - if (nums.end()) return; + if (nums.begin() != nums.end()) return; clang_analyzer_eval(nums.size() == 0); #if INLINE Index: cfe/trunk/test/Analysis/iterator-past-end.cpp === --- cfe/trunk/test/Analysis/iterator-past-end.cpp +++ cfe/trunk/test/Analysis/iterator-past-end.cpp @@ -0,0 +1,205 @@ +// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify +// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify + +#include "Inputs/system-header-simulator-cxx.h" + +void simple_good(const std::vector &v) { + auto i = v.end(); + if (i != v.end()) +*i; // no-warning +} + +void simple_good_negated(const std::vector &v) { + auto i = v.end(); + if (!(i == v.end())) +*i; // no-warning +} + +void simple_bad(const std::vector &v) { + auto i = v.end(); + *i; // expected-warning{{Iterator accessed past its end}} +} + +void copy(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + *i2; // expected-warning{{Iterator accessed past its end}} +} + +void decrease(const std::vector &v) { + auto i = v.end(); + --i; + *i; // no-warning +} + +void copy_and_decrease1(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + --i1; + *i1; // no-warning +} + +void copy_and_decrease2(const std::vector &v) { + auto i1 = v.end(); + auto i2 = i1; + --i1; + *i2; // expected-warning{{Iterator accessed past its end}} +} + +void copy_and_increase1(const std::vector &v) { + auto i1 = v.begin(); + auto i2 = i1; + ++i1; + if (i1 == v.end()) +*i2; // no-warning +} + +void copy_and_increase2(const std::vector &v) { + auto i1 = v.begin(); + auto i2 = i1; + ++i1; + if (i2 == v.end()) +*i2; // expected-warning{{Iterator accessed past its end}} +} + +void good_find(std::vector &vec, int e) { + auto first = std::find(vec.begin(), vec.end(), e); + if (vec.end() != first) +*first; // no-warning +} + +void bad_find(std::vector &vec, int e) { + auto first = std::find(vec.begin(), vec.end(), e); + *first; // expected-warning{{Iterator accessed past its end}} +} + +void good_find_end(std::vector &vec, std::vector &seq) { + auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); + if (vec.end() != last) +*last; // no-warning +} + +void bad_find_end(std::vector &vec, std::vector &seq) { + auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); + *last; // expected-warning{{Iterator accessed past its end}} +} + +void good_find_first_of(std::vector &vec, std::vector &seq) { + auto first = + std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end()); + if (vec.end() != first) +*first; // no-warning +} + +void bad_find_first_of(std::vector &vec, std::vector &seq) { + auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); + *first; // expected-warning{{Iterator accessed past its end}} +} + +bool odd(int i) { return i % 2; } + +void good_find_if(std::vect
[PATCH] D28260: Add an argumentsAre matcher
klimek added a reviewer: bkramer. klimek added a comment. +benjamin https://reviews.llvm.org/D28260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28330: [analyzer] Fix false positives in Keychain API checker
NoQ accepted this revision. NoQ added a reviewer: NoQ. NoQ added a comment. In https://reviews.llvm.org/D28330#637075, @zaks.anna wrote: > I did not think of solution #1! It's definitely better than the pattern > matching I've added here. However, this checker fires so infrequently, that I > do not think it's worth investing more time into perfecting it. Well, the thing i like about your solution is that it resists arbitrary state splits. Eg., if the reason for the state split is some body farm function or a checker state split, which doesn't constitute a programmer's intent to check for error, then there's no reason to clean state. However, we won't be able to find this out by looking at range constraints retrospectively - we'd only know it during `evalAssume`/`checkBranchCondition`. However, currently we're doing a great job in other places around the analyzer to avoid unnecessary state splits, so range constraints are pretty reliable. In fact, a check in an inlined function should also not be considered a valid reason for state cleanup. Or probably even for a state split. But that's another story. Anyway, i approve your approach here :) https://reviews.llvm.org/D28330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications
malcolm.parsons added inline comments. Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:100 + StringRef ReplacementStr = + IsNoThrow ? NoexceptMacro.empty() ? "noexcept" : NoexceptMacro +: DtorOrOperatorDel ? "noexcept(false)" : ""; alexfh wrote: > Did you consider auto-detection approach like in `getFallthroughAttrSpelling` > in tools/clang/lib/Sema/AnalysisBasedWarnings.cpp? cpp11-migrate used to do this for -add-override - rL183001. clang-tidy's modernize-use-override check doesn't even have an option. https://reviews.llvm.org/D20693 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r291433 - [libcxx] Fix externally-threaded shared library builds after r291275.
Author: asiri Date: Mon Jan 9 04:38:56 2017 New Revision: 291433 URL: http://llvm.org/viewvc/llvm-project?rev=291433&view=rev Log: [libcxx] Fix externally-threaded shared library builds after r291275. Need to allow unresolved symbols in the dylib. This was previously done for LIBCXX_HAS_EXTERNAL_THREAD_API, but we have since split that into two with LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY being the externally-threaded variant. Also a minor CMakeLists.txt cleanup. Modified: libcxx/trunk/CMakeLists.txt Modified: libcxx/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=291433&r1=291432&r2=291433&view=diff == --- libcxx/trunk/CMakeLists.txt (original) +++ libcxx/trunk/CMakeLists.txt Mon Jan 9 04:38:56 2017 @@ -245,16 +245,17 @@ if(NOT LIBCXX_ENABLE_THREADS) endif() -if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_HAS_EXTERNAL_THREAD_API) - message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " - "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " - "the same time") -endif() - -if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API) - message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" - "and LIBCXX_HAS_PTHREAD_API cannot be both" - "set to ON at the same time.") +if (LIBCXX_HAS_EXTERNAL_THREAD_API) + if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) +message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " +"LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " +"the same time") + endif() + if (LIBCXX_HAS_PTHREAD_API) +message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" +"and LIBCXX_HAS_PTHREAD_API cannot be both" +"set to ON at the same time.") + endif() endif() # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE @@ -460,7 +461,7 @@ if (NOT LIBCXX_ENABLE_RTTI) endif() # Threading flags = -if (LIBCXX_HAS_EXTERNAL_THREAD_API AND LIBCXX_ENABLE_SHARED) +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) # Need to allow unresolved symbols if this is to work with shared library builds if (APPLE) add_link_flags("-undefined dynamic_lookup") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291434 - clang-format: Improve support for override/final as variable names.
Author: djasper Date: Mon Jan 9 05:04:07 2017 New Revision: 291434 URL: http://llvm.org/viewvc/llvm-project?rev=291434&view=rev Log: clang-format: Improve support for override/final as variable names. Before: bool a = f() &&override.f(); bool a = f() &&final.f(); void f(const MyOverride & override); void f(const MyFinal & final); After: bool a = f() && override.f(); bool a = f() && final.f(); void f(const MyOverride &override); void f(const MyFinal &final); Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=291434&r1=291433&r2=291434&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 9 05:04:07 2017 @@ -1282,9 +1282,7 @@ private: return TT_UnaryOperator; const FormatToken *NextToken = Tok.getNextNonComment(); -if (!NextToken || -NextToken->isOneOf(tok::arrow, Keywords.kw_final, tok::equal, - Keywords.kw_override) || +if (!NextToken || NextToken->isOneOf(tok::arrow, tok::equal) || (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) return TT_PointerOrReference; @@ -2088,9 +2086,9 @@ bool TokenAnnotator::spaceRequiredBetwee !Line.IsMultiVariableDeclStmt))) return true; if (Left.is(TT_PointerOrReference)) -return Right.Tok.isLiteral() || - Right.isOneOf(TT_BlockComment, Keywords.kw_final, - Keywords.kw_override) || +return Right.Tok.isLiteral() || Right.is(TT_BlockComment) || + (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) && +!Right.is(TT_StartOfName)) || (Right.is(tok::l_brace) && Right.BlockKind == BK_Block) || (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare, tok::l_paren) && Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=291434&r1=291433&r2=291434&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 9 05:04:07 2017 @@ -5780,6 +5780,10 @@ TEST_F(FormatTest, UnderstandsUsesOfStar verifyGoogleFormat("MACRO Constructor(const int& i) : a(a), b(b) {}"); verifyFormat("void f() { f(a, c * d); }"); verifyFormat("void f() { f(new a(), c * d); }"); + verifyFormat("void f(const MyOverride &override);"); + verifyFormat("void f(const MyFinal &final);"); + verifyIndependentOfContext("bool a = f() && override.f();"); + verifyIndependentOfContext("bool a = f() && final.f();"); verifyIndependentOfContext("InvalidRegions[*R] = 0;"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291436 - Extend NetBSD/AArch64 to cover Big Endian as well.
Author: joerg Date: Mon Jan 9 05:22:14 2017 New Revision: 291436 URL: http://llvm.org/viewvc/llvm-project?rev=291436&view=rev Log: Extend NetBSD/AArch64 to cover Big Endian as well. Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/netbsd.c cfe/trunk/test/Driver/netbsd.cpp Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=291436&r1=291435&r2=291436&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Jan 9 05:22:14 2017 @@ -3812,6 +3812,7 @@ ToolChain::CXXStdlibType NetBSD::GetDefa if (Major >= 7 || Major == 0) { switch (getArch()) { case llvm::Triple::aarch64: +case llvm::Triple::aarch64_be: case llvm::Triple::arm: case llvm::Triple::armeb: case llvm::Triple::thumb: Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=291436&r1=291435&r2=291436&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Mon Jan 9 05:22:14 2017 @@ -9644,6 +9644,7 @@ void netbsd::Linker::ConstructJob(Compil if (Major >= 7 || Major == 0) { switch (getToolChain().getArch()) { case llvm::Triple::aarch64: +case llvm::Triple::aarch64_be: case llvm::Triple::arm: case llvm::Triple::armeb: case llvm::Triple::thumb: Modified: cfe/trunk/test/Driver/netbsd.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/netbsd.c?rev=291436&r1=291435&r2=291436&view=diff == --- cfe/trunk/test/Driver/netbsd.c (original) +++ cfe/trunk/test/Driver/netbsd.c Mon Jan 9 05:22:14 2017 @@ -23,6 +23,12 @@ // RUN: %clang -no-canonical-prefixes -target aarch64--netbsd7.0.0 \ // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=AARCH64-7 %s +// RUN: %clang -no-canonical-prefixes -target aarch64_be--netbsd \ +// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=AARCH64_BE %s +// RUN: %clang -no-canonical-prefixes -target aarch64_be--netbsd7.0.0 \ +// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=AARCH64_BE-7 %s // RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabi \ // RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=ARM %s @@ -84,6 +90,12 @@ // RUN: %clang -no-canonical-prefixes -target aarch64--netbsd7.0.0 -static \ // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=S-AARCH64-7 %s +// RUN: %clang -no-canonical-prefixes -target aarch64_be--netbsd -static \ +// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=S-AARCH64_BE %s +// RUN: %clang -no-canonical-prefixes -target aarch64_be--netbsd7.0.0 -static \ +// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ +// RUN: | FileCheck -check-prefix=S-AARCH64_BE-7 %s // RUN: %clang -no-canonical-prefixes -target arm--netbsd-eabi -static \ // RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=S-ARM %s @@ -171,6 +183,18 @@ // AARCH64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc" // AARCH64-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o" +// AARCH64_BE: clang{{.*}}" "-cc1" "-triple" "aarch64_be--netbsd" +// AARCH64_BE: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" +// AARCH64_BE: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o" +// AARCH64_BE: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc" +// AARCH64_BE: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o" + +// AARCH64_BE-7: clang{{.*}}" "-cc1" "-triple" "aarch64_be--netbsd7.0.0" +// AARCH64_BE-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" +// AARCH64_BE-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o" +// AARCH64_BE-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc" +// AARCH64_BE-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o" + // ARM: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd-eabi" // ARM: as{{.*}}" "-mcpu=arm926ej-s" "-o" // ARM: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" @@ -311,6 +335,18 @@ // S-AARCH64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc" // S-AARCH64-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o" +// S-AARCH64_BE: clang{{.*}}" "-cc1" "-triple" "aarch64_be--netbsd" +// S-AARCH64_BE: ld{{.*}}" "--eh-frame-hdr" "-Bstatic" +// S-AARCH64_BE: "-o"
Re: r291416 - [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.
On Mon, Jan 9, 2017 at 12:13 AM, Richard Smith wrote: > On 8 January 2017 at 19:02, Faisal Vali via cfe-commits > wrote: >> >> Author: faisalv >> Date: Sun Jan 8 21:02:53 2017 >> New Revision: 291416 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=291416&view=rev >> Log: >> [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing >> lambda expressions. >> >> Add a visitor for lambda expressions to RecordExprEvaluator in >> ExprConstant.cpp that creates an empty APValue of Struct type to represent >> the closure object. Additionally, add a LambdaExpr visitor to the >> TemporaryExprEvaluator that forwards constant evaluation of >> immediately-called-lambda-expressions to the one in RecordExprEvaluator >> through VisitConstructExpr. >> >> This patch supports: >> constexpr auto ID = [] (auto a) { return a; }; >> static_assert(ID(3.14) == 3.14); >> static_assert([](auto a) { return a + 1; }(10) == 11); >> >> Lambda captures are still not supported for constexpr lambdas. >> >> >> Modified: >> cfe/trunk/lib/AST/ExprConstant.cpp >> cfe/trunk/lib/Sema/SemaExpr.cpp >> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp >> >> Modified: cfe/trunk/lib/AST/ExprConstant.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=291416&r1=291415&r2=291416&view=diff >> >> == >> --- cfe/trunk/lib/AST/ExprConstant.cpp (original) >> +++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Jan 8 21:02:53 2017 >> @@ -5868,6 +5868,7 @@ namespace { >> bool VisitCXXConstructExpr(const CXXConstructExpr *E) { >>return VisitCXXConstructExpr(E, E->getType()); >> } >> +bool VisitLambdaExpr(const LambdaExpr *E); >> bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr >> *E); >> bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T); >> bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr >> *E); >> @@ -6202,6 +6203,21 @@ bool RecordExprEvaluator::VisitCXXStdIni >>return true; >> } >> >> +bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) { >> + const CXXRecordDecl *ClosureClass = E->getLambdaClass(); >> + if (ClosureClass->isInvalidDecl()) return false; >> + >> + if (Info.checkingPotentialConstantExpression()) return true; >> + if (E->capture_size()) { >> +Info.FFDiag(E, diag::note_unimplemented_constexpr_lambda_feature_ast) >> +<< "can not evaluate lambda expressions with captures"; >> +return false; >> + } >> + // FIXME: Implement captures. >> + Result = APValue(APValue::UninitStruct(), /*NumBases*/0, >> /*NumFields*/0); >> + return true; >> +} >> + >> static bool EvaluateRecord(const Expr *E, const LValue &This, >> APValue &Result, EvalInfo &Info) { >>assert(E->isRValue() && E->getType()->isRecordType() && >> @@ -6251,6 +6267,9 @@ public: >>bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E) >> { >> return VisitConstructExpr(E); >>} >> + bool VisitLambdaExpr(const LambdaExpr *E) { >> +return VisitConstructExpr(E); >> + } >> }; >> } // end anonymous namespace >> >> >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=291416&r1=291415&r2=291416&view=diff >> >> == >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jan 8 21:02:53 2017 >> @@ -13097,8 +13097,10 @@ void Sema::PopExpressionEvaluationContex >> // evaluate [...] a lambda-expression. >> D = diag::err_lambda_in_constant_expression; >>} >> - for (const auto *L : Rec.Lambdas) >> -Diag(L->getLocStart(), D); >> + // C++1z allows lambda expressions as core constant expressions. >> + if (Rec.Context != ConstantEvaluated || !getLangOpts().CPlusPlus1z) >> +for (const auto *L : Rec.Lambdas) >> + Diag(L->getLocStart(), D); > > > We'll need an implementation of DR1607 before we're done here, since it > looks like this has removed the last restriction on lambda-expressions in > function template signatures in some contexts (array bounds, template > arguments). > Yes - I'll add those restrictions back (I suppose we'll need to check whether the nearest enclosing non-lambda context is a valid one [while still allowing them in default function arguments]) - but then we'll need to relax some of them when we implement P0315 in post-C++-17 right? For e.g. these would be ok w P0315 right? template struct X { }; X<[](auto a){ return a; }(10)> x; Thanks! ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291437 - Use the same ABI logic for AArch64 Big Endian as in other places
Author: joerg Date: Mon Jan 9 05:40:41 2017 New Revision: 291437 URL: http://llvm.org/viewvc/llvm-project?rev=291437&view=rev Log: Use the same ABI logic for AArch64 Big Endian as in other places covering polys. Modified: cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=291437&r1=291436&r2=291437&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jan 9 05:40:41 2017 @@ -1242,7 +1242,8 @@ bool Sema::CheckNeonBuiltinFunctionCall( QualType RHSTy = RHS.get()->getType(); llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); -bool IsPolyUnsigned = Arch == llvm::Triple::aarch64; +bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 || + Arch == llvm::Triple::aarch64_be; bool IsInt64Long = Context.getTargetInfo().getInt64Type() == TargetInfo::SignedLong; QualType EltTy = ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28419: clang-tools-extra: add gitattributes to disable EOL conversions on checkout of test source files
malcolm.parsons resigned from this revision. malcolm.parsons removed a reviewer: malcolm.parsons. malcolm.parsons added a comment. Which tests? How does this interact with svn's eol-style property? Resigning as not something I know about. https://reviews.llvm.org/D28419 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291439 - [cxx1z-constexpr-lambda] [NFC] Add a FIXME to reinstate certain restrictions on constexpr lambdas from appearing within function-signatures (CWG1607)
Author: faisalv Date: Mon Jan 9 05:47:51 2017 New Revision: 291439 URL: http://llvm.org/viewvc/llvm-project?rev=291439&view=rev Log: [cxx1z-constexpr-lambda] [NFC] Add a FIXME to reinstate certain restrictions on constexpr lambdas from appearing within function-signatures (CWG1607) For further background, see Richard's comments: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170109/181998.html A patch to fix this is being worked on. Thanks! Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=291439&r1=291438&r2=291439&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan 9 05:47:51 2017 @@ -13118,7 +13118,13 @@ void Sema::PopExpressionEvaluationContex // evaluate [...] a lambda-expression. D = diag::err_lambda_in_constant_expression; } + // C++1z allows lambda expressions as core constant expressions. + // FIXME: In C++1z, reinstate the restrictions on lambda expressions (CWG + // 1607) from appearing within template-arguments and array-bounds that + // are part of function-signatures. Be mindful that P0315 (Lambdas in + // unevaluated contexts) might lift some of these restrictions in a + // future version. if (Rec.Context != ConstantEvaluated || !getLangOpts().CPlusPlus1z) for (const auto *L : Rec.Lambdas) Diag(L->getLocStart(), D); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
arpith-jacob updated this revision to Diff 83609. arpith-jacob added a comment. Moved CommonActionTy to CGOpenMPRuntimeNVPTX.cpp and renamed it to NVPTXActionTy, allowing us to customize the class in the future, if necessary. https://reviews.llvm.org/D28145 Files: lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h test/OpenMP/nvptx_parallel_codegen.cpp Index: test/OpenMP/nvptx_parallel_codegen.cpp === --- /dev/null +++ test/OpenMP/nvptx_parallel_codegen.cpp @@ -0,0 +1,317 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target if(0) + { +#pragma omp parallel +{ + int a = 41; +} +a += 1; + } + + #pragma omp target + { +#pragma omp parallel +{ + int a = 42; +} +#pragma omp parallel if(0) +{ + int a = 43; +} +#pragma omp parallel if(1) +{ + int a = 44; +} +a += 1; + } + + #pragma omp target if(n>40) + { +#pragma omp parallel if(n>1000) +{ + int a = 45; +} +a += 1; +aa += 1; +b[2] += 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker() + + + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker() + // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, + // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, + // CHECK: store i8* null, i8** [[OMP_WORK_FN]], + // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], + // CHECK: br label {{%?}}[[AWAIT_WORK:.+]] + // + // CHECK: [[AWAIT_WORK]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) + // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 + // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 + // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null + // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]] + // + // CHECK: [[SEL_WORKERS]] + // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]] + // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0 + // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]] + // + // CHECK: [[EXEC_PARALLEL]] + // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*) + // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]] + // + // CHECK: [[EXEC_PFN1]] + // CHECK: call void [[PARALLEL_FN1]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT1]] + // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*) + // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]] + // + // CHECK: [[EXEC_PFN2]] + // CHECK: call void [[PARALLEL_FN2]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT2]] + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[TERM_PARALLEL]] + // CHECK: call void @__kmpc_kernel_end_parallel() + // CHECK: br label {{%?}}[[BAR_PARALLEL]] + // + // CHECK: [[BAR_PARALLEL]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: br label {{%?}}[[AWAIT_WORK]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + + // CHECK: define {{.*}}void [[T6:@__omp_offloading_.+template.+l26]](i[[SZ:32|64]] + // Create l
[PATCH] D28018: AMD family 17h (znver1) enablement
RKSimon added inline comments. Comment at: lib/Basic/Targets.cpp:3189 break; + case CK_ZNVER1: +setFeatureEnabledImpl(Features, "adx", true); GGanesh wrote: > RKSimon wrote: > > Same as what I asked on D28017 - is there an accepted order that we should > > be using here? > Some of them seems to be chronological. > Some of them are alphabetical. > > I personally don't have any preference as such. > Alphabetical order suits a long list. > I would like to know your suggestion. @craig.topper Any preferences? No strong preference and nothing that should slow the acceptance of this patch - alphabetical can be easier to maintain but it's unlikely this code changes often. Sorting by feature groups/age can be more understandable, and can help account for the fall-through behaviour used in many of the cases here - speaking of which would it be useful to fall-through from CK_ZNVER1 to CK_BTVER2 to CK_BTVER1 since they seem to have a common set of features? https://reviews.llvm.org/D28018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r291440 - [libcxxabi] Cleanup and adapt for r291275. NFC.
Author: asiri Date: Mon Jan 9 05:57:21 2017 New Revision: 291440 URL: http://llvm.org/viewvc/llvm-project?rev=291440&view=rev Log: [libcxxabi] Cleanup and adapt for r291275. NFC. + Now that libcxxabi shares the same threading API as libcxx, a whole chunk of code in src/config.h is made redundant (I missed this earlier). + r291275 split off the externalized-thread-api libcxx configuration from the external-thread-library libcxx configuration. libcxxabi should follow the same approach. Modified: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/config.h libcxxabi/trunk/test/CMakeLists.txt libcxxabi/trunk/test/lit.site.cfg.in Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=291440&r1=291439&r2=291440&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Mon Jan 9 05:57:21 2017 @@ -125,6 +125,9 @@ option(LIBCXXABI_HAS_PTHREAD_API "Ignore option(LIBCXXABI_HAS_EXTERNAL_THREAD_API "Build libc++abi with an externalized threading API. This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF) +option(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY + "Build libc++abi with an externalized threading library. + This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON" OFF) option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS}) option(LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${LLVM_INCLUDE_TESTS}) set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") @@ -367,16 +370,28 @@ if (NOT LIBCXXABI_ENABLE_THREADS) " be set to ON when LIBCXXABI_ENABLE_THREADS" " is also set to ON.") endif() + if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) +message(FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only" +" be set to ON when LIBCXXABI_ENABLE_THREADS" +" is also set to ON.") + endif() add_definitions(-D_LIBCXXABI_HAS_NO_THREADS) endif() -if (LIBCXXABI_HAS_PTHREAD_API AND LIBCXXABI_HAS_EXTERNAL_THREAD_API) - message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" - "and LIBCXXABI_HAS_PTHREAD_API cannot be both" - "set to ON at the same time.") +if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) + if (LIBCXXABI_HAS_PTHREAD_API) +message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API" +" and LIBCXXABI_HAS_PTHREAD_API cannot be both" +" set to ON at the same time.") + endif() + if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) +message(FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY" +" and LIBCXXABI_HAS_EXTERNAL_THREAD_API cannot be both" +" set to ON at the same time.") + endif() endif() -if (LIBCXXABI_HAS_EXTERNAL_THREAD_API AND LIBCXXABI_ENABLE_SHARED) +if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED) # Need to allow unresolved symbols if this is to work with shared library builds if (APPLE) add_link_flags("-undefined dynamic_lookup") @@ -388,11 +403,14 @@ endif() if (LIBCXXABI_HAS_PTHREAD_API) add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD) - add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD) endif() if (LIBCXXABI_HAS_EXTERNAL_THREAD_API) - add_definitions(-D_LIBCXXABI_HAS_THREAD_API_EXTERNAL) + add_definitions(-D_LIBCPP_HAS_THREAD_API_EXTERNAL) +endif() + +if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY) + add_definitions(-D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) endif() if (MSVC) Modified: libcxxabi/trunk/src/config.h URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=291440&r1=291439&r2=291440&view=diff == --- libcxxabi/trunk/src/config.h (original) +++ libcxxabi/trunk/src/config.h Mon Jan 9 05:57:21 2017 @@ -16,41 +16,6 @@ #include -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif - -// Configure inline visibility attributes -#if defined(_WIN32) - #if defined(_MSC_VER) && !defined(__clang__) - // Using Microsoft Visual C++ compiler - #define _LIBCXXABI_INLINE_VISIBILITY __forceinline - #else - #if __has_attribute(__internal_linkage__) - #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, __always_inline__)) - #else - #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__always_inline__)) - #endif - #endif -#else - #if __has_attribute(__internal_linkage__) - #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, __always_inline__)) - #else - #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) - #endif -#endif - -// Try and deduce a t
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
arpith-jacob marked 2 inline comments as done. arpith-jacob added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:365 +llvm::FunctionType *FnTy = +llvm::FunctionType::get(llvm::Type::getInt1Ty(CGM.getLLVMContext()), +TypeParams, /*isVarArg*/ false); ABataev wrote: > Does it really return I1 type? Or I8? Alexey, the runtime function is called by every worker thread. It returns a 'bool' that indicates if the thread has been activated in the parallel region, which is why I used an Int1Ty. Please let me know if you see problems with this. Thanks. https://reviews.llvm.org/D28145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28467: [Sema] Add warning for unused lambda captures
malcolm.parsons created this revision. malcolm.parsons added reviewers: aaron.ballman, rsmith. malcolm.parsons added a subscriber: cfe-commits. Warn when a lambda explicitly captures something that is not used in its body. The warning is part of -Wunused and can be enabled with -Wunused-lambda-capture. https://reviews.llvm.org/D28467 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/ScopeInfo.h lib/Parse/ParseExprCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLambda.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp test/SemaCXX/uninitialized.cpp test/SemaCXX/warn-unused-lambda-capture.cpp Index: test/SemaCXX/warn-unused-lambda-capture.cpp === --- /dev/null +++ test/SemaCXX/warn-unused-lambda-capture.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s + +void test() { + int i = 0; + + auto captures_nothing = [] {}; + + auto captures_nothing_by_value = [=] {}; + auto captures_nothing_by_reference = [&] {}; + + auto implicit_by_value = [=]() mutable { i++; }; + auto implicit_by_reference = [&] { i++; }; + + auto explicit_by_value_used = [i] { return i + 1; }; + auto explicit_by_value_used_void = [i] { (void)i; }; + auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_by_reference_used = [&i] { i++; }; + auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_initialized_reference_used = [&j = i] { return j + 1; }; + auto explicit_initialized_reference_unused = [&j = i]{}; // expected-warning{{lambda capture 'j' is not used}} + + auto explicit_initialized_value_used = [j = 1] { return j + 1; }; + auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}} + + auto nested = [&i] { +auto explicit_by_value_used = [i] { return i + 1; }; +auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + }; +} + +class Foo +{ + void test() { +auto explicit_this_used = [this] { return i; }; +auto explicit_this_used_void = [this] { (void)this; }; +auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}} + } + int i; +}; Index: test/SemaCXX/uninitialized.cpp === --- test/SemaCXX/uninitialized.cpp +++ test/SemaCXX/uninitialized.cpp @@ -1434,6 +1434,6 @@ if (b) { int unused; // expected-warning {{unused variable}} } else { -[fname]{}; +[fname] { (void)fname; }; // expected-warning {{lambda capture 'fname' is not used}} } } Index: test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp === --- test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp +++ test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp @@ -7,7 +7,7 @@ template T &&move(T&); void test_special_member_functions(MoveOnly mo, int i) { - auto lambda1 = [i]() { }; // expected-note 2{{lambda expression begins here}} expected-note 2{{candidate}} + auto lambda1 = [i]() { (void)i; }; // expected-note 2{{lambda expression begins here}} expected-note 2{{candidate}} // Default constructor decltype(lambda1) lambda2; // expected-error{{no matching constructor}} Index: test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp === --- test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp +++ test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp @@ -30,6 +30,8 @@ "should be const int&"); static_assert(is_same::value, "should be const int&"); +(void)irc; +(void)ir; }(); [=] { @@ -42,5 +44,6 @@ [&i] { static_assert(is_same::value, "should be int&"); +(void)i; }(); } Index: test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp === --- test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp +++ test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp @@ -7,16 +7,18 @@ }; void test_capture(X x) { - [x] { }(); // okay: non-const copy ctor + [x] { (void)x; }(); // okay: non-const copy ctor [x] { [x] { // expected-error{{call to deleted constructor of 'X'}} + (void)x; }(); }(); [x] { [&x] { [x] { // expected-error{{call to deleted constructor of 'const X'}} +(void)x;
Re: [PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
Arpith, I'm afraid that bool type is translated to i8 or even to i32 type rather than to i1. I believe you'd better to use CGF.ConvertTypeForMem(Context.getBoolType())to get the correct return type for bool rather than simply i1. You'd better to check how bool(...) function type is converted to LLVM IR. Best regards, Alexey Bataev > 9 янв. 2017 г., в 15:09, Arpith Jacob via Phabricator > написал(а): > > arpith-jacob marked 2 inline comments as done. > arpith-jacob added inline comments. > > > > Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:365 > +llvm::FunctionType *FnTy = > +llvm::FunctionType::get(llvm::Type::getInt1Ty(CGM.getLLVMContext()), > +TypeParams, /*isVarArg*/ false); > > ABataev wrote: >> Does it really return I1 type? Or I8? > Alexey, the runtime function is called by every worker thread. It returns a > 'bool' that indicates if the thread has been activated in the parallel > region, which is why I used an Int1Ty. Please let me know if you see > problems with this. Thanks. > > > https://reviews.llvm.org/D28145 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right
KP added a comment. ping https://reviews.llvm.org/D27651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds
xazax.hun added a comment. Did you experience any problems with the array out of bounds check lately? In case it was stable on large code-bases and did not give too many false positives, I think it might be worth to move that check out of alpha at the same time, so users who do not turn on alpha checks will not lose any functionality. What do you think? Repository: rL LLVM https://reviews.llvm.org/D28278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right
berenm added a comment. I'm trying to think of a scenario where *, && or & before tokens to be aligned would not indicate pointers or references, but as the alignment is only done for now on declarations and assignments, I can't find one. Maybe you could add one more test case to check Left pointer alignment, as all the tests are apparently aligned Right by default ? This looks good to me, although it will conflict with https://reviews.llvm.org/D21279, so one or the other has to be merged first and the other rebased. https://reviews.llvm.org/D27651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28467: [Sema] Add warning for unused lambda captures
arphaman added inline comments. Comment at: test/SemaCXX/uninitialized.cpp:1437 } else { -[fname]{}; +[fname] { (void)fname; }; // expected-warning {{lambda capture 'fname' is not used}} } I think that expected-warning shouldn't be used here as you have `(void)fname` in the lambda (I don't get this warning if I test this locally). https://reviews.llvm.org/D28467 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
Author: d0k Date: Mon Jan 9 09:18:28 2017 New Revision: 291446 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev Log: [include-fixer] Load symbol index asynchronously. We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan 9 09:18:28 2017 @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR do { std::vector Symbols; for (const auto &DB : SymbolIndices) { - auto Res = DB->search(Names.back().str()); + auto Res = DB.get()->search(Names.back()); Symbols.insert(Symbols.end(), Res.begin(), Res.end()); } Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Mon Jan 9 09:18:28 2017 @@ -13,6 +13,7 @@ #include "SymbolIndex.h" #include "find-all-symbols/SymbolInfo.h" #include "llvm/ADT/StringRef.h" +#include namespace clang { namespace include_fixer { @@ -21,8 +22,8 @@ namespace include_fixer { /// to an indentifier in the source code from multiple symbol databases. class SymbolIndexManager { public: - void addSymbolIndex(std::unique_ptr DB) { -SymbolIndices.push_back(std::move(DB)); + void addSymbolIndex(std::function()> F) { +SymbolIndices.push_back(std::async(std::launch::async, F)); } /// Search for header files to be included for an identifier. @@ -39,7 +40,7 @@ public: search(llvm::StringRef Identifier, bool IsNestedSearch = true) const; private: - std::vector> SymbolIndices; + std::vector>> SymbolIndices; }; } // namespace include_fixer Modified: clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp (original) +++ clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp Mon Jan 9 09:18:28 2017 @@ -61,23 +61,26 @@ public: Input = Arg.substr(strlen("-input=")); } -llvm::ErrorOr> SymbolIdx( -nullptr); -if (DB == "yaml") { - if (!Input.empty()) { -SymbolIdx = include_fixer::YamlSymbolIndex::createFromFile(Input); - } else { -// If we don't have any input file, look in the directory of the first -// file and its parents. -const FrontendOptions &FO = CI.getFrontendOpts(); -SmallString<128> AbsolutePath( -tooling::getAbsolutePath(FO.Inputs[0].getFile())); -StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); -SymbolIdx = include_fixer::YamlSymbolIndex::createFromDirectory( -Directory, "find_all_symbols_db.yaml"); +std::string InputFile = CI.getFrontendOpts().Inputs[0].getFile(); +auto CreateYamlIdx = [=]() -> std::unique_ptr { + llvm::ErrorOr> SymbolIdx( + nullptr); + if (DB == "yaml") { +if (!Input.empty()) { + SymbolIdx = include_fixer::YamlSymbolIndex::createFromFile(Input); +} else { + // If we don't have any input file, look in the directory of the first + // file and its parents. + SmallString<128> AbsolutePath(tooling::getAbsolutePath(InputFile)); + StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); + SymbolIdx = include_fixer::YamlSymbolIndex::createFromDirectory( + Directory, "find_all_symbols_db.yaml"); +} } -} -SymbolIndexMgr->addSymbolIndex(std::move(*SymbolIdx)); + return std::move(*SymbolIdx); +}; + +SymbolIndexMgr->addSymbolIndex(std::move(CreateYamlIdx)); return true; } Modified: c
[PATCH] D28467: [Sema] Add warning for unused lambda captures
malcolm.parsons updated this revision to Diff 83624. malcolm.parsons added a comment. Don't warn in a dependent context. Remove spurious expected-warning. https://reviews.llvm.org/D28467 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/ScopeInfo.h lib/Parse/ParseExprCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLambda.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp test/SemaCXX/uninitialized.cpp test/SemaCXX/warn-unused-lambda-capture.cpp Index: test/SemaCXX/warn-unused-lambda-capture.cpp === --- /dev/null +++ test/SemaCXX/warn-unused-lambda-capture.cpp @@ -0,0 +1,78 @@ +// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s + +void test() { + int i = 0; + + auto captures_nothing = [] {}; + + auto captures_nothing_by_value = [=] {}; + auto captures_nothing_by_reference = [&] {}; + + auto implicit_by_value = [=]() mutable { i++; }; + auto implicit_by_reference = [&] { i++; }; + + auto explicit_by_value_used = [i] { return i + 1; }; + auto explicit_by_value_used_void = [i] { (void)i; }; + auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_by_reference_used = [&i] { i++; }; + auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_initialized_reference_used = [&j = i] { return j + 1; }; + auto explicit_initialized_reference_unused = [&j = i]{}; // expected-warning{{lambda capture 'j' is not used}} + + auto explicit_initialized_value_used = [j = 1] { return j + 1; }; + auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}} + + auto nested = [&i] { +auto explicit_by_value_used = [i] { return i + 1; }; +auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + }; +} + +class Foo +{ + void test() { +auto explicit_this_used = [this] { return i; }; +auto explicit_this_used_void = [this] { (void)this; }; +auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 'this' is not used}} + } + int i; +}; + +template +void test_templated() { + int i = 0; + + auto captures_nothing = [] {}; + + auto captures_nothing_by_value = [=] {}; + auto captures_nothing_by_reference = [&] {}; + + auto implicit_by_value = [=]() mutable { i++; }; + auto implicit_by_reference = [&] { i++; }; + + auto explicit_by_value_used = [i] { return i + 1; }; + auto explicit_by_value_used_void = [i] { (void)i; }; + auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_by_reference_used = [&i] { i++; }; + auto explicit_by_reference_unused = [&i] {}; // expected-warning{{lambda capture 'i' is not used}} + + auto explicit_initialized_reference_used = [&j = i] { return j + 1; }; + auto explicit_initialized_reference_unused = [&j = i]{}; // expected-warning{{lambda capture 'j' is not used}} + + auto explicit_initialized_value_used = [j = 1] { return j + 1; }; + auto explicit_initialized_value_unused = [j = 1] {}; // expected-warning{{lambda capture 'j' is not used}} + + auto nested = [&i] { +auto explicit_by_value_used = [i] { return i + 1; }; +auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 'i' is not used}} + }; +} + +void test_use_template() { + test_templated(); // expected-note{{in instantiation of function template specialization 'test_templated' requested here}} +} Index: test/SemaCXX/uninitialized.cpp === --- test/SemaCXX/uninitialized.cpp +++ test/SemaCXX/uninitialized.cpp @@ -1434,6 +1434,6 @@ if (b) { int unused; // expected-warning {{unused variable}} } else { -[fname]{}; +[fname] { (void)fname; }; } } Index: test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp === --- test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp +++ test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp @@ -7,7 +7,7 @@ template T &&move(T&); void test_special_member_functions(MoveOnly mo, int i) { - auto lambda1 = [i]() { }; // expected-note 2{{lambda expression begins here}} expected-note 2{{candidate}} + auto lambda1 = [i]() { (void)i; }; // expected-note 2{{lambda expre
[PATCH] D26546: [PPC] Add vec_insert4b/vec_extract4b to altivec.h
nemanjai added inline comments. Comment at: test/CodeGen/builtins-ppc-extractword-error.c:2 +// REQUIRES: powerpc-registered-target +// XFAIL: powerpc + I think this will fail on all the powerpc targets, such as powerpc64le, etc. Which isn't what you want I imagine. Also, I think this isn't really the idea with XFAIL. The semantics we'd probably want are better served by using the `not` tool and checking for the error messages. You should be able to find some example of how the `not` tool is used in some of the other test cases (for example `test/CodeGen/builtins-ppc-p7-disabled.c`). Repository: rL LLVM https://reviews.llvm.org/D26546 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28419: clang-tools-extra: add gitattributes to disable EOL conversions on checkout of test source files
amaiorano added a comment. Hello, sorry for the lack of details here. I will re-run the tests later and report here the tests that are failing along with output. The main issue is that when using Git on Windows, by default the installer will set core.autocrlf to true, which is a Git config variable that tells Git to automatically convert line endings to CRLF for text files on checkout, and back to LF on staging. Some of the tests expect LF line endings - for instance, when specifying absolute offsets for replacements, these offsets are incorrect when there are extra "CR" bytes in the file, which end up making the tests fail since the output doesn't match the expected output. Note that on Linux, I believe core.autocrlf isn't usually set, so it defaults to false (could someone verify this for me?). Since files in Git are usually 'LF', this works fine for Linux users. On Windows, you usually want the CRLF line endings on source files because not all Windows text editors are good at being consistent with line endings. The solution I propose here is to add a single .gitattributes file that specifies that all .h and .cpp files under clang/tools/extra/test should be checked out with whatever line endings they were checked in with. In other words, don't convert line endings at all for these files. This means existing test source files that have LF will continue to have LF when checked out in Git, or if they have CRLF (which is the case for crlf.cpp), it will be checked out with CRLF line endings. Another consequence of this change is that if a Windows developer decides to add a new test, they'd create a test source file with CRLF line endings, and this file would be committed with these CRLF line endings. This would work fine on Linux since the file would be checked out as-is as well (with CRLF line endings), and the test would run fine. However, without this change, the Windows developer would write a test that works fine on Windows, then when staging the file, the CRLF would be converted to LF and the test would fail on Linux. Alternative solutions: 1. Instead of applying the no eol conversion to ALL .h/.cpp under test, we could add explicit entries to the .h/.cpp files that specifically require them for their tests (those that specify offsets for replacements, for e.g.) 2. Instead of a single .gitattributes file at the root of the extra/ directory, we can add one to each test directory that requires it, specifying the exact files in that test directory that needs to not apply eol conversions. Again, I will post the specific failures as soon as I get the chance. https://reviews.llvm.org/D28419 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
arpith-jacob updated this revision to Diff 83631. arpith-jacob marked an inline comment as done. arpith-jacob added a comment. Using CGF.ConvertTypeForMem(Context.getBoolType()) to get the right type for 'bool' rather than using i1. https://reviews.llvm.org/D28145 Files: lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h test/OpenMP/nvptx_parallel_codegen.cpp Index: test/OpenMP/nvptx_parallel_codegen.cpp === --- /dev/null +++ test/OpenMP/nvptx_parallel_codegen.cpp @@ -0,0 +1,315 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target if(0) + { +#pragma omp parallel +{ + int a = 41; +} +a += 1; + } + + #pragma omp target + { +#pragma omp parallel +{ + int a = 42; +} +#pragma omp parallel if(0) +{ + int a = 43; +} +#pragma omp parallel if(1) +{ + int a = 44; +} +a += 1; + } + + #pragma omp target if(n>40) + { +#pragma omp parallel if(n>1000) +{ + int a = 45; +} +a += 1; +aa += 1; +b[2] += 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker() + + + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker() + // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, + // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, + // CHECK: store i8* null, i8** [[OMP_WORK_FN]], + // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], + // CHECK: br label {{%?}}[[AWAIT_WORK:.+]] + // + // CHECK: [[AWAIT_WORK]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: [[KPR:%.+]] = call i8 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) + // store i8 [[KPR]], i8* [[OMP_EXEC_STATUS]], align 1 + // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null + // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]] + // + // CHECK: [[SEL_WORKERS]] + // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]] + // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0 + // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]] + // + // CHECK: [[EXEC_PARALLEL]] + // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*) + // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]] + // + // CHECK: [[EXEC_PFN1]] + // CHECK: call void [[PARALLEL_FN1]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT1]] + // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*) + // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]] + // + // CHECK: [[EXEC_PFN2]] + // CHECK: call void [[PARALLEL_FN2]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT2]] + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[TERM_PARALLEL]] + // CHECK: call void @__kmpc_kernel_end_parallel() + // CHECK: br label {{%?}}[[BAR_PARALLEL]] + // + // CHECK: [[BAR_PARALLEL]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: br label {{%?}}[[AWAIT_WORK]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + + // CHECK: define {{.*}}void [[T6:@__omp_offloading_.+template.+l26]](i[[SZ:32|64]] + // Create local storage for each capture. + // CHECK:
[PATCH] D28018: AMD family 17h (znver1) enablement
GGanesh updated this revision to Diff 83626. GGanesh added a comment. Fallback to CK_BTVER1 is ok but not to CK_BTVER2. This is not possible because of the partial YMM writes. They have different behavior for znver1 with AVX and their legacy SIMD counterparts. So, as of now leaving them to alphabetical order. https://reviews.llvm.org/D28018 Files: lib/Basic/Targets.cpp Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2651,6 +2651,12 @@ CK_BDVER4, //@} +/// \name zen +/// Zen architecture processors. +//@{ +CK_ZNVER1, +//@} + /// This specification is deprecated and will be removed in the future. /// Users should prefer \see CK_K8. // FIXME: Warn on this when the CPU is set to it. @@ -2732,6 +2738,7 @@ .Case("bdver2", CK_BDVER2) .Case("bdver3", CK_BDVER3) .Case("bdver4", CK_BDVER4) +.Case("znver1", CK_ZNVER1) .Case("x86-64", CK_x86_64) .Case("geode", CK_Geode) .Default(CK_Generic); @@ -2931,6 +2938,7 @@ case CK_BDVER2: case CK_BDVER3: case CK_BDVER4: +case CK_ZNVER1: case CK_x86_64: return true; } @@ -3178,6 +3186,33 @@ setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); break; + case CK_ZNVER1: +setFeatureEnabledImpl(Features, "adx", true); +setFeatureEnabledImpl(Features, "aes", true); +setFeatureEnabledImpl(Features, "avx2", true); +setFeatureEnabledImpl(Features, "bmi", true); +setFeatureEnabledImpl(Features, "bmi2", true); +setFeatureEnabledImpl(Features, "clflushopt", true); +setFeatureEnabledImpl(Features, "cx16", true); +setFeatureEnabledImpl(Features, "f16c", true); +setFeatureEnabledImpl(Features, "fma", true); +setFeatureEnabledImpl(Features, "fsgsbase", true); +setFeatureEnabledImpl(Features, "fxsr", true); +setFeatureEnabledImpl(Features, "lzcnt", true); +setFeatureEnabledImpl(Features, "mwaitx", true); +setFeatureEnabledImpl(Features, "movbe", true); +setFeatureEnabledImpl(Features, "pclmul", true); +setFeatureEnabledImpl(Features, "popcnt", true); +setFeatureEnabledImpl(Features, "prfchw", true); +setFeatureEnabledImpl(Features, "rdrnd", true); +setFeatureEnabledImpl(Features, "rdseed", true); +setFeatureEnabledImpl(Features, "sha", true); +setFeatureEnabledImpl(Features, "sse4a", true); +setFeatureEnabledImpl(Features, "xsave", true); +setFeatureEnabledImpl(Features, "xsavec", true); +setFeatureEnabledImpl(Features, "xsaveopt", true); +setFeatureEnabledImpl(Features, "xsaves", true); +break; case CK_BDVER4: setFeatureEnabledImpl(Features, "avx2", true); setFeatureEnabledImpl(Features, "bmi2", true); @@ -3729,6 +3764,9 @@ case CK_BDVER4: defineCPUMacros(Builder, "bdver4"); break; + case CK_ZNVER1: +defineCPUMacros(Builder, "znver1"); +break; case CK_Geode: defineCPUMacros(Builder, "geode"); break; Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2651,6 +2651,12 @@ CK_BDVER4, //@} +/// \name zen +/// Zen architecture processors. +//@{ +CK_ZNVER1, +//@} + /// This specification is deprecated and will be removed in the future. /// Users should prefer \see CK_K8. // FIXME: Warn on this when the CPU is set to it. @@ -2732,6 +2738,7 @@ .Case("bdver2", CK_BDVER2) .Case("bdver3", CK_BDVER3) .Case("bdver4", CK_BDVER4) +.Case("znver1", CK_ZNVER1) .Case("x86-64", CK_x86_64) .Case("geode", CK_Geode) .Default(CK_Generic); @@ -2931,6 +2938,7 @@ case CK_BDVER2: case CK_BDVER3: case CK_BDVER4: +case CK_ZNVER1: case CK_x86_64: return true; } @@ -3178,6 +3186,33 @@ setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); break; + case CK_ZNVER1: +setFeatureEnabledImpl(Features, "adx", true); +setFeatureEnabledImpl(Features, "aes", true); +setFeatureEnabledImpl(Features, "avx2", true); +setFeatureEnabledImpl(Features, "bmi", true); +setFeatureEnabledImpl(Features, "bmi2", true); +setFeatureEnabledImpl(Features, "clflushopt", true); +setFeatureEnabledImpl(Features, "cx16", true); +setFeatureEnabledImpl(Features, "f16c", true); +setFeatureEnabledImpl(Features, "fma", true); +setFeatureEnabledImpl(Features, "fsgsbase", true); +setFeatureEnabledImpl(Features, "fxsr", true); +setFeatureEnabledImpl(Features, "lzcnt", true); +setFeatureEnabledImpl(Features, "mwaitx", true); +setFeatureEnabledImpl(Features, "movbe", true); +setFeatureEnabledImpl(Features, "pclmul", true); +setFeatureEnabledImpl(Fe
Re: [PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
Alexey, Thanks for the pointer. I've updated the patch using CGF.ConvertTypeForMem(CGM.getContext().BoolTy); to get the type for 'bool'. On my machine it returns i8. The compiler produces code for a simple OpenMP program that links and seems to run fine on the GPU with my runtime. I also compiled the following C++ program to get the IR shown below: bool test() { return true; } ; Function Attrs: noinline nounwind define zeroext i1 @_Z4testv() #0 { entry: ret i1 true } For this program you can see i1 being generated. I'm not quite sure what the difference is... Regards, Arpith From: Alexey Bataev To: "reviews+d28145+public+d89a609fe244d...@reviews.llvm.org" Cc: Arpith C Jacob/Watson/IBM@IBMUS, Samuel F Antao/Watson/IBM@IBMUS, Carlo Bertolli/Watson/IBM@IBMUS, "kkw...@gmail.com" , Kevin K O'Brien/Watson/IBM@IBMUS, "gheorghe-teod.ber...@ibm.com" , "t...@google.com" , "jholewin...@nvidia.com" , "cfe-commits@lists.llvm.org" Date: 01/09/2017 08:47 AM Subject:Re: [PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device. Arpith, I'm afraid that bool type is translated to i8 or even to i32 type rather than to i1. I believe you'd better to use CGF.ConvertTypeForMem (Context.getBoolType())to get the correct return type for bool rather than simply i1. You'd better to check how bool(...) function type is converted to LLVM IR. Best regards, Alexey Bataev > 9 янв. 2017 г., в 15:09, Arpith Jacob via Phabricator написал(а): > > arpith-jacob marked 2 inline comments as done. > arpith-jacob added inline comments. > > > > Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:365 > +llvm::FunctionType *FnTy = > +llvm::FunctionType::get(llvm::Type::getInt1Ty(CGM.getLLVMContext ()), > +TypeParams, /*isVarArg*/ false); > > ABataev wrote: >> Does it really return I1 type? Or I8? > Alexey, the runtime function is called by every worker thread. It returns a 'bool' that indicates if the thread has been activated in the parallel region, which is why I used an Int1Ty. Please let me know if you see problems with this. Thanks. > > > https://reviews.llvm.org/D28145 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r291058 - [Sema] Mark undefined ctors as deleted. NFC.
Alternatively could make the bool ctor a template with some SFINAE to restrict it to only parameters of type bool - thus blocking all conversions there, if they're particularly problematic. On Wed, Jan 4, 2017 at 5:32 PM George Burgess IV via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: gbiv > Date: Wed Jan 4 19:21:21 2017 > New Revision: 291058 > > URL: http://llvm.org/viewvc/llvm-project?rev=291058&view=rev > Log: > [Sema] Mark undefined ctors as deleted. NFC. > > Looks like these functions exist just to prevent bad implicit > conversions. Rather than waiting for the linker to complain about > undefined references to them, we can mark them as deleted. > > Modified: > cfe/trunk/include/clang/Sema/Ownership.h > > Modified: cfe/trunk/include/clang/Sema/Ownership.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=291058&r1=291057&r2=291058&view=diff > > == > --- cfe/trunk/include/clang/Sema/Ownership.h (original) > +++ cfe/trunk/include/clang/Sema/Ownership.h Wed Jan 4 19:21:21 2017 > @@ -153,8 +153,8 @@ namespace clang { > ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true) > {} > > // These two overloads prevent void* -> bool conversions. > -ActionResult(const void *); > -ActionResult(volatile void *); > +ActionResult(const void *) = delete; > +ActionResult(volatile void *) = delete; > > bool isInvalid() const { return Invalid; } > bool isUsable() const { return !Invalid && Val; } > @@ -192,8 +192,8 @@ namespace clang { > ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { } > > // These two overloads prevent void* -> bool conversions. > -ActionResult(const void *); > -ActionResult(volatile void *); > +ActionResult(const void *) = delete; > +ActionResult(volatile void *) = delete; > > bool isInvalid() const { return PtrWithInvalid & 0x01; } > bool isUsable() const { return PtrWithInvalid > 0x01; } > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28315: Update tools to use new getStyle API
amaiorano added a comment. In https://reviews.llvm.org/D28315#639559, @ioeric wrote: > I ran `ninja check-all` with https://reviews.llvm.org/D28081 and > https://reviews.llvm.org/D28315 (in Linux), and some lit tests failed, namely: > > Clang :: Format/style-on-command-line.cpp > Clang Tools :: clang-apply-replacements/basic.cpp > Clang Tools :: clang-apply-replacements/conflict.cpp > Clang Tools :: clang-apply-replacements/crlf.cpp > Clang Tools :: clang-apply-replacements/format.cpp > Clang Tools :: clang-rename/ClassReplacements.cpp > > > Error message I am seeing: `Expected must be checked before access or > destruction.` > > Could you double check? Thanks! Will definitely double check. Strange that I didn't get these errors on Windows. I did notice in the output that it said one test was disabled. I'll take a closer look asap. Comment at: change-namespace/ChangeNamespace.cpp:892 + llvm::errs() << llvm::toString(Style.takeError()) << "\n"; + continue; +} ioeric wrote: > I'd still like to apply replacements that are not cleaned up. Could you add > the following line before continue, thanks! :) > ``` > FileToReplacements[FilePath] = Replaces; > ``` Will do. https://reviews.llvm.org/D28315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26667: Teach clang that 'sv' is a fine literal suffix
mclow.lists abandoned this revision. mclow.lists added a comment. This was resolved by https://reviews.llvm.org/D26829 https://reviews.llvm.org/D26667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28018: AMD family 17h (znver1) enablement
RKSimon added a comment. In https://reviews.llvm.org/D28018#639765, @GGanesh wrote: > Fallback to CK_BTVER1 is ok but not to CK_BTVER2. This is not possible > because of the partial YMM writes. They have different behavior for znver1 > with AVX and their legacy SIMD counterparts. So, as of now leaving them to > alphabetical order. That makes sense for the llvm patch, but for this clang patch in X86TargetInfo::initFeatureMap we don't need to handle those behaviour features just the instruction set features which we can fall though. https://reviews.llvm.org/D28018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291449 - [clang] Enable using --section-ordering-file option of ld.gold
Author: alexshap Date: Mon Jan 9 11:06:24 2017 New Revision: 291449 URL: http://llvm.org/viewvc/llvm-project?rev=291449&view=rev Log: [clang] Enable using --section-ordering-file option of ld.gold This diffs enables using --section-ordering-file option of ld.gold via the variable CLANG_ORDER_FILE. Differential revision: https://reviews.llvm.org/D28461 Modified: cfe/trunk/tools/driver/CMakeLists.txt Modified: cfe/trunk/tools/driver/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=291449&r1=291448&r2=291449&view=diff == --- cfe/trunk/tools/driver/CMakeLists.txt (original) +++ cfe/trunk/tools/driver/CMakeLists.txt Mon Jan 9 11:06:24 2017 @@ -72,7 +72,7 @@ endforeach() # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") -if (APPLE) +if (APPLE) if (CLANG_VENDOR) set(TOOL_INFO_NAME "${CLANG_VENDOR} clang") else() @@ -82,20 +82,19 @@ if (APPLE) set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}") set(TOOL_INFO_VERSION "${CLANG_VERSION}") set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") - + set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}") target_link_libraries(clang "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}") configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY) - + set(TOOL_INFO_UTI) set(TOOL_INFO_NAME) set(TOOL_INFO_VERSION) set(TOOL_INFO_BUILD_VERSION) endif() -# the linker -order_file flag is only supported by ld64 -if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) +if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE)) include(CMakePushCheckState) function(check_linker_flag flag out_var) @@ -105,9 +104,14 @@ if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) cmake_pop_check_state() endfunction() + if (LD64_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}") + elseif (GOLD_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}") + endif() + # This is a test to ensure the actual order file works with the linker. - check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}" -LINKER_ORDER_FILE_WORKS) + check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS) # Passing an empty order file disables some linker layout optimizations. # To work around this and enable workflows for re-linking when the order file @@ -117,7 +121,7 @@ if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) if("${ORDER_FILE}" STREQUAL "\n") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE}) elseif(LINKER_ORDER_FILE_WORKS) -target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}") +target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION}) set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE}) endif() endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28461: [clang] Enable using --section-ordering-file option of ld.gold
This revision was automatically updated to reflect the committed changes. Closed by commit rL291449: [clang] Enable using --section-ordering-file option of ld.gold (authored by alexshap). Changed prior to commit: https://reviews.llvm.org/D28461?vs=83582&id=83637#toc Repository: rL LLVM https://reviews.llvm.org/D28461 Files: cfe/trunk/tools/driver/CMakeLists.txt Index: cfe/trunk/tools/driver/CMakeLists.txt === --- cfe/trunk/tools/driver/CMakeLists.txt +++ cfe/trunk/tools/driver/CMakeLists.txt @@ -72,7 +72,7 @@ # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") -if (APPLE) +if (APPLE) if (CLANG_VENDOR) set(TOOL_INFO_NAME "${CLANG_VENDOR} clang") else() @@ -82,20 +82,19 @@ set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}") set(TOOL_INFO_VERSION "${CLANG_VERSION}") set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") - + set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}") target_link_libraries(clang "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}") configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY) - + set(TOOL_INFO_UTI) set(TOOL_INFO_NAME) set(TOOL_INFO_VERSION) set(TOOL_INFO_BUILD_VERSION) endif() -# the linker -order_file flag is only supported by ld64 -if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) +if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE)) include(CMakePushCheckState) function(check_linker_flag flag out_var) @@ -105,9 +104,14 @@ cmake_pop_check_state() endfunction() + if (LD64_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}") + elseif (GOLD_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}") + endif() + # This is a test to ensure the actual order file works with the linker. - check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}" -LINKER_ORDER_FILE_WORKS) + check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS) # Passing an empty order file disables some linker layout optimizations. # To work around this and enable workflows for re-linking when the order file @@ -117,7 +121,7 @@ if("${ORDER_FILE}" STREQUAL "\n") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE}) elseif(LINKER_ORDER_FILE_WORKS) -target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}") +target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION}) set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE}) endif() endif() Index: cfe/trunk/tools/driver/CMakeLists.txt === --- cfe/trunk/tools/driver/CMakeLists.txt +++ cfe/trunk/tools/driver/CMakeLists.txt @@ -72,7 +72,7 @@ # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") -if (APPLE) +if (APPLE) if (CLANG_VENDOR) set(TOOL_INFO_NAME "${CLANG_VENDOR} clang") else() @@ -82,20 +82,19 @@ set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}") set(TOOL_INFO_VERSION "${CLANG_VERSION}") set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}") - + set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}") target_link_libraries(clang "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}") configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY) - + set(TOOL_INFO_UTI) set(TOOL_INFO_NAME) set(TOOL_INFO_VERSION) set(TOOL_INFO_BUILD_VERSION) endif() -# the linker -order_file flag is only supported by ld64 -if(LD64_EXECUTABLE AND CLANG_ORDER_FILE) +if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE)) include(CMakePushCheckState) function(check_linker_flag flag out_var) @@ -105,9 +104,14 @@ cmake_pop_check_state() endfunction() + if (LD64_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}") + elseif (GOLD_EXECUTABLE) +set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}") + endif() + # This is a test to ensure the actual order file works with the linker. - check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}" -LINKER_ORDER_FILE_WORKS) + check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS) # Passing an empty order file disables some linker layout optimizations. # To work around this and enable workflows for re-linking when the order file @@ -117,7 +121,7 @@ if("${ORDER_FILE}" STREQUAL "\n") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE}) elseif(LINKER_ORDER_FILE_WORKS) -target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}") +target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION}) set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLA
r291450 - Follow up to r291448: use isStructorDecl in one more place
Author: rnk Date: Mon Jan 9 11:09:59 2017 New Revision: 291450 URL: http://llvm.org/viewvc/llvm-project?rev=291450&view=rev Log: Follow up to r291448: use isStructorDecl in one more place This pointer comparison has shown to be error-prone, so use the standard helper for it. NFC Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=291450&r1=291449&r2=291450&view=diff == --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original) +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jan 9 11:09:59 2017 @@ -902,7 +902,7 @@ void MicrosoftCXXNameMangler::mangleUnqu llvm_unreachable("Can't mangle Objective-C selector names here!"); case DeclarationName::CXXConstructorName: - if (Structor == getStructor(ND)) { + if (isStructorDecl(ND)) { if (StructorType == Ctor_CopyingClosure) { Out << "?_O"; return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291448 - [MS] Fix function type mangling of default ctor closures
Author: rnk Date: Mon Jan 9 11:04:37 2017 New Revision: 291448 URL: http://llvm.org/viewvc/llvm-project?rev=291448&view=rev Log: [MS] Fix function type mangling of default ctor closures Use the canonical decl in pointer comparisons with the default constructor closure decl. Otherwise we don't produce the correct "@@QAEXXZ" mangling, which essentially means "void(void) thiscall public instance method". Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/test/CodeGenCXX/dllexport.cpp Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=291448&r1=291447&r2=291448&view=diff == --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original) +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jan 9 11:04:37 2017 @@ -109,13 +109,13 @@ static const DeclContext *getEffectivePa static const FunctionDecl *getStructor(const NamedDecl *ND) { if (const auto *FTD = dyn_cast(ND)) -return FTD->getTemplatedDecl(); +return FTD->getTemplatedDecl()->getCanonicalDecl(); const auto *FD = cast(ND); if (const auto *FTD = FD->getPrimaryTemplate()) -return FTD->getTemplatedDecl(); +return FTD->getTemplatedDecl()->getCanonicalDecl(); - return FD; + return FD->getCanonicalDecl(); } /// MicrosoftMangleContextImpl - Overrides the default MangleContext for the @@ -312,6 +312,10 @@ public: void mangleNestedName(const NamedDecl *ND); private: + bool isStructorDecl(const NamedDecl *ND) const { +return ND == Structor || getStructor(ND) == Structor; + } + void mangleUnqualifiedName(const NamedDecl *ND) { mangleUnqualifiedName(ND, ND->getDeclName()); } @@ -912,7 +916,7 @@ void MicrosoftCXXNameMangler::mangleUnqu return; case DeclarationName::CXXDestructorName: - if (ND == Structor) + if (isStructorDecl(ND)) // If the named decl is the C++ destructor we're mangling, // use the type we were given. mangleCXXDtorType(static_cast(StructorType)); @@ -1862,7 +1866,7 @@ void MicrosoftCXXNameMangler::mangleFunc IsStructor = true; IsCtorClosure = (StructorType == Ctor_CopyingClosure || StructorType == Ctor_DefaultClosure) && - getStructor(MD) == Structor; + isStructorDecl(MD); if (IsCtorClosure) CC = getASTContext().getDefaultCallingConvention( /*IsVariadic=*/false, /*IsCXXMethod=*/true); @@ -1883,7 +1887,7 @@ void MicrosoftCXXNameMangler::mangleFunc // ::= // ::= @ # structors (they have no declared return type) if (IsStructor) { -if (isa(D) && D == Structor && +if (isa(D) && isStructorDecl(D) && StructorType == Dtor_Deleting) { // The scalar deleting destructor takes an extra int argument. // However, the FunctionType generated has 0 arguments. Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=291448&r1=291447&r2=291448&view=diff == --- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Mon Jan 9 11:04:37 2017 @@ -498,6 +498,12 @@ struct CtorWithClosure { // M32-DAG: ret void }; +struct CtorWithClosureOutOfLine { + __declspec(dllexport) CtorWithClosureOutOfLine(...); +}; +CtorWithClosureOutOfLine::CtorWithClosureOutOfLine(...) {} +// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosureOutOfLine@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat + #define DELETE_IMPLICIT_MEMBERS(ClassName) \ ClassName(ClassName &&) = delete; \ ClassName(ClassName &) = delete; \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right
KP updated this revision to Diff 83639. KP added a comment. Thanks Beren. No problem for me to rebase once https://reviews.llvm.org/D21279 is merged. I've added test cases for PAS_Middle and PAS_Left, I'm a bit surprised with some of the results (although it is not impacted by my changes). With PAS_Middle and PAS_Left, I get: void SomeFunction(int parameter = 0) { int const i = 1; int **j = 2, ***k = 3; int big = 1; I would have expected with PAS_Middle: int **j = 2, *** k = 3; and with PAS_Left: int**j = 2, *** k = 3; Am I right ? IIUC it is some bug/limitation in PAS_Left and Middle. https://reviews.llvm.org/D27651 Files: lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -8769,9 +8769,11 @@ verifyFormat("int oneTwoThree = {0}; // comment\n" "unsigned oneTwo = 0; // comment", Alignment); + + // PAS_RIGHT EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" " int const i = 1;\n" -" int * j = 2;\n" +" int *j = 2;\n" " int big = 1;\n" "\n" " unsigned oneTwoThree = 123;\n" @@ -8792,6 +8794,131 @@ "int ll=1;\n" "}", Alignment)); + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int **j = 2, ***k = 3;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int **j=2,***k=3;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + Alignment)); + + // PAS_LEFT + FormatStyle AlignmentLeft = Alignment; + AlignmentLeft.PointerAlignment = FormatStyle::PAS_Left; + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int* j = 2;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int *j=2;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + AlignmentLeft)); + // FIXME: one would expect " int** j = 2, *** k = 3;\n" + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int **j = 2, ***k = 3;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int **j=2,***k=3;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + AlignmentLeft)); + // PAS_MIDDLE + FormatStyle AlignmentMiddle = Alignment; + AlignmentMiddle.PointerAlignment = FormatStyle::PAS_Middle; + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int * j = 2;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" +
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
arpith-jacob updated this revision to Diff 83641. arpith-jacob added a comment. Use i1 type for bool after all. But this time use the api ConvertType(). https://reviews.llvm.org/D28145 Files: lib/CodeGen/CGOpenMPRuntime.cpp lib/CodeGen/CGOpenMPRuntime.h lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp lib/CodeGen/CGOpenMPRuntimeNVPTX.h test/OpenMP/nvptx_parallel_codegen.cpp Index: test/OpenMP/nvptx_parallel_codegen.cpp === --- /dev/null +++ test/OpenMP/nvptx_parallel_codegen.cpp @@ -0,0 +1,317 @@ +// Test target codegen - host bc file has to be created first. +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 +// expected-no-diagnostics +#ifndef HEADER +#define HEADER + +template +tx ftemplate(int n) { + tx a = 0; + short aa = 0; + tx b[10]; + + #pragma omp target if(0) + { +#pragma omp parallel +{ + int a = 41; +} +a += 1; + } + + #pragma omp target + { +#pragma omp parallel +{ + int a = 42; +} +#pragma omp parallel if(0) +{ + int a = 43; +} +#pragma omp parallel if(1) +{ + int a = 44; +} +a += 1; + } + + #pragma omp target if(n>40) + { +#pragma omp parallel if(n>1000) +{ + int a = 45; +} +a += 1; +aa += 1; +b[2] += 1; + } + + return a; +} + +int bar(int n){ + int a = 0; + + a += ftemplate(n); + + return a; +} + + // CHECK-NOT: define {{.*}}void {{@__omp_offloading_.+template.+l17}}_worker() + + + + + + + // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l26}}_worker() + // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, + // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, + // CHECK: store i8* null, i8** [[OMP_WORK_FN]], + // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], + // CHECK: br label {{%?}}[[AWAIT_WORK:.+]] + // + // CHECK: [[AWAIT_WORK]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) + // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 + // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 + // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null + // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]] + // + // CHECK: [[SEL_WORKERS]] + // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]] + // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0 + // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]] + // + // CHECK: [[EXEC_PARALLEL]] + // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*) + // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]] + // + // CHECK: [[EXEC_PFN1]] + // CHECK: call void [[PARALLEL_FN1]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT1]] + // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]], + // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*) + // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]] + // + // CHECK: [[EXEC_PFN2]] + // CHECK: call void [[PARALLEL_FN2]]( + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[CHECK_NEXT2]] + // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] + // + // CHECK: [[TERM_PARALLEL]] + // CHECK: call void @__kmpc_kernel_end_parallel() + // CHECK: br label {{%?}}[[BAR_PARALLEL]] + // + // CHECK: [[BAR_PARALLEL]] + // CHECK: call void @llvm.nvvm.barrier0() + // CHECK: br label {{%?}}[[AWAIT_WORK]] + // + // CHECK: [[EXIT]] + // CHECK: ret void + + // CHECK: define {{.*}}void [[T6:@__omp_offloading_.+template.+l26]](i[[SZ:32|64]] + // Create local storage for each capture. + // CHECK: [[LOCAL_A:%.+]] = alloca i[[
r291452 - Split dllexport default constructor closure tests out into a separate file
Author: rnk Date: Mon Jan 9 11:25:30 2017 New Revision: 291452 URL: http://llvm.org/viewvc/llvm-project?rev=291452&view=rev Log: Split dllexport default constructor closure tests out into a separate file test/CodeGenCXX/dllexport.cpp has grown quite large at this point. NFC Added: cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp Added: cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp?rev=291452&view=auto == --- cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp (added) +++ cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp Mon Jan 9 11:25:30 2017 @@ -0,0 +1,63 @@ +// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++14 \ +// RUN:-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases \ +// RUN:-disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | \ +// RUN:FileCheck %s + +struct CtorWithClosure { + __declspec(dllexport) CtorWithClosure(...) {} +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosure@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat +// CHECK: %[[this_addr:.*]] = alloca %struct.CtorWithClosure*, align 4 +// CHECK: store %struct.CtorWithClosure* %this, %struct.CtorWithClosure** %[[this_addr]], align 4 +// CHECK: %[[this:.*]] = load %struct.CtorWithClosure*, %struct.CtorWithClosure** %[[this_addr]] +// CHECK: call %struct.CtorWithClosure* (%struct.CtorWithClosure*, ...) @"\01??0CtorWithClosure@@QAA@ZZ"(%struct.CtorWithClosure* %[[this]]) +// CHECK: ret void +}; + +struct CtorWithClosureOutOfLine { + __declspec(dllexport) CtorWithClosureOutOfLine(...); +}; +CtorWithClosureOutOfLine::CtorWithClosureOutOfLine(...) {} +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosureOutOfLine@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat + +#define DELETE_IMPLICIT_MEMBERS(ClassName) \ +ClassName(ClassName &&) = delete; \ +ClassName(ClassName &) = delete; \ +~ClassName() = delete; \ +ClassName &operator=(ClassName &) = delete + +struct __declspec(dllexport) ClassWithClosure { + DELETE_IMPLICIT_MEMBERS(ClassWithClosure); + ClassWithClosure(...) {} +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FClassWithClosure@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat +// CHECK: %[[this_addr:.*]] = alloca %struct.ClassWithClosure*, align 4 +// CHECK: store %struct.ClassWithClosure* %this, %struct.ClassWithClosure** %[[this_addr]], align 4 +// CHECK: %[[this:.*]] = load %struct.ClassWithClosure*, %struct.ClassWithClosure** %[[this_addr]] +// CHECK: call %struct.ClassWithClosure* (%struct.ClassWithClosure*, ...) @"\01??0ClassWithClosure@@QAA@ZZ"(%struct.ClassWithClosure* %[[this]]) +// CHECK: ret void +}; + +template struct TemplateWithClosure { + TemplateWithClosure(int x = sizeof(T)) {} +}; +extern template struct TemplateWithClosure; +template struct __declspec(dllexport) TemplateWithClosure; +extern template struct TemplateWithClosure; +template struct __declspec(dllexport) TemplateWithClosure; + +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@D@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat +// CHECK: call {{.*}} @"\01??0?$TemplateWithClosure@D@@QAE@H@Z"({{.*}}, i32 1) + +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_F?$TemplateWithClosure@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat +// CHECK: call {{.*}} @"\01??0?$TemplateWithClosure@H@@QAE@H@Z"({{.*}}, i32 4) + +struct __declspec(dllexport) NestedOuter { + DELETE_IMPLICIT_MEMBERS(NestedOuter); + NestedOuter(void *p = 0) {} + struct __declspec(dllexport) NestedInner { +DELETE_IMPLICIT_MEMBERS(NestedInner); +NestedInner(void *p = 0) {} + }; +}; + +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedInner@NestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=291452&r1=291451&r2=291452&view=diff == --- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Mon Jan 9 11:25:30 2017 @@ -488,63 +488,6 @@ struct S { }; }; -struct CtorWithClosure { - __declspec(dllexport) CtorWithClosure(...) {} -// M32-DAG: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorWithClosure@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat -// M32-DAG: %[[this_addr:.*]] = alloca %struct.CtorWithClosure*, align 4 -// M32-DAG: store %struct.CtorWithClosure* %this, %struct.CtorWithClosure** %[[this_addr]], align 4 -// M32-DAG: %[[this:.*]] =
[PATCH] D28415: PCH: fix a regression that reports a module is defined in both pch and pcm
benlangmuir added a comment. LGTM https://reviews.llvm.org/D28415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291453 - [MS] Mark default args of exported default constructors as used
Author: rnk Date: Mon Jan 9 11:27:17 2017 New Revision: 291453 URL: http://llvm.org/viewvc/llvm-project?rev=291453&view=rev Log: [MS] Mark default args of exported default constructors as used Fixes a regression introduced in r291045, which would lead to link errors. While we should no longer encounter unparsed or uninstantiated default arguments in this codepath, we still need to call CheckCXXDefaultArgExpr to mark the default argument expressions as ODR-used. Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=291453&r1=291452&r2=291453&view=diff == --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jan 9 11:27:17 2017 @@ -5395,14 +5395,32 @@ static void ReferenceDllExportedMethods( } } -static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class) { +static void checkForMultipleExportedDefaultConstructors(Sema &S, +CXXRecordDecl *Class) { + // Only the MS ABI has default constructor closures, so we don't need to do + // this semantic checking anywhere else. + if (!S.Context.getTargetInfo().getCXXABI().isMicrosoft()) +return; + CXXConstructorDecl *LastExportedDefaultCtor = nullptr; for (Decl *Member : Class->decls()) { // Look for exported default constructors. auto *CD = dyn_cast(Member); -if (!CD || !CD->isDefaultConstructor() || !CD->hasAttr()) +if (!CD || !CD->isDefaultConstructor()) + continue; +auto *Attr = CD->getAttr(); +if (!Attr) continue; +// If the class is non-dependent, mark the default arguments as ODR-used so +// that we can properly codegen the constructor closure. +if (!Class->isDependentContext()) { + for (ParmVarDecl *PD : CD->parameters()) { +(void)S.CheckCXXDefaultArgExpr(Attr->getLocation(), CD, PD); +S.DiscardCleanupsInEvaluationContext(); + } +} + if (LastExportedDefaultCtor) { S.Diag(LastExportedDefaultCtor->getLocation(), diag::err_attribute_dll_ambiguous_default_ctor) Modified: cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp?rev=291453&r1=291452&r2=291453&view=diff == --- cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp (original) +++ cfe/trunk/test/CodeGenCXX/dllexport-ctor-closure.cpp Mon Jan 9 11:27:17 2017 @@ -61,3 +61,22 @@ struct __declspec(dllexport) NestedOuter // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat // CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FNestedInner@NestedOuter@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat + +struct HasDtor { + ~HasDtor(); + int o; +}; +struct HasImplicitDtor1 { HasDtor o; }; +struct HasImplicitDtor2 { HasDtor o; }; +struct __declspec(dllexport) CtorClosureInline { + CtorClosureInline(const HasImplicitDtor1 &v = {}) {} +}; +struct __declspec(dllexport) CtorClosureOutOfLine { + CtorClosureOutOfLine(const HasImplicitDtor2 &v = {}); +}; +CtorClosureOutOfLine::CtorClosureOutOfLine(const HasImplicitDtor2 &v) {} + +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorClosureInline@@QAEXXZ" +// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??1HasImplicitDtor1@@QAE@XZ" +// CHECK-LABEL: define weak_odr dllexport x86_thiscallcc void @"\01??_FCtorClosureOutOfLine@@QAEXXZ" +// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01??1HasImplicitDtor2@@QAE@XZ" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right
berenm added a comment. Yes you are right, I believe it's happening for comma-separated declaration list. I think the algorithm tries to keep it clear that the pointer / reference marks are for each declared identifier and not part of the common type. I think that splitting the declarations for the Left and Middle test cases would be better so it actually verifies that the pointer marks are aligned as expected. Also, maybe add a bunch of references and rvalue refs to the test cases so that the tests are exhaustive. Thanks! https://reviews.llvm.org/D27651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. Over the weekend I had a thought: Why is -O0 so special here? That is, after going to all this trouble to propagate -O0 to LTO, how does this generalize to propagating -O1 or any other specific -O option? (Maybe this question would be better dealt with on the dev list...) https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21113: Add support for case-insensitive header lookup
hans added a comment. In https://reviews.llvm.org/D21113#627413, @francisco.lopes wrote: > I'm waiting for this to land as well, it's crucial for coding windows code > with libclang assistance on a linux machine. I'm not actively working on this, so it might take a while. In the meantime, I recommend mounting a case-insensitive file system on your linux machine. https://reviews.llvm.org/D21113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r291457 - Implement P0403R1 - 'Literal suffixes for basic_string_view'. Requires clang 4.0 (specifically, r290744)
Author: marshall Date: Mon Jan 9 12:07:34 2017 New Revision: 291457 URL: http://llvm.org/viewvc/llvm-project?rev=291457&view=rev Log: Implement P0403R1 - 'Literal suffixes for basic_string_view'. Requires clang 4.0 (specifically, r290744) Added: libcxx/trunk/test/std/strings/string.view/string_view.literals/ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal3.pass.cpp Modified: libcxx/trunk/include/string_view libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/string_view URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string_view?rev=291457&r1=291456&r2=291457&view=diff == --- libcxx/trunk/include/string_view (original) +++ libcxx/trunk/include/string_view Mon Jan 9 12:07:34 2017 @@ -156,6 +156,11 @@ namespace std { template <> struct hash; template <> struct hash; + constexpr basic_string operator "" s( const char *str, size_t len ); // C++17 + constexpr basic_string operator "" s( const wchar_t *str, size_t len ); // C++17 + constexpr basic_string operator "" s( const char16_t *str, size_t len ); // C++17 + constexpr basic_string operator "" s( const char32_t *str, size_t len ); // C++17 + } // namespace std @@ -749,6 +754,38 @@ hash return __do_string_hash(__val.data(), __val.data() + __val.size()); } + +#if _LIBCPP_STD_VER > 11 +inline namespace literals +{ + inline namespace string_view_literals + { +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +basic_string_view operator "" sv(const char *__str, size_t __len) +{ +return basic_string_view (__str, __len); +} + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +basic_string_view operator "" sv(const wchar_t *__str, size_t __len) +{ +return basic_string_view (__str, __len); +} + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +basic_string_view operator "" sv(const char16_t *__str, size_t __len) +{ +return basic_string_view (__str, __len); +} + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +basic_string_view operator "" sv(const char32_t *__str, size_t __len) +{ +return basic_string_view (__str, __len); +} + } +} +#endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STRING_VIEW Added: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp?rev=291457&view=auto == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp (added) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp Mon Jan 9 12:07:34 2017 @@ -0,0 +1,56 @@ +// -*- 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. +// +//===--===// + +// UNSUPPORTED: c++98, c++03, c++11 +// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// Note: libc++ supports string_view before C++17, but literals were introduced in C++14 + +#include +#include + +int main() +{ +using namespace std::literals::string_view_literals; + +static_assert ( std::is_same::value, "" ); +static_assert ( std::is_same::value, "" ); +static_assert ( std::is_same::value, "" ); +static_assert ( std::is_same::value, "" ); +static_assert ( std::is_same::value, "" ); + +std::string_view foo; +std::wstring_view Lfoo; +std::u16string_view ufoo; +std::u32string_view Ufoo; + +foo = ""sv; assert( foo.size() == 0); +foo = u8""sv; assert( foo.size() == 0); +Lfoo = L""sv; assert(Lfoo.size() == 0); +ufoo = u""sv; assert(ufoo.size() == 0); +Ufoo = U""sv; assert(Ufoo.size() == 0); + +foo = " "sv; assert( foo.size() == 1); +foo = u8" "sv; assert( foo.size() == 1); +Lfoo = L" "sv; assert(Lfoo.size() == 1); +ufoo = u" "sv; assert(ufoo.size() == 1); +Ufoo = U" "sv; assert(Ufoo.size() == 1); + +foo = "ABC"sv; assert( foo == "ABC"); assert( foo == std::string_
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
mehdi_amini added a comment. In https://reviews.llvm.org/D28404#639874, @probinson wrote: > Over the weekend I had a thought: Why is -O0 so special here? That is, > after going to all this trouble to propagate -O0 to LTO, how does this > generalize to propagating -O1 or any other specific -O option? (Maybe this > question would be better dealt with on the dev list...) O0 is "special" like Os and Oz because we have an attribute for it and passes "know" how to handle this attribute. I guess no-one cares enough about https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//O3 to find a solution for these (in the context of LTO, I don't really care about https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2/). It is likely that Og would need a special treatment at some point, maybe with a new attribute as well, to inhibit optimization that can't preserve debug info properly. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28427: Allow constexpr construction of subobjects unconditionally, not just in C++14.
dlj updated this revision to Diff 83647. dlj added a comment. - Add a test, and fix codegen test (the array init is now constant, even though there is a dtor). https://reviews.llvm.org/D28427 Files: lib/AST/ExprConstant.cpp test/CXX/basic/basic.start/basic.start.init/p2.cpp test/CodeGenCXX/global-array-destruction.cpp Index: test/CodeGenCXX/global-array-destruction.cpp === --- test/CodeGenCXX/global-array-destruction.cpp +++ test/CodeGenCXX/global-array-destruction.cpp @@ -39,15 +39,17 @@ T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: getelementptr inbounds {{.*}} +// CHECK: bitcast {{.*}} to %struct.T* // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @t // CHECK: br i1 {{.*}} static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to %struct.T*), i64 6 +// CHECK: getelementptr inbounds {{.*}} +// CHECK: bitcast {{.*}} to %struct.T* // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @_ZL2t // CHECK: br i1 {{.*}} Index: test/CXX/basic/basic.start/basic.start.init/p2.cpp === --- /dev/null +++ test/CXX/basic/basic.start/basic.start.init/p2.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14 +// expected-no-diagnostics + +struct foo_t { + union { +int i; +volatile int j; + } u; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_t x = {{0}}; + +union foo_u { + int i; + volatile int j; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_u y = {0}; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -1627,8 +1627,17 @@ // C++1y: A constant initializer for an object o [...] may also invoke // constexpr constructors for o and its subobjects even if those objects // are of non-literal class types. - if (Info.getLangOpts().CPlusPlus14 && This && - Info.EvaluatingDecl == This->getLValueBase()) + // + // C++11 missed this detail for aggregates, so classes like this: + // struct foo_t { union { int i; volatile int j; } u; }; + // are not (obviously) initializable like so: + // __attribute__((__require_constant_initialization__)) + // static const foo_t x = {{0}}; + // because "i" is a subobject with non-literal initialization (due to the + // volatile member of the union). See: + // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677 + // Therefore, we use the C++1y behavior. + if (This && Info.EvaluatingDecl == This->getLValueBase()) return true; // Prvalue constant expressions must be of literal types. Index: test/CodeGenCXX/global-array-destruction.cpp === --- test/CodeGenCXX/global-array-destruction.cpp +++ test/CodeGenCXX/global-array-destruction.cpp @@ -39,15 +39,17 @@ T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: getelementptr inbounds {{.*}} +// CHECK: bitcast {{.*}} to %struct.T* // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @t // CHECK: br i1 {{.*}} static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to %struct.T*), i64 6 +// CHECK: getelementptr inbounds {{.*}} +// CHECK: bitcast {{.*}} to %struct.T* // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @_ZL2t // CHECK: br i1 {{.*}} Index: test/CXX/basic/basic.start/basic.start.init/p2.cpp === --- /dev/null +++ test/CXX/basic/basic.start/basic.start.init/p2.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14 +// expected-no-diagnostics + +struct foo_t { + union { +int i; +volatile int j; + } u; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_t x = {{0}}; + +union foo_u { + int i; + volatile int j; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_u y = {0}; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -1627,8 +1627,17 @@ // C++1y: A constant initializer for an object o [...] may also invoke // constexpr constructor
[PATCH] D28427: Allow constexpr construction of subobjects unconditionally, not just in C++14.
dlj updated this revision to Diff 83650. dlj added a comment. - Fix lit checks. https://reviews.llvm.org/D28427 Files: lib/AST/ExprConstant.cpp test/CXX/basic/basic.start/basic.start.init/p2.cpp test/CodeGenCXX/global-array-destruction.cpp Index: test/CodeGenCXX/global-array-destruction.cpp === --- test/CodeGenCXX/global-array-destruction.cpp +++ test/CodeGenCXX/global-array-destruction.cpp @@ -39,17 +39,17 @@ T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x {{.*}}]], [2 x [3 x {{.*}}]]* @t, i32 0, i32 0, i32 0), i64 6) // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @t // CHECK: br i1 {{.*}} static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to %struct.T*), i64 6 +// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x {{.*}}]], [2 x [3 x {{.*}}]]* @_ZL2t2, i32 0, i32 0, i32 0), i64 6) // CHECK: call void @_ZN1TD1Ev -// CHECK: icmp eq {{.*}} @_ZL2t +// CHECK: icmp eq {{.*}} @_ZL2t2 // CHECK: br i1 {{.*}} using U = T[2][3]; Index: test/CXX/basic/basic.start/basic.start.init/p2.cpp === --- /dev/null +++ test/CXX/basic/basic.start/basic.start.init/p2.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14 +// expected-no-diagnostics + +struct foo_t { + union { +int i; +volatile int j; + } u; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_t x = {{0}}; + +union foo_u { + int i; + volatile int j; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_u y = {0}; Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -1627,8 +1627,17 @@ // C++1y: A constant initializer for an object o [...] may also invoke // constexpr constructors for o and its subobjects even if those objects // are of non-literal class types. - if (Info.getLangOpts().CPlusPlus14 && This && - Info.EvaluatingDecl == This->getLValueBase()) + // + // C++11 missed this detail for aggregates, so classes like this: + // struct foo_t { union { int i; volatile int j; } u; }; + // are not (obviously) initializable like so: + // __attribute__((__require_constant_initialization__)) + // static const foo_t x = {{0}}; + // because "i" is a subobject with non-literal initialization (due to the + // volatile member of the union). See: + // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677 + // Therefore, we use the C++1y behavior. + if (This && Info.EvaluatingDecl == This->getLValueBase()) return true; // Prvalue constant expressions must be of literal types. Index: test/CodeGenCXX/global-array-destruction.cpp === --- test/CodeGenCXX/global-array-destruction.cpp +++ test/CodeGenCXX/global-array-destruction.cpp @@ -39,17 +39,17 @@ T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x {{.*}}]], [2 x [3 x {{.*}}]]* @t, i32 0, i32 0, i32 0), i64 6) // CHECK: call void @_ZN1TD1Ev // CHECK: icmp eq {{.*}} @t // CHECK: br i1 {{.*}} static T t2[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; // CHECK: call {{.*}} @__cxa_atexit -// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @_ZL2t2 to %struct.T*), i64 6 +// CHECK: getelementptr inbounds ({{.*}} getelementptr inbounds ([2 x [3 x {{.*}}]], [2 x [3 x {{.*}}]]* @_ZL2t2, i32 0, i32 0, i32 0), i64 6) // CHECK: call void @_ZN1TD1Ev -// CHECK: icmp eq {{.*}} @_ZL2t +// CHECK: icmp eq {{.*}} @_ZL2t2 // CHECK: br i1 {{.*}} using U = T[2][3]; Index: test/CXX/basic/basic.start/basic.start.init/p2.cpp === --- /dev/null +++ test/CXX/basic/basic.start/basic.start.init/p2.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 +// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14 +// expected-no-diagnostics + +struct foo_t { + union { +int i; +volatile int j; + } u; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_t x = {{0}}; + +union foo_u { + int i; + volatile int j; +}; + +__attribute__((__require_constant_initialization__)) +static const foo_u y = {0}; Index:
[PATCH] D28427: Allow constexpr construction of subobjects unconditionally, not just in C++14.
dlj added a comment. Test added, and fixed another one that I missed before. https://reviews.llvm.org/D28427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28425: Lit C++11 Compatibility Patch - nonthrowing destructors
This revision was automatically updated to reflect the committed changes. Closed by commit rL291458: [Lit Test] Make tests C++11 compatible - nothrow destructors (authored by lcharles). Changed prior to commit: https://reviews.llvm.org/D28425?vs=83470&id=83651#toc Repository: rL LLVM https://reviews.llvm.org/D28425 Files: cfe/trunk/test/CodeGenCXX/arm.cpp cfe/trunk/test/CodeGenCXX/debug-info-class.cpp cfe/trunk/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp cfe/trunk/test/CodeGenCXX/exceptions.cpp cfe/trunk/test/CodeGenCXX/goto.cpp cfe/trunk/test/OpenMP/atomic_codegen.cpp cfe/trunk/test/OpenMP/threadprivate_codegen.cpp Index: cfe/trunk/test/OpenMP/atomic_codegen.cpp === --- cfe/trunk/test/OpenMP/atomic_codegen.cpp +++ cfe/trunk/test/OpenMP/atomic_codegen.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++98 %s -o - | FileCheck %s +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++11 %s -o - | FileCheck %s // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG // expected-no-diagnostics @@ -21,14 +23,15 @@ // CHECK: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]]) // CHECK: [[SCALAR_VAL:%.+]] = load atomic i32, i32* [[SCALAR_ADDR]] monotonic // CHECK: store i32 [[SCALAR_VAL]], i32* @b - // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) + // CHECK98: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) + // CHECK11: call void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) #pragma omp atomic read b = St().get(); // CHECK-DAG: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]]) // CHECK-DAG: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]]) // CHECK-DAG: [[B_VAL:%.+]] = load i32, i32* @b // CHECK: store atomic i32 [[B_VAL]], i32* [[SCALAR_ADDR]] monotonic - // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) + // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) #pragma omp atomic write St().get() = b; // CHECK: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]]) @@ -46,7 +49,7 @@ // CHECK: [[COND:%.+]] = extractvalue { i32, i1 } [[RES]], 1 // CHECK: br i1 [[COND]], label %[[OMP_DONE:.+]], label %[[OMP_UPDATE]] // CHECK: [[OMP_DONE]] - // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) + // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) #pragma omp atomic St().get() %= b; #pragma omp atomic @@ -67,7 +70,7 @@ // CHECK: br i1 [[COND]], label %[[OMP_DONE:.+]], label %[[OMP_UPDATE]] // CHECK: [[OMP_DONE]] // CHECK: store i32 [[NEW_CALC_VAL]], i32* @a, - // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) + // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]]) #pragma omp atomic capture a = St().get() %= b; } Index: cfe/trunk/test/OpenMP/threadprivate_codegen.cpp === --- cfe/trunk/test/OpenMP/threadprivate_codegen.cpp +++ cfe/trunk/test/OpenMP/threadprivate_codegen.cpp @@ -275,7 +275,7 @@ // CHECK: {{.*}}[[ARR_LOOP]]{{.*}} // CHECK-NEXT: [[ARR_ELEMENTPAST:%.*]] = phi [[S1]]* [ [[ARR_CUR]], {{.*}} ], [ [[ARR_ELEMENT:%.*]], {{.*}} ] // CHECK-NEXT: [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]], [[S1]]* [[ARR_ELEMENTPAST]], i{{.*}} -1 -// CHECK-NEXT: invoke {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]]) +// CHECK-NEXT: {{call|invoke}} {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]]) // CHECK: [[ARR_DONE:%.*]] = icmp eq [[S1]]* [[ARR_ELEMENT]], [[ARR_BEGIN]] // CHECK-NEXT: br i1 [[ARR_DONE]], label %[[ARR_EXIT:.*]], label %[[ARR_LOOP]] // CHECK: {{.*}}[[ARR_EXIT]]{{.*}} Index: cfe/trunk/test/CodeGenCXX/debug-info-class.cpp === --- cfe/trunk/test/CodeGenCXX/debug-info-class.cpp +++ cfe/trunk/test/CodeGenCXX/debug-info-class.cpp @@ -83,12 +83,17 @@ return 0; } -// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s -// RUN: %clang_cc1 -triple i686-cygwin -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s -// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unkn
[PATCH] D28145: [OpenMP] Basic support for a parallel directive in a target region on an NVPTX device.
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG with a nit Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:409 +llvm::FunctionType *FnTy = +llvm::FunctionType::get(CGM.VoidTy, {}, /*isVarArg*/ false); +RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_end_parallel"); llvm::None instead of {} https://reviews.llvm.org/D28145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28472: Move _PairT declaration out of __hash_combine to avoid warning under C++98
dim created this revision. dim added reviewers: EricWF, mclow.lists. dim added subscribers: emaste, cfe-commits. Some parts of the FreeBSD tree are still compiled with C++98, and until https://reviews.llvm.org/rL288554 this has always worked fine. After that, a complaint about the newly introduced local _PairT is produced: /usr/include/c++/v1/memory:3354:27: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args] typedef __scalar_hash<_PairT> _HashT; ^~ /usr/include/c++/v1/memory:3284:29: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args] : public unary_function<_Tp, size_t> ^~~ /usr/include/c++/v1/memory:3356:12: note: in instantiation of template class 'std::__1::__scalar_hash<_PairT, 2>' requested here return _HashT()(__p); ^ As far as I can see, there should be no problem moving the _PairT struct to just before the __hash_combine() function, which fixes this particular warning. https://reviews.llvm.org/D28472 Files: include/memory Index: include/memory === --- include/memory +++ include/memory @@ -3344,12 +3344,13 @@ } }; +struct _PairT { + size_t first; + size_t second; +}; + _LIBCPP_INLINE_VISIBILITY inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { -struct _PairT { - size_t first; - size_t second; -}; typedef __scalar_hash<_PairT> _HashT; const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); Index: include/memory === --- include/memory +++ include/memory @@ -3344,12 +3344,13 @@ } }; +struct _PairT { + size_t first; + size_t second; +}; + _LIBCPP_INLINE_VISIBILITY inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { -struct _PairT { - size_t first; - size_t second; -}; typedef __scalar_hash<_PairT> _HashT; const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28473: Implement http://wg21.link/P0426 Constexpr for std::char_traits
mclow.lists created this revision. mclow.lists added reviewers: EricWF, rsmith. mclow.lists added a subscriber: cfe-commits. Make `assign`/`length`/`find`/`compare` for `std::char_traits` constexpr. This makes using `string_view`s at compile time easier. Use the compiler intrinsics when available. Note that `__builtin_memchr` is not really appropriate, since it returns a `void *`. Sadly, this turns a bunch of code into "a twisty little maze of ifdefs, all different", but oh well. https://reviews.llvm.org/D28473 Files: include/__string test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp === --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp @@ -12,10 +12,21 @@ // template<> struct char_traits // static size_t length(const char_type* s); +// constexpr in C++17 #include #include +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ +return std::char_traits::length(L"") == 0 +&& std::char_traits::length(L"abcd") == 4; +} +#endif + int main() { assert(std::char_traits::length(L"") == 0); @@ -23,4 +34,8 @@ assert(std::char_traits::length(L"aa") == 2); assert(std::char_traits::length(L"aaa") == 3); assert(std::char_traits::length(L"") == 4); + +#if TEST_STD_VER > 14 +static_assert(test_constexpr(), "" ); +#endif } Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp === --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp +++ test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp @@ -12,10 +12,24 @@ // template<> struct char_traits // static const char_type* find(const char_type* s, size_t n, const char_type& a); +// constexpr in C++17 #include #include +#include "test_macros.h" + +#if TEST_STD_VER > 14 +constexpr bool test_constexpr() +{ +constexpr const wchar_t *p = L"123"; +return std::char_traits::find(p, 3, L'1') == p +&& std::char_traits::find(p, 3, L'2') == p + 1 +&& std::char_traits::find(p, 3, L'3') == p + 2 +&& std::char_traits::find(p, 3, L'4') == nullptr; +} +#endif + int main() { wchar_t s1[] = {1, 2, 3}; @@ -25,4 +39,8 @@ assert(std::char_traits::find(s1, 3, wchar_t(4)) == 0); assert(std::char_traits::find(s1, 3, wchar_t(0)) == 0); assert(std::char_traits::find(NULL, 0, wchar_t(0)) == 0); + +#if TEST_STD_VER > 14 +static_assert(test_constexpr(), "" ); +#endif } Index: test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp === --- test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.c
[PATCH] D28473: Implement http://wg21.link/P0426 Constexpr for std::char_traits
mclow.lists added inline comments. Comment at: include/__string:261 + +// inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +// int I will remove this block before committing. https://reviews.llvm.org/D28473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25435: Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection
danielcdh added a comment. Thanks David for the reivew. Could you also help take a look at https://reviews.llvm.org/D25434, as it depends on the TargetOptions.h change in that patch. Thanks, Dehao https://reviews.llvm.org/D25435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28415: PCH: fix a regression that reports a module is defined in both pch and pcm
This revision was automatically updated to reflect the committed changes. Closed by commit rL291465: PCH: fix a regression that reports a module is defined in both pch and pcm. (authored by mren). Changed prior to commit: https://reviews.llvm.org/D28415?vs=83431&id=83660#toc Repository: rL LLVM https://reviews.llvm.org/D28415 Files: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Frontend/FrontendActions.h cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp cfe/trunk/test/Modules/Inputs/pch-with-module-name/A.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.m cfe/trunk/test/Modules/Inputs/pch-with-module-name/D.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/module.modulemap cfe/trunk/test/Modules/Inputs/pch-with-module-name/test.h cfe/trunk/test/Modules/pch-with-module-name.m Index: cfe/trunk/lib/Frontend/FrontendActions.cpp === --- cfe/trunk/lib/Frontend/FrontendActions.cpp +++ cfe/trunk/lib/Frontend/FrontendActions.cpp @@ -127,6 +127,12 @@ return OS; } +bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI, + StringRef Filename) { + CI.getLangOpts().CompilingPCH = true; + return true; +} + std::unique_ptr GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { Index: cfe/trunk/lib/Serialization/ASTWriter.cpp === --- cfe/trunk/lib/Serialization/ASTWriter.cpp +++ cfe/trunk/lib/Serialization/ASTWriter.cpp @@ -4654,17 +4654,6 @@ // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); - else if (!getLangOpts().CurrentModule.empty()) { -// If we're building a PCH in the implementation of a module, we may need -// the description of the current module. -// -// FIXME: We may need other modules that we did not load from an AST file, -// such as if a module declares a 'conflicts' on a different module. -Module *M = PP.getHeaderSearchInfo().getModuleMap().findModule( -getLangOpts().CurrentModule); -if (M && !M->IsFromModuleFile) - WriteSubmodules(M); - } Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); Index: cfe/trunk/lib/Lex/PPDirectives.cpp === --- cfe/trunk/lib/Lex/PPDirectives.cpp +++ cfe/trunk/lib/Lex/PPDirectives.cpp @@ -1996,18 +1996,28 @@ // Ask HeaderInfo if we should enter this #include file. If not, #including // this file will have no effect. + bool SkipHeader = false; if (ShouldEnter && !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport, SuggestedModule.getModule())) { ShouldEnter = false; +SkipHeader = true; if (Callbacks) Callbacks->FileSkipped(*File, FilenameTok, FileCharacter); } // If we don't need to enter the file, stop now. if (!ShouldEnter) { // If this is a module import, make it visible if needed. if (auto *M = SuggestedModule.getModule()) { + // When building a pch, -fmodule-name tells the compiler to textually + // include headers in the specified module. But it is possible that + // ShouldEnter is false because we are skipping the header. In that + // case, We are not importing the specified module. + if (SkipHeader && getLangOpts().CompilingPCH && + M->getTopLevelModuleName() == getLangOpts().CurrentModule) +return; + makeModuleVisible(M, HashLoc); if (IncludeTok.getIdentifierInfo()->getPPKeywordID() != @@ -2032,6 +2042,13 @@ // Determine if we're switching to building a new submodule, and which one. if (auto *M = SuggestedModule.getModule()) { +// When building a pch, -fmodule-name tells the compiler to textually +// include headers in the specified module. We are not building the +// specified module. +if (getLangOpts().CompilingPCH && +M->getTopLevelModuleName() == getLangOpts().CurrentModule) + return; + assert(!CurSubmodule && "should not have marked this as a module yet"); CurSubmodule = M; Index: cfe/trunk/include/clang/Basic/LangOptions.def === --- cfe/trunk/include/clang/Basic/LangOptions.def +++ cfe/trunk/include/clang/Basic/LangOptions.def @@ -146,6 +146,7 @@ COMPATIBLE_LANGOPT(ModulesTS , 1, 0, "C++ Modules TS") BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None, "compiling a module interface") +BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch") COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module use
r291465 - PCH: fix a regression that reports a module is defined in both pch and pcm.
Author: mren Date: Mon Jan 9 13:20:18 2017 New Revision: 291465 URL: http://llvm.org/viewvc/llvm-project?rev=291465&view=rev Log: PCH: fix a regression that reports a module is defined in both pch and pcm. In r276159, we started to say that a module X is defined in a pch if we specify -fmodule-name when building the pch. This caused a regression that reports module X is defined in both pch and pcm if we generate the pch with -fmodule-name=X and then in a separate clang invocation, we include the pch and also import X.pcm. This patch adds an option CompilingPCH similar to CompilingModule. When we use -fmodule-name=X while building a pch, modular headers in X will be textually included and the compiler knows that we are not building module X, so we don't put module X in SUBMODULE_DEFINITION of the pch. Differential Revision: http://reviews.llvm.org/D28415 Added: cfe/trunk/test/Modules/Inputs/pch-with-module-name/ cfe/trunk/test/Modules/Inputs/pch-with-module-name/A.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/C.m cfe/trunk/test/Modules/Inputs/pch-with-module-name/D.h cfe/trunk/test/Modules/Inputs/pch-with-module-name/module.modulemap cfe/trunk/test/Modules/Inputs/pch-with-module-name/test.h cfe/trunk/test/Modules/pch-with-module-name.m Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Frontend/FrontendActions.h cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=291465&r1=291464&r2=291465&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jan 9 13:20:18 2017 @@ -146,6 +146,7 @@ LANGOPT(Modules , 1, 0, "modul COMPATIBLE_LANGOPT(ModulesTS , 1, 0, "C++ Modules TS") BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None, "compiling a module interface") +BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch") COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module uses") BENIGN_LANGOPT(ModulesSearchAll , 1, 1, "searching even non-imported modules to find unresolved references") COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of module uses and all headers to be in modules") Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=291465&r1=291464&r2=291465&view=diff == --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Jan 9 13:20:18 2017 @@ -88,6 +88,8 @@ public: static std::unique_ptr ComputeASTConsumerArguments(CompilerInstance &CI, StringRef InFile, std::string &Sysroot, std::string &OutputFile); + + bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; }; class GenerateModuleAction : public ASTFrontendAction { Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=291465&r1=291464&r2=291465&view=diff == --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Jan 9 13:20:18 2017 @@ -127,6 +127,12 @@ GeneratePCHAction::ComputeASTConsumerArg return OS; } +bool GeneratePCHAction::BeginSourceFileAction(CompilerInstance &CI, + StringRef Filename) { + CI.getLangOpts().CompilingPCH = true; + return true; +} + std::unique_ptr GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { Modified: cfe/trunk/lib/Lex/PPDirectives.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=291465&r1=291464&r2=291465&view=diff == --- cfe/trunk/lib/Lex/PPDirectives.cpp (original) +++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Jan 9 13:20:18 2017 @@ -1996,10 +1996,12 @@ void Preprocessor::HandleIncludeDirectiv // Ask HeaderInfo if we should enter this #include file. If not, #including // this file will have no effect. + bool SkipHeader = false; if (ShouldEnter && !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport, SuggestedModule.getModule())) { ShouldEnter = false; +SkipHeader = true; if (Callbacks
[libcxx] r291466 - [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW
Author: bruno Date: Mon Jan 9 13:21:48 2017 New Revision: 291466 URL: http://llvm.org/viewvc/llvm-project?rev=291466&view=rev Log: [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin. On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to time functions in the nanosecond range. Thus, they are the only acceptable implementations of steady_clock. Differential Revision: https://reviews.llvm.org/D27429 rdar://problem/29449467 Modified: libcxx/trunk/src/chrono.cpp Modified: libcxx/trunk/src/chrono.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=291466&r1=291465&r2=291466&view=diff == --- libcxx/trunk/src/chrono.cpp (original) +++ libcxx/trunk/src/chrono.cpp Mon Jan 9 13:21:48 2017 @@ -12,6 +12,28 @@ #include "system_error" // __throw_system_error #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME +#if (__APPLE__) +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 +#define _LIBCXX_USE_CLOCK_GETTIME +#endif +#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) +#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10 +#define _LIBCXX_USE_CLOCK_GETTIME +#endif +#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) +#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10 +#define _LIBCXX_USE_CLOCK_GETTIME +#endif +#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) +#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3 +#define _LIBCXX_USE_CLOCK_GETTIME +#endif +#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__ +#else +#define _LIBCXX_USE_CLOCK_GETTIME +#endif // __APPLE__ + #if defined(_LIBCPP_WIN32API) #define WIN32_LEAN_AND_MEAN #define VC_EXTRA_LEAN @@ -70,16 +92,16 @@ system_clock::now() _NOEXCEPT static_cast<__int64>(ft.dwLowDateTime)}; return time_point(duration_cast(d - nt_to_unix_epoch)); #else -#ifdef CLOCK_REALTIME +#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) struct timespec tp; if (0 != clock_gettime(CLOCK_REALTIME, &tp)) __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); -#else // !CLOCK_REALTIME +#else timeval tv; gettimeofday(&tv, 0); return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); -#endif // CLOCK_REALTIME +#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME #endif } @@ -106,6 +128,18 @@ const bool steady_clock::is_steady; #if defined(__APPLE__) +// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW +#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW) +steady_clock::time_point +steady_clock::now() _NOEXCEPT +{ +struct timespec tp; +if (0 != clock_gettime(CLOCK_UPTIME_RAW, &tp)) +__throw_system_error(errno, "clock_gettime(CLOCK_UPTIME_RAW) failed"); +return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); +} + +#else // mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of // nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom // are run time constants supplied by the OS. This clock has no relationship @@ -157,6 +191,7 @@ steady_clock::now() _NOEXCEPT static FP fp = init_steady_clock(); return time_point(duration(fp())); } +#endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW) #elif defined(_LIBCPP_WIN32API) @@ -175,6 +210,13 @@ steady_clock::now() _NOEXCEPT #elif defined(CLOCK_MONOTONIC) +// On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to +// time functions in the nanosecond range. Thus, they are the only acceptable +// implementations of steady_clock. +#ifdef __APPLE__ +#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms" +#endif + steady_clock::time_point steady_clock::now() _NOEXCEPT { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r291058 - [Sema] Mark undefined ctors as deleted. NFC.
That's a good point, but I don't think they're a big issue: this code has apparently been this way since 2010, and I only hit this problem because I was blindly adding `const` to things and looking for what broke. :) If someone feels differently, I'm happy to swap this to use SFINAE magic. On Mon, Jan 9, 2017 at 8:34 AM, David Blaikie wrote: > Alternatively could make the bool ctor a template with some SFINAE to > restrict it to only parameters of type bool - thus blocking all conversions > there, if they're particularly problematic. > > On Wed, Jan 4, 2017 at 5:32 PM George Burgess IV via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: gbiv >> Date: Wed Jan 4 19:21:21 2017 >> New Revision: 291058 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=291058&view=rev >> Log: >> [Sema] Mark undefined ctors as deleted. NFC. >> >> Looks like these functions exist just to prevent bad implicit >> conversions. Rather than waiting for the linker to complain about >> undefined references to them, we can mark them as deleted. >> >> Modified: >> cfe/trunk/include/clang/Sema/Ownership.h >> >> Modified: cfe/trunk/include/clang/Sema/Ownership.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Sema/Ownership.h?rev=291058&r1=291057&r2=291058&view=diff >> >> == >> --- cfe/trunk/include/clang/Sema/Ownership.h (original) >> +++ cfe/trunk/include/clang/Sema/Ownership.h Wed Jan 4 19:21:21 2017 >> @@ -153,8 +153,8 @@ namespace clang { >> ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), >> Invalid(true) {} >> >> // These two overloads prevent void* -> bool conversions. >> -ActionResult(const void *); >> -ActionResult(volatile void *); >> +ActionResult(const void *) = delete; >> +ActionResult(volatile void *) = delete; >> >> bool isInvalid() const { return Invalid; } >> bool isUsable() const { return !Invalid && Val; } >> @@ -192,8 +192,8 @@ namespace clang { >> ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { } >> >> // These two overloads prevent void* -> bool conversions. >> -ActionResult(const void *); >> -ActionResult(volatile void *); >> +ActionResult(const void *) = delete; >> +ActionResult(volatile void *) = delete; >> >> bool isInvalid() const { return PtrWithInvalid & 0x01; } >> bool isUsable() const { return PtrWithInvalid > 0x01; } >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#639887, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#639874, @probinson wrote: > > > Over the weekend I had a thought: Why is -O0 so special here? That is, > > after going to all this trouble to propagate -O0 to LTO, how does this > > generalize to propagating -O1 or any other specific -O option? (Maybe this > > question would be better dealt with on the dev list...) > > > O0 is "special" like Os and Oz because we have an attribute for it and passes > "know" how to handle this attribute. > I guess no-one cares enough about > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//O3 > to find a solution for these (in the context of LTO, I don't really care > about > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2/). > It is likely that Og would need a special treatment at some point, maybe > with a new attribute as well, to inhibit optimization that can't preserve > debug info properly. "I don't care" doesn't seem like much of a principle. Optnone does not equal -O0. It is a debugging aid for the programmer, because debugging optimized code sucks. If you have an LTO-built application and want to de-optimize parts of it to aid with debugging, then you can use the pragma, as originally intended. I don't think `-c -O0 -flto` should get this not-entirely-O0-like behavior. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25435: Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection
echristo added a comment. I don't think this ever was hashed out in the llvm-dev thread? https://reviews.llvm.org/D25435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28473: Implement http://wg21.link/P0426 Constexpr for std::char_traits
rsmith added inline comments. Comment at: include/__string:248 +#if _LIBCPP_STD_VER <= 14 +return (const char_type*) memchr(__s, to_int_type(__a), __n); +#else We can add another builtin to Clang to support this case if you'd like. (There's also a way to get `__builtin_memchr` to work here using a `__builtin_constant_p` conditional expression to enable constant folding -- http://melpon.org/wandbox/permlink/0ob1n4a3zv1Kt3Ds -- but from discussion on IRC it sounds like Marshall is not happy about that approach.) https://reviews.llvm.org/D28473 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D25435: Add -fdebug-info-for-profiling to emit more debug info for sample pgo profile collection
I started the llvm-dev thread for the instruction location tradeoffs (removing the location from instructions to improve profiling support - possibly at the cost of other debug info consumers). The motivation for this flag is different - for added functionality that's generally (imho/based on conversations so far) pretty well justified for profile needs (the need for function start lines to make profiles somewhat resilient to unrelated code changes, etc - as mentioned in the review/patch description). On Mon, Jan 9, 2017 at 11:51 AM Eric Christopher via Phabricator < revi...@reviews.llvm.org> wrote: > echristo added a comment. > > I don't think this ever was hashed out in the llvm-dev thread? > > > https://reviews.llvm.org/D25435 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
mehdi_amini added a comment. In https://reviews.llvm.org/D28404#640046, @probinson wrote: > In https://reviews.llvm.org/D28404#639887, @mehdi_amini wrote: > > > In https://reviews.llvm.org/D28404#639874, @probinson wrote: > > > > > Over the weekend I had a thought: Why is -O0 so special here? That is, > > > after going to all this trouble to propagate -O0 to LTO, how does this > > > generalize to propagating -O1 or any other specific -O option? (Maybe > > > this question would be better dealt with on the dev list...) > > > > > > O0 is "special" like Os and Oz because we have an attribute for it and > > passes "know" how to handle this attribute. > > I guess no-one cares enough about > > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//O3 > > to find a solution for these (in the context of LTO, I don't really care > > about > > https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2/). > > It is likely that Og would need a special treatment at some point, maybe > > with a new attribute as well, to inhibit optimization that can't preserve > > debug info properly. > > > "I don't care" doesn't seem like much of a principle. Long version is: "There is no use-case, no users, so I don't have much motivation to push it forward for the only sake of completeness". Does it sound enough of a principle like that? > Optnone does not equal -O0. It is a debugging aid for the programmer, > because debugging optimized code sucks. If you have an LTO-built application > and want to de-optimize parts of it to aid with debugging, then you can use > the pragma, as originally intended. Having to modifying the source isn't friendly. Not being able to honor -O0 during LTO is not user-friendly. > I don't think `-c -O0` should get this not-entirely-O0-like behavior. What is "not-entirely"? And why do you think that? https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Patch for Bug 22877
Hi,This is my first commit, please feel free to critique any of the code/new test since I'm not quite sure if this is in the correct format.The patch is for the bug https://llvm.org/bugs/show_bug.cgi?id=22877 regarding cleaning up default arguments in constructors while initializing an array.It doesn't break any old tests.Thanks,Arthur Eubanks patch.diff Description: Binary data ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r291458 - [Lit Test] Make tests C++11 compatible - nothrow destructors
Author: lcharles Date: Mon Jan 9 12:24:16 2017 New Revision: 291458 URL: http://llvm.org/viewvc/llvm-project?rev=291458&view=rev Log: [Lit Test] Make tests C++11 compatible - nothrow destructors In C++11, a destructor's implicit exception-spec is nothrow. The IR for the destructor's invocation changed from invoke to call. Differential Revision: https://reviews.llvm.org/D28425 Modified: cfe/trunk/test/CodeGenCXX/arm.cpp cfe/trunk/test/CodeGenCXX/debug-info-class.cpp cfe/trunk/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp cfe/trunk/test/CodeGenCXX/exceptions.cpp cfe/trunk/test/CodeGenCXX/goto.cpp cfe/trunk/test/OpenMP/atomic_codegen.cpp cfe/trunk/test/OpenMP/threadprivate_codegen.cpp Modified: cfe/trunk/test/CodeGenCXX/arm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/arm.cpp?rev=291458&r1=291457&r2=291458&view=diff == --- cfe/trunk/test/CodeGenCXX/arm.cpp (original) +++ cfe/trunk/test/CodeGenCXX/arm.cpp Mon Jan 9 12:24:16 2017 @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios6.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s +// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios6.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -std=gnu++98 -o - -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s +// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios6.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -std=gnu++11 -o - -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s // CHECK: @_ZZN5test74testEvE1x = internal global i32 0, align 4 // CHECK: @_ZGVZN5test74testEvE1x = internal global i32 0 @@ -156,7 +157,8 @@ namespace test3 { // CHECK: getelementptr {{.*}}, i32 4 // CHECK: bitcast {{.*}} to i32* // CHECK: load -// CHECK: invoke {{.*}} @_ZN5test31AD1Ev +// CHECK98: invoke {{.*}} @_ZN5test31AD1Ev +// CHECK11: call {{.*}} @_ZN5test31AD1Ev // CHECK: call void @_ZdaPv delete [] x; } @@ -168,7 +170,8 @@ namespace test3 { // CHECK: getelementptr {{.*}}, i32 4 // CHECK: bitcast {{.*}} to i32* // CHECK: load -// CHECK: invoke {{.*}} @_ZN5test31AD1Ev +// CHECK98: invoke {{.*}} @_ZN5test31AD1Ev +// CHECK11: call {{.*}} @_ZN5test31AD1Ev // CHECK: call void @_ZdaPv delete [] x; } Modified: cfe/trunk/test/CodeGenCXX/debug-info-class.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class.cpp?rev=291458&r1=291457&r2=291458&view=diff == --- cfe/trunk/test/CodeGenCXX/debug-info-class.cpp (original) +++ cfe/trunk/test/CodeGenCXX/debug-info-class.cpp Mon Jan 9 12:24:16 2017 @@ -83,12 +83,17 @@ int main(int argc, char **argv) { return 0; } -// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s -// RUN: %clang_cc1 -triple i686-cygwin -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s -// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -debug-info-kind=limited -fexceptions %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=limited -fexceptions -std=c++98 %s -o - | FileCheck -check-prefix=CHECK98 %s +// RUN: %clang_cc1 -triple i686-cygwin -emit-llvm -debug-info-kind=limited -fexceptions -std=c++98 %s -o - | FileCheck -check-prefix=CHECK98 %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -debug-info-kind=limited -fexceptions -std=c++98 %s -o - | FileCheck -check-prefix=CHECK98 %s +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=limited -fexceptions -std=c++11 %s -o - | FileCheck -check-prefix=CHECK11 %s +// RUN: %clang_cc1 -triple i686-cygwin -emit-llvm -debug-info-kind=limited -fexceptions -std=c++11 %s -o - | FileCheck -check-prefix=CHECK11 %s +// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -debug-info-kind=limited -fexceptions -std=c++11 %s -o - | FileCheck -check-prefix=CHECK11 %s + +// CHECK98: invoke {{.+}} @_ZN1BD1Ev(%class.B* %b) +// CHECK98-NEXT: unwind label %{{.+}}, !dbg ![[EXCEPTLOC:.*]] +// CHECK11: call {{.+}} @_ZN1BD1Ev(%class.B* %b){{.*}}, !dbg ![[EXCEPTLOC:.*]] -// CHECK: invoke {{.+}} @_ZN1BD1Ev(%class.B* %b) -// CHECK-NEXT: unwind label %{{.+}}, !dbg ![[EXCEPTLOC:.*]] // CHECK: store i32 0, i32* %{{.+}}, !dbg ![[RETLOC:.*]] // CHECK: [[F:![0-9]*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "F" Modified: cfe/trunk/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp?rev=291458&r1=291457&r2=291458&view=diff == --- cfe/trunk/test/CodeGenCXX/eh-aggregate-copy-destroy.cpp
[PATCH] D28018: AMD family 17h (znver1) enablement
GGanesh added a comment. Yes. True I mentioned that for the grouping or the order of the features enabled. These initFeatureMap are done based on the intrinsics and the CodeGen part. https://reviews.llvm.org/D28018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28018: AMD family 17h (znver1) enablement
GGanesh added a comment. If Okay, can you please commit these on my behalf. I don't have write access. https://reviews.llvm.org/D28018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28445: [Analyzer] Extend taint propagation and checking
zaks.anna added a comment. Thanks for working on this! Comment at: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:443 + if (auto LCV = Val.getAs()) +return C.getSymbolManager().getRegionValueSymbol(LCV->getRegion()); + This might create a new symbol. Is this what we want? Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:694 + if (const TypedValueRegion *TVR = dyn_cast(Reg)) { +SymbolRef Sym = getSymbolManager().getRegionValueSymbol(TVR); + This might create a new symbol as well. Is this what we want here? https://reviews.llvm.org/D28445 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r291475 - Added XFAIL for the apple versions of clang as well
Author: marshall Date: Mon Jan 9 14:29:28 2017 New Revision: 291475 URL: http://llvm.org/viewvc/llvm-project?rev=291475&view=rev Log: Added XFAIL for the apple versions of clang as well Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp libcxx/trunk/test/std/strings/string.view/string_view.literals/literal3.pass.cpp Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp?rev=291475&r1=291474&r2=291475&view=diff == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp (original) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp Mon Jan 9 14:29:28 2017 @@ -10,6 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8 // Note: libc++ supports string_view before C++17, but literals were introduced in C++14 #include Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp?rev=291475&r1=291474&r2=291475&view=diff == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp (original) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.fail.cpp Mon Jan 9 14:29:28 2017 @@ -10,6 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8 #include #include Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp?rev=291475&r1=291474&r2=291475&view=diff == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp (original) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal1.pass.cpp Mon Jan 9 14:29:28 2017 @@ -10,6 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8 // Note: libc++ supports string_view before C++17, but literals were introduced in C++14 #include Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp?rev=291475&r1=291474&r2=291475&view=diff == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp (original) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.fail.cpp Mon Jan 9 14:29:28 2017 @@ -10,6 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8 #include #include Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp?rev=291475&r1=291474&r2=291475&view=diff == --- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp (original) +++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal2.pass.cpp Mon Jan 9 14:29:28 2017 @@ -10,6 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8, clang-3.9 +// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8 // Note: libc++ supports string_view before C++17, but literals were introduced in C++14 #include Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal3.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libc
[libcxx] r291476 - Move _PairT declaration out of __hash_combine to avoid warning under C++98
Author: dim Date: Mon Jan 9 14:29:35 2017 New Revision: 291476 URL: http://llvm.org/viewvc/llvm-project?rev=291476&view=rev Log: Move _PairT declaration out of __hash_combine to avoid warning under C++98 Summary: Some parts of the FreeBSD tree are still compiled with C++98, and until rL288554 this has always worked fine. After that, a complaint about the newly introduced local _PairT is produced: /usr/include/c++/v1/memory:3354:27: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args] typedef __scalar_hash<_PairT> _HashT; ^~ /usr/include/c++/v1/memory:3284:29: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args] : public unary_function<_Tp, size_t> ^~~ /usr/include/c++/v1/memory:3356:12: note: in instantiation of template class 'std::__1::__scalar_hash<_PairT, 2>' requested here return _HashT()(__p); ^ As far as I can see, there should be no problem moving the _PairT struct to just before the __hash_combine() function, which fixes this particular warning. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits, emaste Differential Revision: https://reviews.llvm.org/D28472 Modified: libcxx/trunk/include/memory Modified: libcxx/trunk/include/memory URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=291476&r1=291475&r2=291476&view=diff == --- libcxx/trunk/include/memory (original) +++ libcxx/trunk/include/memory Mon Jan 9 14:29:35 2017 @@ -3344,12 +3344,13 @@ struct __scalar_hash<_Tp, 4> } }; +struct _PairT { + size_t first; + size_t second; +}; + _LIBCPP_INLINE_VISIBILITY inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { -struct _PairT { - size_t first; - size_t second; -}; typedef __scalar_hash<_PairT> _HashT; const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28472: Move _PairT declaration out of __hash_combine to avoid warning under C++98
This revision was automatically updated to reflect the committed changes. Closed by commit rL291476: Move _PairT declaration out of __hash_combine to avoid warning under C++98 (authored by dim). Changed prior to commit: https://reviews.llvm.org/D28472?vs=83654&id=83672#toc Repository: rL LLVM https://reviews.llvm.org/D28472 Files: libcxx/trunk/include/memory Index: libcxx/trunk/include/memory === --- libcxx/trunk/include/memory +++ libcxx/trunk/include/memory @@ -3344,12 +3344,13 @@ } }; +struct _PairT { + size_t first; + size_t second; +}; + _LIBCPP_INLINE_VISIBILITY inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { -struct _PairT { - size_t first; - size_t second; -}; typedef __scalar_hash<_PairT> _HashT; const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); Index: libcxx/trunk/include/memory === --- libcxx/trunk/include/memory +++ libcxx/trunk/include/memory @@ -3344,12 +3344,13 @@ } }; +struct _PairT { + size_t first; + size_t second; +}; + _LIBCPP_INLINE_VISIBILITY inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { -struct _PairT { - size_t first; - size_t second; -}; typedef __scalar_hash<_PairT> _HashT; const _PairT __p = {__lhs, __rhs}; return _HashT()(__p); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28477: Add LF_ prefix to LibFunc enums in TargetLibraryInfo.
dlj created this revision. dlj added a reviewer: rsmith. dlj added a subscriber: cfe-commits. The LibFunc::Func enum holds enumerators named for libc functions. Unfortunately, there are real situations, including libc implementations, where function names are actually macros (musl uses "#define fopen64 fopen", for example; any other transitively visible macro would have similar effects). Strictly speaking, a conforming C++ Standard Library should provide any such macros as functions instead (via ). However, there are some "library" functions which are not part of the standard, and thus not subject to this rule (fopen64, for example). So, in order to be both portable and consistent, the enum should not use the bare function names. The old enum naming used a namespace LibFunc and an enum Func, with bare enumerators. This patch changes LibFunc to be an enum with enumerators prefixed with "LF_". (Unfortunately, a scoped enum is not sufficient to override macros.) These changes are for clang. See https://reviews.llvm.org/D28476 for LLVM. https://reviews.llvm.org/D28477 Files: lib/CodeGen/BackendUtil.cpp Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -262,7 +262,7 @@ TLII->disableAllFunctions(); else { // Disable individual libc/libm calls in TargetLibraryInfo. -LibFunc::Func F; +LibFunc F; for (auto &FuncName : CodeGenOpts.getNoBuiltinFuncs()) if (TLII->getLibFunc(FuncName, F)) TLII->setUnavailable(F); Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -262,7 +262,7 @@ TLII->disableAllFunctions(); else { // Disable individual libc/libm calls in TargetLibraryInfo. -LibFunc::Func F; +LibFunc F; for (auto &FuncName : CodeGenOpts.getNoBuiltinFuncs()) if (TLII->getLibFunc(FuncName, F)) TLII->setUnavailable(F); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27800: Add overload of TransformToPotentiallyEvaluated for TypeSourceInfo
efriedma requested changes to this revision. efriedma added a comment. This revision now requires changes to proceed. Missing regression test in test/SemaCXX/. https://reviews.llvm.org/D27800 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640090, @mehdi_amini wrote: > In https://reviews.llvm.org/D28404#640046, @probinson wrote: > > > "I don't care" doesn't seem like much of a principle. > > > Long version is: "There is no use-case, no users, so I don't have much > motivation to push it forward for the only sake of completeness". Does it > sound enough of a principle like that? No. You still need to have adequate justification for your use case, which I think you do not. >> Optnone does not equal -O0. It is a debugging aid for the programmer, >> because debugging optimized code sucks. If you have an LTO-built >> application and want to de-optimize parts of it to aid with debugging, then >> you can use the pragma, as originally intended. > > Having to modifying the source isn't friendly. Not being able to honor -O0 > during LTO is not user-friendly. IMO, '-O0' and '-flto' are conflicting options and therefore not deserving of special support. In my experience, modifying source is by far simpler than hacking a build system to make a special case for compiler options for one module in an application. (If you have a way to build Clang with everything done LTO except one module built with -O0, on Linux with ninja, I would be very curious to hear how you do that.) But if your build system makes that easy, you can just as easily remove `-flto` as add `-O0` and thus get the result you want without trying to pass conflicting options to the compiler. Or spending time implementing this patch. >> I don't think `-c -O0` should get this not-entirely-O0-like behavior. > > What is "not-entirely"? And why do you think that? "Not entirely" means that running the -O0 pipeline, and running an optimization pipeline but asking some subset of passes to turn themselves off, does not get you the same result. And I think that because I'm the one who put 'optnone' upstream in the first place. The case that particularly sticks in my memory is the register allocator, but I believe there are passes at every stage that do not turn themselves off for optnone. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
probinson added a comment. In https://reviews.llvm.org/D28404#640170, @probinson wrote: > In my experience, modifying source Note that the source modification consists of adding `#pragma clang optimize off` to the top of the file. It is not a complicated thing. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right
KP updated this revision to Diff 83676. KP added a comment. Thanks for the review! Split declarations in test cases with PAS_Middle/PAS_Left. Add tests with references and rvalue references. https://reviews.llvm.org/D27651 Files: lib/Format/WhitespaceManager.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -8769,9 +8769,11 @@ verifyFormat("int oneTwoThree = {0}; // comment\n" "unsigned oneTwo = 0; // comment", Alignment); + + // PAS_RIGHT EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" " int const i = 1;\n" -" int * j = 2;\n" +" int *j = 2;\n" " int big = 1;\n" "\n" " unsigned oneTwoThree = 123;\n" @@ -8792,6 +8794,141 @@ "int ll=1;\n" "}", Alignment)); + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int **j = 2, ***k;\n" +" int &k = i;\n" +" int &&l = i + j;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int **j=2,***k;\n" + "int &k=i;\n" + "int &&l=i+j;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + Alignment)); + + // PAS_LEFT + FormatStyle AlignmentLeft = Alignment; + AlignmentLeft.PointerAlignment = FormatStyle::PAS_Left; + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int* j = 2;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int *j=2;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + AlignmentLeft)); + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int** j = 2;\n" +" int& k = i;\n" +" int&& l = i + j;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int **j=2;\n" + "int &k=i;\n" + "int &&l=i+j;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" + "float k= 2;\n" + "int ll=1;\n" + "}", + AlignmentLeft)); + // PAS_MIDDLE + FormatStyle AlignmentMiddle = Alignment; + AlignmentMiddle.PointerAlignment = FormatStyle::PAS_Middle; + EXPECT_EQ("void SomeFunction(int parameter = 0) {\n" +" int const i = 1;\n" +" int * j = 2;\n" +" int big = 1;\n" +"\n" +" unsigned oneTwoThree = 123;\n" +" int oneTwo = 12;\n" +" method();\n" +" float k = 2;\n" +" int ll = 1;\n" +"}", +format("void SomeFunction(int parameter= 0) {\n" + " int const i= 1;\n" + " int *j=2;\n" + " int big = 1;\n" + "\n" + "unsigned oneTwoThree =123;\n" + "int oneTwo = 12;\n" + " method();\n" +
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
mehdi_amini added a comment. In https://reviews.llvm.org/D28404#640170, @probinson wrote: > In https://reviews.llvm.org/D28404#640090, @mehdi_amini wrote: > > > In https://reviews.llvm.org/D28404#640046, @probinson wrote: > > > > > "I don't care" doesn't seem like much of a principle. > > > > > > Long version is: "There is no use-case, no users, so I don't have much > > motivation to push it forward for the only sake of completeness". Does it > > sound enough of a principle like that? > > > No. You still need to have adequate justification for your use case, which I > think you do not. I don't follow your logic. IIUC, you asked about "why not supporting `O1/O2/O3`" ; how is *not supporting* these because their not useful / don't have use-case related to "supporting `O0` is useful"? > > >>> Optnone does not equal -O0. It is a debugging aid for the programmer, >>> because debugging optimized code sucks. If you have an LTO-built >>> application and want to de-optimize parts of it to aid with debugging, then >>> you can use the pragma, as originally intended. >> >> Having to modifying the source isn't friendly. Not being able to honor -O0 >> during LTO is not user-friendly. > > IMO, '-O0' and '-flto' are conflicting options and therefore not deserving of > special support. You're advocating for *rejecting* O0 built module at link-time? We'd still need to detect this though. Status-quo isn't acceptable. Also, that's not practicable: what if I have an LTO static library for which I don't have the source, now if I build my own file with -O0 -flto I can't link anymore. > In my experience, modifying source is by far simpler than hacking a build > system to make a special case for compiler options for one module in an > application. (If you have a way to build Clang with everything done LTO > except one module built with -O0, on Linux with ninja, I would be very > curious to hear how you do that.) Static library, separated projects, etc. We have tons of users... >>> I don't think `-c -O0` should get this not-entirely-O0-like behavior. >> >> What is "not-entirely"? And why do you think that? > > "Not entirely" means that running the -O0 pipeline, and running an > optimization pipeline but asking some subset of passes to turn themselves > off, does not get you the same result. And I think that because I'm the one > who put 'optnone' upstream in the first place. The case that particularly > sticks in my memory is the register allocator, but I believe there are passes > at every stage that do not turn themselves off for optnone. That's orthogonal: you're saying we are not handling it correctly yet, I'm just moving toward *fixing* all these. https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28404: IRGen: Add optnone attribute on function during O0
mehdi_amini added a comment. In https://reviews.llvm.org/D28404#640178, @mehdi_amini wrote: > Also, that's not practicable: what if I have an LTO static library for which > I don't have the source, now if I build my own file with -O0 -flto I can't > link anymore. Also: LTO is required for some features likes CFI. There are users who wants CFI+O0 during development (possibly for debugging a subcomponent of the app). https://reviews.llvm.org/D28404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r291416 - [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.
On 9 January 2017 at 03:44, Faisal Vali wrote: > On Mon, Jan 9, 2017 at 12:13 AM, Richard Smith > wrote: > > On 8 January 2017 at 19:02, Faisal Vali via cfe-commits > > wrote: > >> > >> Author: faisalv > >> Date: Sun Jan 8 21:02:53 2017 > >> New Revision: 291416 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=291416&view=rev > >> Log: > >> [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing > >> lambda expressions. > >> > >> Add a visitor for lambda expressions to RecordExprEvaluator in > >> ExprConstant.cpp that creates an empty APValue of Struct type to > represent > >> the closure object. Additionally, add a LambdaExpr visitor to the > >> TemporaryExprEvaluator that forwards constant evaluation of > >> immediately-called-lambda-expressions to the one in RecordExprEvaluator > >> through VisitConstructExpr. > >> > >> This patch supports: > >> constexpr auto ID = [] (auto a) { return a; }; > >> static_assert(ID(3.14) == 3.14); > >> static_assert([](auto a) { return a + 1; }(10) == 11); > >> > >> Lambda captures are still not supported for constexpr lambdas. > >> > >> > >> Modified: > >> cfe/trunk/lib/AST/ExprConstant.cpp > >> cfe/trunk/lib/Sema/SemaExpr.cpp > >> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp > >> > >> Modified: cfe/trunk/lib/AST/ExprConstant.cpp > >> URL: > >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ExprConstant.cpp?rev=291416&r1=291415&r2=291416&view=diff > >> > >> > == > >> --- cfe/trunk/lib/AST/ExprConstant.cpp (original) > >> +++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Jan 8 21:02:53 2017 > >> @@ -5868,6 +5868,7 @@ namespace { > >> bool VisitCXXConstructExpr(const CXXConstructExpr *E) { > >>return VisitCXXConstructExpr(E, E->getType()); > >> } > >> +bool VisitLambdaExpr(const LambdaExpr *E); > >> bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr > >> *E); > >> bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T); > >> bool VisitCXXStdInitializerListExpr(const > CXXStdInitializerListExpr > >> *E); > >> @@ -6202,6 +6203,21 @@ bool RecordExprEvaluator::VisitCXXStdIni > >>return true; > >> } > >> > >> +bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) { > >> + const CXXRecordDecl *ClosureClass = E->getLambdaClass(); > >> + if (ClosureClass->isInvalidDecl()) return false; > >> + > >> + if (Info.checkingPotentialConstantExpression()) return true; > >> + if (E->capture_size()) { > >> +Info.FFDiag(E, diag::note_unimplemented_ > constexpr_lambda_feature_ast) > >> +<< "can not evaluate lambda expressions with captures"; > >> +return false; > >> + } > >> + // FIXME: Implement captures. > >> + Result = APValue(APValue::UninitStruct(), /*NumBases*/0, > >> /*NumFields*/0); > >> + return true; > >> +} > >> + > >> static bool EvaluateRecord(const Expr *E, const LValue &This, > >> APValue &Result, EvalInfo &Info) { > >>assert(E->isRValue() && E->getType()->isRecordType() && > >> @@ -6251,6 +6267,9 @@ public: > >>bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr > *E) > >> { > >> return VisitConstructExpr(E); > >>} > >> + bool VisitLambdaExpr(const LambdaExpr *E) { > >> +return VisitConstructExpr(E); > >> + } > >> }; > >> } // end anonymous namespace > >> > >> > >> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp > >> URL: > >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ > SemaExpr.cpp?rev=291416&r1=291415&r2=291416&view=diff > >> > >> > == > >> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) > >> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jan 8 21:02:53 2017 > >> @@ -13097,8 +13097,10 @@ void Sema::PopExpressionEvaluationContex > >> // evaluate [...] a lambda-expression. > >> D = diag::err_lambda_in_constant_expression; > >>} > >> - for (const auto *L : Rec.Lambdas) > >> -Diag(L->getLocStart(), D); > >> + // C++1z allows lambda expressions as core constant expressions. > >> + if (Rec.Context != ConstantEvaluated || > !getLangOpts().CPlusPlus1z) > >> +for (const auto *L : Rec.Lambdas) > >> + Diag(L->getLocStart(), D); > > > > > > We'll need an implementation of DR1607 before we're done here, since it > > looks like this has removed the last restriction on lambda-expressions in > > function template signatures in some contexts (array bounds, template > > arguments). > > > > Yes - I'll add those restrictions back (I suppose we'll need to check > whether the nearest enclosing non-lambda context is a valid one [while > still allowing them in default function arguments]) - but then we'll > need to relax some of them when we implement P0315 in post-C++-17 > right? > > For e.g. these would be ok w P0315 right? > > template struct X { }; > > X<[](auto
[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin
This revision was automatically updated to reflect the committed changes. Closed by commit rL291477: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D28213?vs=82791&id=83677#toc Repository: rL LLVM https://reviews.llvm.org/D28213 Files: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Sema/atomic-ops.c Index: cfe/trunk/test/Sema/atomic-ops.c === --- cfe/trunk/test/Sema/atomic-ops.c +++ cfe/trunk/test/Sema/atomic-ops.c @@ -14,11 +14,7 @@ _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); -#ifdef __i386__ -_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); -#else _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); -#endif _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); _Static_assert(__c11_atomic_is_lock_free(1), ""); Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp === --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp @@ -286,12 +286,12 @@ /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with /// the specified properties. -static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, -unsigned InlineWidth) { +static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) { // Fully-aligned, power-of-2 sizes no larger than the inline // width will be inlined as lock-free operations. - if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && - TypeWidth <= InlineWidth) + // Note: we do not need to check alignment since _Atomic(T) is always + // appropriately-aligned in clang. + if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) return "2"; // "always lock free" // We cannot be certain what operations the lib calls might be // able to implement as lock-free on future processors. @@ -881,7 +881,6 @@ #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ getLockFreeValue(TI.get##Type##Width(), \ - TI.get##Type##Align(), \ InlineWidthBits)); DEFINE_LOCK_FREE_MACRO(BOOL, Bool); DEFINE_LOCK_FREE_MACRO(CHAR, Char); @@ -894,7 +893,6 @@ DEFINE_LOCK_FREE_MACRO(LLONG, LongLong); Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", getLockFreeValue(TI.getPointerWidth(0), - TI.getPointerAlign(0), InlineWidthBits)); #undef DEFINE_LOCK_FREE_MACRO } Index: cfe/trunk/test/Sema/atomic-ops.c === --- cfe/trunk/test/Sema/atomic-ops.c +++ cfe/trunk/test/Sema/atomic-ops.c @@ -14,11 +14,7 @@ _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); -#ifdef __i386__ -_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); -#else _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); -#endif _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); _Static_assert(__c11_atomic_is_lock_free(1), ""); Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp === --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp @@ -286,12 +286,12 @@ /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with /// the specified properties. -static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, -unsigned InlineWidth) { +static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) { // Fully-aligned, power-of-2 sizes no larger than the inline // width will be inlined as lock-free operations. - if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && - TypeWidth <= InlineWidth) + // Note: we do not need to check alignment since _Atomic(T) is always + // appropriately-aligned in clang. + if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) return "2"; // "always lock free" // We cannot be certain what operations the lib calls might be // able to implement as lock-free on future processors. @@ -881,7 +881,6 @@ #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ getLockFreeValue(TI.get##Type##Width(), \ - TI.get##Type##Align(), \ InlineWidt
r291477 - [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin
Author: mgorny Date: Mon Jan 9 14:54:20 2017 New Revision: 291477 URL: http://llvm.org/viewvc/llvm-project?rev=291477&view=rev Log: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin Correct the logic used to set ATOMIC_*_LOCK_FREE preprocessor macros not to rely on the ABI alignment of types. Instead, just assume all those types are aligned correctly by default since clang uses safe alignment for _Atomic types even if the underlying types are aligned to a lower boundary by default. For example, the 'long long' and 'double' types on x86 are aligned to 32-bit boundary by default. However, '_Atomic long long' and '_Atomic double' are aligned to 64-bit boundary, therefore satisfying the requirements of lock-free atomic operations. This fixes PR #19355 by correcting the value of __GCC_ATOMIC_LLONG_LOCK_FREE on x86, and therefore also fixing the assumption made in libc++ tests. This also fixes PR #30581 by applying a consistent logic between the functions used to implement both interfaces. Differential Revision: https://reviews.llvm.org/D28213 Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Sema/atomic-ops.c Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=291477&r1=291476&r2=291477&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Jan 9 14:54:20 2017 @@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned T /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with /// the specified properties. -static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, -unsigned InlineWidth) { +static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) { // Fully-aligned, power-of-2 sizes no larger than the inline // width will be inlined as lock-free operations. - if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && - TypeWidth <= InlineWidth) + // Note: we do not need to check alignment since _Atomic(T) is always + // appropriately-aligned in clang. + if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) return "2"; // "always lock free" // We cannot be certain what operations the lib calls might be // able to implement as lock-free on future processors. @@ -881,7 +881,6 @@ static void InitializePredefinedMacros(c #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ getLockFreeValue(TI.get##Type##Width(), \ - TI.get##Type##Align(), \ InlineWidthBits)); DEFINE_LOCK_FREE_MACRO(BOOL, Bool); DEFINE_LOCK_FREE_MACRO(CHAR, Char); @@ -894,7 +893,6 @@ static void InitializePredefinedMacros(c DEFINE_LOCK_FREE_MACRO(LLONG, LongLong); Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", getLockFreeValue(TI.getPointerWidth(0), - TI.getPointerAlign(0), InlineWidthBits)); #undef DEFINE_LOCK_FREE_MACRO } Modified: cfe/trunk/test/Sema/atomic-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=291477&r1=291476&r2=291477&view=diff == --- cfe/trunk/test/Sema/atomic-ops.c (original) +++ cfe/trunk/test/Sema/atomic-ops.c Mon Jan 9 14:54:20 2017 @@ -14,11 +14,7 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); -#ifdef __i386__ -_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); -#else _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); -#endif _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); _Static_assert(__c11_atomic_is_lock_free(1), ""); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits