Re: [PATCH] D14629: [analyzer] Configuration file for scan-build.
xazax.hun added a comment. Clang tidy can pass per checker configuration to the static analyzer at the moment. I think it should not be hard to extend it. http://reviews.llvm.org/D14629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r253772 - clang-format: Make sorting includes respect // clang-format off
Author: djasper Date: Sat Nov 21 03:17:08 2015 New Revision: 253772 URL: http://llvm.org/viewvc/llvm-project?rev=253772&view=rev Log: clang-format: Make sorting includes respect // clang-format off Modified: cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/SortIncludesTest.cpp Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=253772&r1=253771&r2=253772&view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Sat Nov 21 03:17:08 2015 @@ -1780,11 +1780,20 @@ tooling::Replacements sortIncludes(const for (const auto &Category : Style.IncludeCategories) CategoryRegexs.emplace_back(Category.Regex); + bool FormattingOff = false; + for (;;) { auto Pos = Code.find('\n', SearchFrom); StringRef Line = Code.substr(Prev, (Pos != StringRef::npos ? Pos : Code.size()) - Prev); -if (!Line.endswith("\\")) { + +StringRef Trimmed = Line.trim(); +if (Trimmed == "// clang-format off") + FormattingOff = true; +else if (Trimmed == "// clang-format on") + FormattingOff = false; + +if (!FormattingOff && !Line.endswith("\\")) { if (IncludeRegex.match(Line, &Matches)) { StringRef IncludeName = Matches[2]; unsigned Category; Modified: cfe/trunk/unittests/Format/SortIncludesTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/SortIncludesTest.cpp?rev=253772&r1=253771&r2=253772&view=diff == --- cfe/trunk/unittests/Format/SortIncludesTest.cpp (original) +++ cfe/trunk/unittests/Format/SortIncludesTest.cpp Sat Nov 21 03:17:08 2015 @@ -40,6 +40,25 @@ TEST_F(SortIncludesTest, BasicSorting) { "#include \"b.h\"\n")); } +TEST_F(SortIncludesTest, SupportClangFormatOff) { + EXPECT_EQ("#include \n" +"#include \n" +"#include \n" +"// clang-format off\n" +"#include \n" +"#include \n" +"#include \n" +"// clang-format on\n", +sort("#include \n" + "#include \n" + "#include \n" + "// clang-format off\n" + "#include \n" + "#include \n" + "#include \n" + "// clang-format on\n")); +} + TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) { Style.SortIncludes = false; EXPECT_EQ("#include \"a.h\"\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14871: [Power PC] fix calculating address of arguments on stack for variadic functions
hfinkel added inline comments. Comment at: lib/CodeGen/TargetInfo.cpp:3547 @@ +3546,3 @@ +// Round up address of argument to alignment +llvm::Value *overflow_arg_area = OverflowArea.getPointer(); +uint32_t Align = CGF.getContext().getTypeAlignInChars(Ty).getQuantity(); You need to use variable names consistent with our coding convention (OverflowArgArea, etc.). http://reviews.llvm.org/D14871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14880: Fixed some buggy edge-cases in UseOverrideCheck.cpp
baxtersa added a comment. I don't know who to add as reviewers here, so if someone in the know could do that that would be great! http://reviews.llvm.org/D14880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14858: Support building tsan on android.
dimitry added a comment. The only difference is that main executable group is not RTLD_GLOBAL in android (it is RTLD_GLOBAL in glibc) - so the symbols of DT_NEEDED libraries are not visible by default; the way to enforce this for you library on android is to use -z global ld option http://reviews.llvm.org/D14858 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D9600: Add scan-build python implementation
dcoughlin added a comment. Thanks Laszlo! Is there a more descriptive name than "intercept-build" (I realize scan-build is pretty general too). It seems to me the point of the intercept-build tool is to generate the compilation database. I think it would be helpful if the tool name indicated that rather than the *method* used to to generate the database. I don't have any great suggestions: "compilation-database-build", "log-build", "log-compilation-build", ... A couple more comments inline. Comment at: tools/scan-build-py/MANIFEST.in:1 @@ +1,2 @@ +include README.md +include *.txt rizsotto.mailinglist wrote: > dcoughlin wrote: > > How about this one? Is it needed in clang trunk? > in order to make this code a standalone python tool tool, we need this file. > (see llvm/utils/lit directory for example.) Can you explain why this is needed? We didn't need one for the perl scan-build nor for SATestBuild.py/SATestAdd.py? A difference between lit and scan-build is that scan-build is not a standalone tool. Are you envisioning users installing scan-build without installing clang? Comment at: tools/scan-build-py/libear/__init__.py:1 @@ +1,2 @@ +# -*- coding: utf-8 -*- +# The LLVM Compiler Infrastructure jroelofs wrote: > rizsotto.mailinglist wrote: > > dcoughlin wrote: > > > How does this file fit into the overall build picture? Will this file go > > > away once scan-build-py is built with the common clang cmake? > > this is quiet confusing me. previously you were asking make it work without > > installation. this file makes it possible to compile the `ear` library > > compiled before the build runs to use as preloaded library. the thing which > > is not needed is the CMakefile actually. > I think the best way forward would be to teach the CMake build how to run > `setup.py`. Then this would work both with and without installation, and > it'd use the same code paths for both. > previously you were asking make it work without installation. Yes. It is very important to support that workflow since many users have multiple versions of clang on their systems at the same time. > this file makes it possible to compile the ear library compiled before the > build runs to use as preloaded library. Shouldn't this be done as part of the build process and not as part of installation? Can the interception library (eventually) be built as part of the global CMake build? It seems quite fragile to have custom build logic in a python file. Comment at: tools/scan-build-py/libear/__init__.py:1 @@ +1,2 @@ +# -*- coding: utf-8 -*- +# The LLVM Compiler Infrastructure dcoughlin wrote: > jroelofs wrote: > > rizsotto.mailinglist wrote: > > > dcoughlin wrote: > > > > How does this file fit into the overall build picture? Will this file > > > > go away once scan-build-py is built with the common clang cmake? > > > this is quiet confusing me. previously you were asking make it work > > > without installation. this file makes it possible to compile the `ear` > > > library compiled before the build runs to use as preloaded library. the > > > thing which is not needed is the CMakefile actually. > > I think the best way forward would be to teach the CMake build how to run > > `setup.py`. Then this would work both with and without installation, and > > it'd use the same code paths for both. > > previously you were asking make it work without installation. > > Yes. It is very important to support that workflow since many users have > multiple versions of clang on their systems at the same time. > > > this file makes it possible to compile the ear library compiled before the > > build runs to use as preloaded library. > > Shouldn't this be done as part of the build process and not as part of > installation? > > Can the interception library (eventually) be built as part of the global > CMake build? It seems quite fragile to have custom build logic in a python > file. jroelofs wrote: > I think the best way forward would be to teach the CMake build how to run > setup.py What is the benefit of running `setup.py` and treating scan-build as a python package? It seems to me that the fact that scan-build is written in python should be an implementation detail. Most importantly, installing scan-build shouldn't muck up the user's python environment. In my opinion, it would be more user-friendly to install into the new scan-build install hierarchy that jroelofs recently added. This way all the scan-build stuff is under one directory that the user can blow away rather than hidden deep in the bowels of some python environment. This makes it much easier to ensure that scan-build and clang are in sync and would prevent the user from accidentally installing scan-build into a virtualenv (which doesn't make sense because clang doesn't live there). Co
Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats
It would seem cleaner to build an ImplicitCastExpr node in Sema between the operand and the splat node. On Nov 20, 2015 11:04 AM, "George Burgess IV" wrote: > george.burgess.iv created this revision. > george.burgess.iv added a reviewer: rsmith. > george.burgess.iv added a subscriber: cfe-commits. > > When evaluating constexpr vector splats, we weren't doing appropriate type > conversions on the literal we were splatting, causing assertion failures in > cases like: > > ``` > void foo(vector float FloatInput, vector short ShortInput) { > (void)(FloatInput == (vector float)0); // OK > (void)(ShortInput == (vector short)0); // OK > > constexpr vector float Floats = (vector float)0; > (void)(FloatInput == Floats); // ICE -- fcmp between [4 x i32] and [4 x > f32] > > constexpr vector short Shorts = (vector short)0; > (void)(ShortInput == Shorts); // ICE -- fcmp between vec of i16 and vec > of i32 > } > ``` > > (The same issue applied for cases like `(vector short)0`; it would be > lowered as a vector of `i32`.) > > This patch fixes these in ExprConstant rather than CodeGen, because it > allows us to more sanely model overflow/complain to the user/... in the > evaluator. > > This patch also contains a few generic code cleanliness changes. I'm happy > to drop any/all of them if we decide they're not helpful. :) > > http://reviews.llvm.org/D14877 > > Files: > lib/AST/ExprConstant.cpp > lib/CodeGen/CGExprConstant.cpp > test/CodeGenCXX/builtins-systemz-zvector.cpp > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14877: Fix ICE on lowering of constexpr vector splats
majnemer added a subscriber: majnemer. Comment at: lib/CodeGen/CGExprConstant.cpp:1362-1363 @@ -1360,3 +1361,4 @@ +Inits[I] = llvm::ConstantFP::get(VMContext, Elt.getFloat()); else -Inits.push_back(llvm::ConstantFP::get(VMContext, Elt.getFloat())); +llvm_unreachable("unsupported vector element type"); } Is this unreachable for vectors of pointer type? http://reviews.llvm.org/D14877 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14905: [constexpr-lambda] Support parsing of constexpr specifier (and its inference) on lambda expressions
faisalv created this revision. faisalv added reviewers: rsmith, doug.gregor, hubert.reinterpretcast, aaron.ballman, nwilson. faisalv added a subscriber: cfe-commits. This patch supports parsing of the constexpr specifier on lambdas - and its inference from the lambda call operator's body. i.e. auto L = [] () constexpr { return 5; }; static_assert(L() == 5); // OK It does not support evaluation of lambda's within constant expressions, which should follow this patch, when approved. http://reviews.llvm.org/D14905 Files: include/clang/Basic/DiagnosticASTKinds.td include/clang/Basic/DiagnosticParseKinds.td include/clang/Sema/Sema.h lib/AST/ExprConstant.cpp lib/Parse/ParseExprCXX.cpp lib/Sema/SemaLambda.cpp lib/Sema/TreeTransform.h test/Parser/cxx1z-constexpr-lambdas.cpp test/SemaCXX/cxx1z-constexpr-lambdas.cpp Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp === --- test/SemaCXX/cxx1z-constexpr-lambdas.cpp +++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks %s +// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING +// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS +// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING + +namespace test_constexpr_checking { + +namespace ns1 { + struct NonLit { ~NonLit(); }; //expected-note{{not literal}} + auto L = [](NonLit NL) constexpr { }; //expected-error{{not a literal type}} +} // end ns1 + +namespace ns2 { + auto L = [](int I) constexpr { static int J; }; //expected-error{{not permitted in a constexpr function}} +} // end ns1 + +} // end ns test_constexpr_checking + +namespace test_constexpr_call { + +namespace ns1 { + auto L = [](int I) { return I; }; + static_assert(L(3) == 3); +} // end ns1 + +} // end ns test_constexpr_call \ No newline at end of file Index: test/Parser/cxx1z-constexpr-lambdas.cpp === --- test/Parser/cxx1z-constexpr-lambdas.cpp +++ test/Parser/cxx1z-constexpr-lambdas.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++1z %s -verify -DCPP1Z +// RUN: %clang_cc1 -std=c++14 %s -verify -DCPP14 + +auto L0 = [] constexpr { }; //expected-error{{requires '()'}} expected-error{{expected body}} +#ifdef CPP1Z + +auto L = []() mutable constexpr { }; +auto L2 = []() constexpr { }; +auto L3 = []() mutable { }; +auto L4 = []() constexpr mutable { }; + + +#elif defined(CPP14) +auto L = [] () constexpr { }; //expected-error{{only in C++1z}} + +#endif + + Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -9678,7 +9678,9 @@ CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition( Class, E->getIntroducerRange(), NewCallOpTSI, E->getCallOperator()->getLocEnd(), - NewCallOpTSI->getTypeLoc().castAs().getParams()); + NewCallOpTSI->getTypeLoc().castAs().getParams(), + E->getCallOperator()->isConstexpr()); + LSI->CallOperator = NewCallOperator; getDerived().transformAttrs(E->getCallOperator(), NewCallOperator); Index: lib/Sema/SemaLambda.cpp === --- lib/Sema/SemaLambda.cpp +++ lib/Sema/SemaLambda.cpp @@ -354,7 +354,8 @@ SourceRange IntroducerRange, TypeSourceInfo *MethodTypeInfo, SourceLocation EndLoc, - ArrayRef Params) { + ArrayRef Params, + const bool IsConstexprSpecified) { QualType MethodType = MethodTypeInfo->getType(); TemplateParameterList *TemplateParams = getGenericLambdaTemplateParameterList(getCurLambda(), *this); @@ -391,7 +392,7 @@ MethodType, MethodTypeInfo, SC_None, /*isInline=*/true, -/*isConstExpr=*/false, +IsConstexprSpecified, EndLoc); Method->setAccess(AS_public); @@ -881,8 +882,9 @@ CXXRecordDecl *Class = createLambdaClosureType(Intro.Range, MethodTyInfo, KnownDependent, Intro.Default); - CXXMethodDecl *Method = startLambdaDefinition(Class, Intro.Range, -MethodTyInfo, EndLoc, Params); + CXXMethodDecl *Method = + startLambdaDefinition(Class, Intro.Range, MethodTyInfo, EndLoc, Params, +ParamInfo.getDeclSpec().isConstexpr
Re: [PATCH] D9600: Add scan-build python implementation
On 11/21/15 9:50 AM, Devin Coughlin wrote: dcoughlin added a comment. Thanks Laszlo! Is there a more descriptive name than "intercept-build" (I realize scan-build is pretty general too). It seems to me the point of the intercept-build tool is to generate the compilation database. I think it would be helpful if the tool name indicated that rather than the *method* used to to generate the database. I don't have any great suggestions: "compilation-database-build", "log-build", "log-compilation-build", ... A couple more comments inline. Comment at: tools/scan-build-py/MANIFEST.in:1 @@ +1,2 @@ +include README.md +include *.txt rizsotto.mailinglist wrote: dcoughlin wrote: How about this one? Is it needed in clang trunk? in order to make this code a standalone python tool tool, we need this file. (see llvm/utils/lit directory for example.) Can you explain why this is needed? We didn't need one for the perl scan-build nor for SATestBuild.py/SATestAdd.py? A difference between lit and scan-build is that scan-build is not a standalone tool. Are you envisioning users installing scan-build without installing clang? Comment at: tools/scan-build-py/libear/__init__.py:1 @@ +1,2 @@ +# -*- coding: utf-8 -*- +# The LLVM Compiler Infrastructure jroelofs wrote: rizsotto.mailinglist wrote: dcoughlin wrote: How does this file fit into the overall build picture? Will this file go away once scan-build-py is built with the common clang cmake? this is quiet confusing me. previously you were asking make it work without installation. this file makes it possible to compile the `ear` library compiled before the build runs to use as preloaded library. the thing which is not needed is the CMakefile actually. I think the best way forward would be to teach the CMake build how to run `setup.py`. Then this would work both with and without installation, and it'd use the same code paths for both. previously you were asking make it work without installation. Yes. It is very important to support that workflow since many users have multiple versions of clang on their systems at the same time. this file makes it possible to compile the ear library compiled before the build runs to use as preloaded library. Shouldn't this be done as part of the build process and not as part of installation? Can the interception library (eventually) be built as part of the global CMake build? It seems quite fragile to have custom build logic in a python file. Oh, good point. This is also important if we're cross building the toolchain... this library should get built with the same compiler that's building clang. Comment at: tools/scan-build-py/libear/__init__.py:1 @@ +1,2 @@ +# -*- coding: utf-8 -*- +# The LLVM Compiler Infrastructure dcoughlin wrote: jroelofs wrote: rizsotto.mailinglist wrote: dcoughlin wrote: How does this file fit into the overall build picture? Will this file go away once scan-build-py is built with the common clang cmake? this is quiet confusing me. previously you were asking make it work without installation. this file makes it possible to compile the `ear` library compiled before the build runs to use as preloaded library. the thing which is not needed is the CMakefile actually. I think the best way forward would be to teach the CMake build how to run `setup.py`. Then this would work both with and without installation, and it'd use the same code paths for both. previously you were asking make it work without installation. Yes. It is very important to support that workflow since many users have multiple versions of clang on their systems at the same time. this file makes it possible to compile the ear library compiled before the build runs to use as preloaded library. Shouldn't this be done as part of the build process and not as part of installation? Can the interception library (eventually) be built as part of the global CMake build? It seems quite fragile to have custom build logic in a python file. jroelofs wrote: I think the best way forward would be to teach the CMake build how to run setup.py What is the benefit of running `setup.py` and treating scan-build as a python package? It seems to me that the fact that scan-build is written in python should be an implementation detail. Most importantly, installing scan-build shouldn't muck up the user's python environment. In my opinion, it would be more user-friendly to install into the new scan-build install hierarchy that jroelofs recently added. This way all the scan-build stuff is under one directory that the user can blow away rather than hidden deep in the bowels of some python environment. This makes it much easier to ensure that scan-build and clang are in sync and would prevent the user from accidentally installing scan-build into a virtualenv (which doesn't make sense because clang doesn't
r253811 - [coroutines] Factor out co_await representation into common base class for co_await and co_yield, and use it to hold await_* calls.
Author: rsmith Date: Sat Nov 21 20:57:17 2015 New Revision: 253811 URL: http://llvm.org/viewvc/llvm-project?rev=253811&view=rev Log: [coroutines] Factor out co_await representation into common base class for co_await and co_yield, and use it to hold await_* calls. Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/Basic/StmtNodes.td cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/Parser/cxx1z-coroutines.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=253811&r1=253810&r2=253811&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Sat Nov 21 20:57:17 2015 @@ -4826,6 +4826,14 @@ public: const_semantics_iterator semantics_end() const { return getSubExprsBuffer() + getNumSubExprs(); } + + llvm::iterator_range semantics() { +return llvm::make_range(semantics_begin(), semantics_end()); + } + llvm::iterator_range semantics() const { +return llvm::make_range(semantics_begin(), semantics_end()); + } + Expr *getSemanticExpr(unsigned index) { assert(index + 1 < getNumSubExprs()); return getSubExprsBuffer()[index + 1]; Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=253811&r1=253810&r2=253811&view=diff == --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Sat Nov 21 20:57:17 2015 @@ -4008,65 +4008,61 @@ public: child_range children() { return child_range(SubExprs, SubExprs + 2); } }; -/// \brief Represents a 'co_await' expression. This expression checks whether its -/// operand is ready, and suspends the coroutine if not. Then (after the resume -/// if suspended) it resumes the coroutine and extracts the value from the -/// operand. This implies making four calls: +/// \brief Represents an expression that might suspend coroutine execution; +/// either a co_await or co_yield expression. /// -/// .operator co_await() or operator co_await() -/// .await_ready() -/// .await_suspend(h) -/// .await_resume() -/// -/// where h is a handle to the coroutine, and is the result of calling -/// operator co_await() if it exists or the original operand otherwise. -/// -/// Note that the coroutine is prepared for suspension before the 'await_suspend' -/// call, but resumes after that call, which may cause parts of the -/// 'await_suspend' expression to occur much later than expected. -class CoawaitExpr : public Expr { - SourceLocation CoawaitLoc; +/// Evaluation of this expression first evaluates its 'ready' expression. If +/// that returns 'false': +/// -- execution of the coroutine is suspended +/// -- the 'suspend' expression is evaluated +/// -- if the 'suspend' expression returns 'false', the coroutine is +///resumed +/// -- otherwise, control passes back to the resumer. +/// If the coroutine is not suspended, or when it is resumed, the 'resume' +/// expression is evaluated, and its result is the result of the overall +/// expression. +class CoroutineSuspendExpr : public Expr { + SourceLocation KeywordLoc; - enum SubExpr { Operand, Ready, Suspend, Resume, Count }; + enum SubExpr { Common, Ready, Suspend, Resume, Count }; Stmt *SubExprs[SubExpr::Count]; friend class ASTStmtReader; public: - CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Ready, - Expr *Suspend, Expr *Resume) - : Expr(CoawaitExprClass, Resume->getType(), Resume->getValueKind(), - Resume->getObjectKind(), - Resume->isTypeDependent(), - Resume->isValueDependent(), - Operand->isInstantiationDependent(), - Operand->containsUnexpandedParameterPack()), - CoawaitLoc(CoawaitLoc) { -SubExprs[CoawaitExpr::Operand] = Operand; -SubExprs[CoawaitExpr::Ready] = Ready; -SubExprs[CoawaitExpr::Suspend] = Suspend; -SubExprs[CoawaitExpr::Resume] = Resume; - } - CoawaitExpr(SourceLocation CoawaitLoc, QualType Ty, Expr *Operand) - : Expr(CoawaitExprClass, Ty, VK_RValue, OK_Ordinary, - true, true, true, Operand->containsUnexpandedParameterPack()), -CoawaitLoc(CoawaitLoc) { -assert(Operand->isTypeDependent() && Ty->isDependentType() && - "wrong constructor for non-dependent co_await expression"); -SubExprs[CoawaitExpr::Operand] = Operand; -SubExprs[CoawaitExpr::Ready] = nullptr; -SubExprs[CoawaitExpr::Suspend] = nullptr; -SubExprs[CoawaitExpr::Resume] = nullptr; - } - CoawaitExpr(EmptyShell Empty) : Expr(CoawaitExprClass, Empty) { -SubExprs[CoawaitExpr::Operand] = n
r253812 - [coroutines] Materialize the awaitable before generating the await_* calls.
Author: rsmith Date: Sat Nov 21 21:13:02 2015 New Revision: 253812 URL: http://llvm.org/viewvc/llvm-project?rev=253812&view=rev Log: [coroutines] Materialize the awaitable before generating the await_* calls. Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253812&r1=253811&r2=253812&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sat Nov 21 21:13:02 2015 @@ -195,7 +195,7 @@ static ReadySuspendResumeResult buildCoa const StringRef Funcs[] = {"await_ready", "await_suspend", "await_resume"}; for (size_t I = 0, N = llvm::array_lengthof(Funcs); I != N; ++I) { Expr *Operand = new (S.Context) OpaqueValueExpr( -Loc, E->getType(), E->getValueKind(), E->getObjectKind(), E); +Loc, E->getType(), VK_LValue, E->getObjectKind(), E); // FIXME: Pass coroutine handle to await_suspend. ExprResult Result = buildMemberCall(S, Operand, Loc, Funcs[I], None); @@ -237,8 +237,10 @@ ExprResult Sema::BuildCoawaitExpr(Source return Res; } - // FIXME: If E is a prvalue, create a temporary. - // FIXME: If E is an xvalue, convert to lvalue. + // If the expression is a temporary, materialize it as an lvalue so that we + // can use it multiple times. + if (E->getValueKind() == VK_RValue) +E = new (Context) MaterializeTemporaryExpr(E->getType(), E, true); // Build the await_ready, await_suspend, await_resume calls. ReadySuspendResumeResult RSS = buildCoawaitCalls(*this, Loc, E); @@ -306,8 +308,10 @@ ExprResult Sema::BuildCoyieldExpr(Source return Res; } - // FIXME: If E is a prvalue, create a temporary. - // FIXME: If E is an xvalue, convert to lvalue. + // If the expression is a temporary, materialize it as an lvalue so that we + // can use it multiple times. + if (E->getValueKind() == VK_RValue) +E = new (Context) MaterializeTemporaryExpr(E->getType(), E, true); // Build the await_ready, await_suspend, await_resume calls. ReadySuspendResumeResult RSS = buildCoawaitCalls(*this, Loc, E); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r253813 - Driver: Specifically tell the linker the target for mingw-w64
Author: martell Date: Sat Nov 21 23:40:06 2015 New Revision: 253813 URL: http://llvm.org/viewvc/llvm-project?rev=253813&view=rev Log: Driver: Specifically tell the linker the target for mingw-w64 Cross compiling from linux and OSX results in Error: Exec format. This is because the linker is expecting ELF formated objects. By passing the target we can explicitly tell the linker that it should be linking COFF objects regardless of the host. Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253813&r1=253812&r2=253813&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Sat Nov 21 23:40:06 2015 @@ -9478,7 +9478,14 @@ void MinGW::Linker::ConstructJob(Compila StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld"); if (LinkerName.equals_lower("lld")) { CmdArgs.push_back("-flavor"); -CmdArgs.push_back("old-gnu"); +CmdArgs.push_back("gnu"); +CmdArgs.push_back("-target"); +if (TC.getArch() == llvm::Triple::x86) + CmdArgs.push_back("i686--windows-gnu"); +if (TC.getArch() == llvm::Triple::x86_64) + CmdArgs.push_back("x86_64--windows-gnu"); +if (TC.getArch() == llvm::Triple::arm) + CmdArgs.push_back("armv7--windows-gnu"); } else if (!LinkerName.equals_lower("ld")) { D.Diag(diag::err_drv_unsupported_linker) << LinkerName; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r253815 - Test: Update mingw-useld.c to reflect r253813
Author: martell Date: Sat Nov 21 23:45:03 2015 New Revision: 253815 URL: http://llvm.org/viewvc/llvm-project?rev=253815&view=rev Log: Test: Update mingw-useld.c to reflect r253813 Modified: cfe/trunk/test/Driver/mingw-useld.c Modified: cfe/trunk/test/Driver/mingw-useld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-useld.c?rev=253815&r1=253814&r2=253815&view=diff == --- cfe/trunk/test/Driver/mingw-useld.c (original) +++ cfe/trunk/test/Driver/mingw-useld.c Sat Nov 21 23:45:03 2015 @@ -1,19 +1,19 @@ // RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s // CHECK_LD_32: {{ld|ld.exe}}" // CHECK_LD_32: "i386pe" -// CHECK_LD_32-NOT: "-flavor" "old-gnu" +// CHECK_LD_32-NOT: "-flavor" "gnu" // RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s // CHECK_LLD_32-NOT: invalid linker name in argument -// CHECK_LLD_32: lld" "-flavor" "old-gnu" +// CHECK_LLD_32: lld" "-flavor" "gnu" // CHECK_LLD_32: "i386pe" // RUN: %clang -### -target x86_64-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s // CHECK_LLD_64-NOT: invalid linker name in argument -// CHECK_LLD_64: lld" "-flavor" "old-gnu" +// CHECK_LLD_64: lld" "-flavor" "gnu" // CHECK_LLD_64: "i386pep" // RUN: %clang -### -target arm-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s // CHECK_LLD_ARM-NOT: invalid linker name in argument -// CHECK_LLD_ARM: lld" "-flavor" "old-gnu" +// CHECK_LLD_ARM: lld" "-flavor" "gnu" // CHECK_LLD_ARM: "thumb2pe" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r253816 - [coroutines] Build implicit return_value / return_void calls for co_return.
Author: rsmith Date: Sun Nov 22 01:05:16 2015 New Revision: 253816 URL: http://llvm.org/viewvc/llvm-project?rev=253816&view=rev Log: [coroutines] Build implicit return_value / return_void calls for co_return. Modified: cfe/trunk/include/clang/AST/StmtCXX.h cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/AST/StmtCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtCXX.h?rev=253816&r1=253815&r2=253816&view=diff == --- cfe/trunk/include/clang/AST/StmtCXX.h (original) +++ cfe/trunk/include/clang/AST/StmtCXX.h Sun Nov 22 01:05:16 2015 @@ -328,50 +328,47 @@ public: /// /// This statament models the initialization of the coroutine promise /// (encapsulating the eventual notional return value) from an expression -/// (or braced-init-list). +/// (or braced-init-list), followed by termination of the coroutine. /// -/// This initialization is modeled by a call to one of: +/// This initialization is modeled by the evaluation of the operand +/// followed by a call to one of: /// .return_value() /// .return_void() /// which we name the "promise call". class CoreturnStmt : public Stmt { SourceLocation CoreturnLoc; - /// The operand of the 'co_return' statement. - Stmt *Operand; - /// The implied call to the promise object. May be null if the - /// coroutine has not yet been finalized. - Stmt *PromiseCall; + enum SubStmt { Operand, PromiseCall, Count }; + Stmt *SubStmts[SubStmt::Count]; friend class ASTStmtReader; public: - CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand) - : Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc), -Operand(Operand), PromiseCall(nullptr) {} + CoreturnStmt(SourceLocation CoreturnLoc, Stmt *Operand, Stmt *PromiseCall) + : Stmt(CoreturnStmtClass), CoreturnLoc(CoreturnLoc) { +SubStmts[SubStmt::Operand] = Operand; +SubStmts[SubStmt::PromiseCall] = PromiseCall; + } SourceLocation getKeywordLoc() const { return CoreturnLoc; } /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr /// if none was specified. - Expr *getOperand() const { return static_cast(Operand); } + Expr *getOperand() const { return static_cast(SubStmts[Operand]); } /// \brief Retrieve the promise call that results from this 'co_return' /// statement. Will be nullptr if either the coroutine has not yet been /// finalized or the coroutine has no eventual return type. - Expr *getPromiseCall() const { return static_cast(PromiseCall); } - - /// \brief Set the resolved promise call. This is delayed until the - /// complete coroutine body has been parsed and the promise type is known. - void finalize(Stmt *PC) { PromiseCall = PC; } + Expr *getPromiseCall() const { +return static_cast(SubStmts[PromiseCall]); + } SourceLocation getLocStart() const LLVM_READONLY { return CoreturnLoc; } SourceLocation getLocEnd() const LLVM_READONLY { -return Operand->getLocEnd(); +return getOperand()->getLocEnd(); } child_range children() { -Stmt **Which = PromiseCall ? &PromiseCall : &Operand; -return child_range(Which, Which + 1); +return child_range(SubStmts, SubStmts + SubStmt::Count); } static bool classof(const Stmt *T) { Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253816&r1=253815&r2=253816&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sun Nov 22 01:05:16 2015 @@ -253,8 +253,9 @@ ExprResult Sema::BuildCoawaitExpr(Source return Res; } -static ExprResult buildYieldValueCall(Sema &S, FunctionScopeInfo *Coroutine, - SourceLocation Loc, Expr *E) { +static ExprResult buildPromiseCall(Sema &S, FunctionScopeInfo *Coroutine, + SourceLocation Loc, StringRef Name, + MutableArrayRef Args) { assert(Coroutine->CoroutinePromise && "no promise for coroutine"); // Form a reference to the promise. @@ -265,7 +266,7 @@ static ExprResult buildYieldValueCall(Se return ExprError(); // Call 'yield_value', passing in E. - return buildMemberCall(S, PromiseRef.get(), Loc, "yield_value", E); + return buildMemberCall(S, PromiseRef.get(), Loc, Name, Args); } ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) { @@ -280,7 +281,8 @@ ExprResult Sema::ActOnCoyieldExpr(Scope return ExprError(); // Build yield_value call. - ExprResult Awaitable = buildYieldValueCall(*this, Coroutine, Loc, E); + ExprResult Awaitable = + buildPromiseCall(*this, Coroutine, Loc, "yield_value", E); if (Awaitable.isInvalid()) return ExprError(); @@ -338,8 +340,22 @@ Stmt
r253817 - [coroutines] Check for overload sets in co_yield / co_return operands being resolved by a call to yield_value / return_value before rejecting them.
Author: rsmith Date: Sun Nov 22 01:33:28 2015 New Revision: 253817 URL: http://llvm.org/viewvc/llvm-project?rev=253817&view=rev Log: [coroutines] Check for overload sets in co_yield / co_return operands being resolved by a call to yield_value / return_value before rejecting them. Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253817&r1=253816&r2=253817&view=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Sun Nov 22 01:33:28 2015 @@ -52,6 +52,8 @@ static QualType lookupPromiseType(Sema & Args.addArgument(TemplateArgumentLoc( TemplateArgument(FnType->getReturnType()), S.Context.getTrivialTypeSourceInfo(FnType->getReturnType(), Loc))); + // FIXME: If the function is a non-static member function, add the type + // of the implicit object parameter before the formal parameters. for (QualType T : FnType->getParamTypes()) Args.addArgument(TemplateArgumentLoc( TemplateArgument(T), S.Context.getTrivialTypeSourceInfo(T, Loc))); @@ -270,12 +272,6 @@ static ExprResult buildPromiseCall(Sema } ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) { - if (E->getType()->isPlaceholderType()) { -ExprResult R = CheckPlaceholderExpr(E); -if (R.isInvalid()) return ExprError(); -E = R.get(); - } - auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield"); if (!Coroutine) return ExprError(); @@ -330,16 +326,17 @@ StmtResult Sema::ActOnCoreturnStmt(Sourc return BuildCoreturnStmt(Loc, E); } StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) { - if (E && E->getType()->isPlaceholderType()) { + auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return"); + if (!Coroutine) +return StmtError(); + + if (E && E->getType()->isPlaceholderType() && + !E->getType()->isSpecificPlaceholderType(BuiltinType::Overload)) { ExprResult R = CheckPlaceholderExpr(E); if (R.isInvalid()) return StmtError(); E = R.get(); } - auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return"); - if (!Coroutine) -return StmtError(); - // FIXME: If the operand is a reference to a variable that's about to go out // ot scope, we should treat the operand as an xvalue for this overload // resolution. Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=253817&r1=253816&r2=253817&view=diff == --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Sun Nov 22 01:33:28 2015 @@ -49,11 +49,11 @@ struct yielded_thing { const char *p; sh struct not_awaitable {}; struct promise { - awaitable yield_value(int); // expected-note {{candidate}} - awaitable yield_value(yielded_thing); // expected-note {{candidate}} - not_awaitable yield_value(void()); // expected-note {{candidate}} + awaitable yield_value(int); // expected-note 2{{candidate}} + awaitable yield_value(yielded_thing); // expected-note 2{{candidate}} + not_awaitable yield_value(void()); // expected-note 2{{candidate}} void return_void(); - void return_value(int); // expected-note {{here}} + void return_value(int); // expected-note 2{{here}} }; void yield() { @@ -159,17 +159,37 @@ namespace dependent_operator_co_await_lo template void await_template_2(outer); } +struct yield_fn_tag {}; +template<> struct std::coroutine_traits { + struct promise_type { +// FIXME: add an await_transform overload for functions +awaitable yield_value(int()); +void return_value(int()); + }; +}; + namespace placeholder { - awaitable f(), f(int); // expected-note 2{{possible target}} - int g(), g(int); // expected-note 4{{possible target}} + awaitable f(), f(int); // expected-note 4{{possible target}} + int g(), g(int); // expected-note 2{{candidate}} void x() { co_await f; // expected-error {{reference to overloaded function}} } void y() { -co_yield g; // expected-error {{reference to overloaded function}} +co_yield g; // expected-error {{no matching member function for call to 'yield_value'}} } void z() { co_await a; -co_return g; // expected-error {{reference to overloaded function}} +co_return g; // expected-error {{address of overloaded function 'g' does not match required type 'int'}} + } + + void x(yield_fn_tag) { +co_await f; // expected-error {{reference to overloaded function}} + } + void y(yield_fn_tag) { +co_yield g; + } + void z(yield_fn_tag) { +co_await a; +co_return g; } } ___ cfe-commits mailing list cfe-commits@lists