r273651 - try to fix the MSVC build
Author: majnemer Date: Fri Jun 24 00:48:59 2016 New Revision: 273651 URL: http://llvm.org/viewvc/llvm-project?rev=273651=rev Log: try to fix the MSVC build Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=273651=273650=273651=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jun 24 00:48:59 2016 @@ -1831,8 +1831,9 @@ bool RecursiveASTVisitor::Trave // if the traverser is visiting implicit code. Parameter variable // declarations do not have valid TypeSourceInfo, so to visit them // we need to traverse the declarations explicitly. -for (ParmVarDecl *Parameter : D->parameters()) +for (ParmVarDecl *Parameter : D->parameters()) { TRY_TO(TraverseDecl(Parameter)); +} } if (CXXConstructorDecl *Ctor = dyn_cast(D)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21501: [Driver] Add support for Broadcom Vulcan core
pgode added a comment. Ping ? http://reviews.llvm.org/D21501 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273650 - Use even more ArrayRefs
Author: majnemer Date: Fri Jun 24 00:33:44 2016 New Revision: 273650 URL: http://llvm.org/viewvc/llvm-project?rev=273650=rev Log: Use even more ArrayRefs No functional change is intended, just a small refactoring. Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/Frontend/ASTConsumers.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=273650=273649=273650=diff == --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jun 24 00:33:44 2016 @@ -1429,9 +1429,8 @@ DEF_TRAVERSE_DECL(ObjCMethodDecl, { if (D->getReturnTypeSourceInfo()) { TRY_TO(TraverseTypeLoc(D->getReturnTypeSourceInfo()->getTypeLoc())); } - for (ObjCMethodDecl::param_iterator I = D->param_begin(), E = D->param_end(); - I != E; ++I) { -TRY_TO(TraverseDecl(*I)); + for (ParmVarDecl *Parameter : D->parameters()) { +TRY_TO(TraverseDecl(Parameter)); } if (D->isThisDeclarationADefinition()) { TRY_TO(TraverseStmt(D->getBody())); @@ -1832,10 +1831,8 @@ bool RecursiveASTVisitor::Trave // if the traverser is visiting implicit code. Parameter variable // declarations do not have valid TypeSourceInfo, so to visit them // we need to traverse the declarations explicitly. -for (FunctionDecl::param_const_iterator I = D->param_begin(), -E = D->param_end(); - I != E; ++I) - TRY_TO(TraverseDecl(*I)); +for (ParmVarDecl *Parameter : D->parameters()) + TRY_TO(TraverseDecl(Parameter)); } if (CXXConstructorDecl *Ctor = dyn_cast(D)) { Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=273650=273649=273650=diff == --- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original) +++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Fri Jun 24 00:33:44 2016 @@ -400,10 +400,10 @@ public: const FunctionDecl *FD) { if (!prototype->isVariadic()) return All; if (FD) - additional += std::count_if(FD->param_begin(), FD->param_end(), - [](const ParmVarDecl *PVD) { -return PVD->hasAttr(); - }); + additional += + llvm::count_if(FD->parameters(), [](const ParmVarDecl *PVD) { +return PVD->hasAttr(); + }); return RequiredArgs(prototype->getNumParams() + additional); } Modified: cfe/trunk/lib/AST/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=273650=273649=273650=diff == --- cfe/trunk/lib/AST/ASTDumper.cpp (original) +++ cfe/trunk/lib/AST/ASTDumper.cpp Fri Jun 24 00:33:44 2016 @@ -1154,10 +1154,8 @@ void ASTDumper::VisitFunctionDecl(const if (!D->param_begin() && D->getNumParams()) dumpChild([=] { OS << ">"; }); else -for (FunctionDecl::param_const_iterator I = D->param_begin(), -E = D->param_end(); - I != E; ++I) - dumpDecl(*I); +for (const ParmVarDecl *Parameter : D->parameters()) + dumpDecl(Parameter); if (const CXXConstructorDecl *C = dyn_cast(D)) for (CXXConstructorDecl::init_const_iterator I = C->init_begin(), @@ -1548,10 +1546,8 @@ void ASTDumper::VisitObjCMethodDecl(cons if (D->isThisDeclarationADefinition()) { dumpDeclContext(D); } else { -for (ObjCMethodDecl::param_const_iterator I = D->param_begin(), - E = D->param_end(); - I != E; ++I) - dumpDecl(*I); +for (const ParmVarDecl *Parameter : D->parameters()) + dumpDecl(Parameter); } if (D->isVariadic()) Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=273650=273649=273650=diff == --- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original) +++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Fri Jun 24 00:33:44 2016 @@ -290,13 +290,12 @@ void DeclContextPrinter::PrintDeclContex // Print the parameters. Out << "("; bool PrintComma = false; -for (FunctionDecl::param_const_iterator I = D->param_begin(), -
[PATCH] D21675: New ODR checker for modules
rtrieu created this revision. rtrieu added a subscriber: cfe-commits. Early prototype of an improved ODR checker for Clang and modules. The current ODR checking of classes is limited to a small number of attributes such as number of methods and base classes. This still allows a number of ODR violations to pass through undetected which only manifests as problems during linking. This improved ODR checker calculates a hash based on the class contents, then checks that the two decls have the same hash before allowing them to be merged. The test case shows a number of ODR violations that the current Clang checker would not have caught. The hashing relies on three visitors for Stmt's, Decl's, and Type's. For Stmt's, the visitor behind Stmt::Profile was refactored so that a hash could be generated without depending on pointers. For Decl's, a new DeclVisitor was created. The Type visitor has not been written yet. Instead, Types are converted into a string as a stand-in. The other area for improvement is the diagnostic message. Most have the default message stating the class has different definitions in different modules. New specific messages will need to be created to supplement the default message. http://reviews.llvm.org/D21675 Files: include/clang/AST/DeclCXX.h include/clang/AST/Stmt.h lib/AST/DeclCXX.cpp lib/AST/StmtProfile.cpp lib/Sema/SemaDecl.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriter.cpp test/Modules/Inputs/odr_hash/first.h test/Modules/Inputs/odr_hash/module.map test/Modules/Inputs/odr_hash/second.h test/Modules/merge-using-decls.cpp test/Modules/odr_hash.cpp Index: test/Modules/odr_hash.cpp === --- test/Modules/odr_hash.cpp +++ test/Modules/odr_hash.cpp @@ -0,0 +1,191 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/odr_hash -verify %s -std=c++11 + +#include "first.h" +#include "second.h" + +namespace test1 { +S1 s1; +// expected-error@first.h:* {{'S1' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S2 s2; +// expected-error@first.h:* {{'S2' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S3 s3; +// expected-error@first.h:* {{'S3' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S4 s4; +// expected-error@first.h:* {{'S4' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S5 s5; +// expected-error@first.h:* {{'S5' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S6 s6; +// expected-error@second.h:* {{'S6::Second' from module 'second' is not present in definition of 'S6' in module 'first'}} +// expected-note@first.h:* {{definition has no member 'Second'}} + +S7 s7; +// expected-error@second.h:* {{'S7::foo' from module 'second' is not present in definition of 'S7' in module 'first'}} +// expected-note@first.h:* {{declaration of 'foo' does not match}} + +S8 s8; +// expected-error@first.h:* {{'S8' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S9 s9; +// expected-error@first.h:* {{'S9' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S10 s10; +// expected-error@second.h:* {{'S10::(anonymous struct)::y' from module 'second' is not present in definition of 'S10::(anonymous struct at /usr/local/google/home/rtrieu/clang/miss/llvm/tools/clang/test/Modules/Inputs/odr_hash/first.h:42:3)' in module 'first'}} +// expected-note@first.h:* {{definition has no member 'y'}} + +// expected-error@first.h:* {{'S10' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S11 s11; +// expected-error@first.h:* {{'S11' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S12 s12; + +S13 s13; +// expected-error@first.h:* {{'S13' has different definitions in different modules; definition in module 'first' is here}} +// expected-note@second.h:* {{definition in module 'second' is here}} + +S14 s14; +// expected-error@second.h:* {{'S14::foo' from module 'second' is not present in definition of 'S14' in module 'first'}} +//
Re: r273602 - Implement p0292r2 (constexpr if), a likely C++1z feature.
On Thu, Jun 23, 2016 at 12:26 PM, Aaron Ballman via cfe-commits < cfe-commits@lists.llvm.org> wrote: > On Thu, Jun 23, 2016 at 3:16 PM, Richard Smith via cfe-commits >wrote: > > Author: rsmith > > Date: Thu Jun 23 14:16:49 2016 > > New Revision: 273602 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=273602=rev > > Log: > > Implement p0292r2 (constexpr if), a likely C++1z feature. > > Is there a feature testing macro for this, or is one not required (or > is one not determined by SG10 yet)? > The paper does not propose one. I expect we'll add one, though; I can imagine reasonable use cases where you'd want to make an 'if' constexpr if the feature is supported (and otherwise have a regular if). > ~Aaron > > > > > Added: > > cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp > > cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp > > cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp > > Modified: > > cfe/trunk/include/clang/AST/Stmt.h > > cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td > > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > cfe/trunk/include/clang/Sema/Sema.h > > cfe/trunk/lib/AST/ASTImporter.cpp > > cfe/trunk/lib/AST/Stmt.cpp > > cfe/trunk/lib/Analysis/BodyFarm.cpp > > cfe/trunk/lib/CodeGen/CGStmt.cpp > > cfe/trunk/lib/CodeGen/CodeGenFunction.cpp > > cfe/trunk/lib/CodeGen/CodeGenFunction.h > > cfe/trunk/lib/Parse/ParseStmt.cpp > > cfe/trunk/lib/Sema/JumpDiagnostics.cpp > > cfe/trunk/lib/Sema/SemaExpr.cpp > > cfe/trunk/lib/Sema/SemaExprCXX.cpp > > cfe/trunk/lib/Sema/SemaExprMember.cpp > > cfe/trunk/lib/Sema/SemaLambda.cpp > > cfe/trunk/lib/Sema/SemaStmt.cpp > > cfe/trunk/lib/Sema/TreeTransform.h > > cfe/trunk/lib/Serialization/ASTReaderStmt.cpp > > cfe/trunk/lib/Serialization/ASTWriterStmt.cpp > > cfe/trunk/www/cxx_status.html > > > > Modified: cfe/trunk/include/clang/AST/Stmt.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=273602=273601=273602=diff > > > == > > --- cfe/trunk/include/clang/AST/Stmt.h (original) > > +++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun 23 14:16:49 2016 > > @@ -93,6 +93,13 @@ protected: > > unsigned NumStmts : 32 - NumStmtBits; > >}; > > > > + class IfStmtBitfields { > > +friend class IfStmt; > > +unsigned : NumStmtBits; > > + > > +unsigned IsConstexpr : 1; > > + }; > > + > >class ExprBitfields { > > friend class Expr; > > friend class DeclRefExpr; // computeDependence > > @@ -248,6 +255,7 @@ protected: > >union { > > StmtBitfields StmtBits; > > CompoundStmtBitfields CompoundStmtBits; > > +IfStmtBitfields IfStmtBits; > > ExprBitfields ExprBits; > > CharacterLiteralBitfields CharacterLiteralBits; > > FloatingLiteralBitfields FloatingLiteralBits; > > @@ -878,7 +886,8 @@ class IfStmt : public Stmt { > >SourceLocation ElseLoc; > > > > public: > > - IfStmt(const ASTContext , SourceLocation IL, VarDecl *var, Expr > *cond, > > + IfStmt(const ASTContext , SourceLocation IL, > > + bool IsConstexpr, VarDecl *var, Expr *cond, > > Stmt *then, SourceLocation EL = SourceLocation(), > > Stmt *elsev = nullptr); > > > > @@ -918,6 +927,9 @@ public: > >SourceLocation getElseLoc() const { return ElseLoc; } > >void setElseLoc(SourceLocation L) { ElseLoc = L; } > > > > + bool isConstexpr() const { return IfStmtBits.IsConstexpr; } > > + void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } > > + > >SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; } > >SourceLocation getLocEnd() const LLVM_READONLY { > > if (SubExprs[ELSE]) > > > > Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=273602=273601=273602=diff > > > == > > --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) > > +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jun 23 > 14:16:49 2016 > > @@ -512,6 +512,11 @@ def err_function_is_not_record : Error< > >"unexpected %0 in function call; perhaps remove the %0?">; > > def err_super_in_using_declaration : Error< > >"'__super' cannot be used with a using declaration">; > > +def ext_constexpr_if : ExtWarn< > > + "constexpr if is a C++1z extension">, InGroup; > > +def warn_cxx14_compat_constexpr_if : Warning< > > + "constexpr if is incompatible with C++ standards before C++1z">, > > + DefaultIgnore, InGroup; > > > > // C++ derived classes > > def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">; > > > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > > URL: >
r273646 - Use the same underlying type for bitfields
Author: majnemer Date: Thu Jun 23 23:05:35 2016 New Revision: 273646 URL: http://llvm.org/viewvc/llvm-project?rev=273646=rev Log: Use the same underlying type for bitfields MSVC allocates fresh storage for consecutive bitfields with different underlying types. Modified: cfe/trunk/include/clang/AST/Attr.h cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/Driver/Driver.h cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Sema/Overload.h Modified: cfe/trunk/include/clang/AST/Attr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=273646=273645=273646=diff == --- cfe/trunk/include/clang/AST/Attr.h (original) +++ cfe/trunk/include/clang/AST/Attr.h Thu Jun 23 23:05:35 2016 @@ -51,11 +51,11 @@ protected: /// An index into the spelling list of an /// attribute defined in Attr.td file. unsigned SpellingListIndex : 4; - bool Inherited : 1; - bool IsPackExpansion : 1; - bool Implicit : 1; - bool IsLateParsed : 1; - bool DuplicatesAllowed : 1; + unsigned Inherited : 1; + unsigned IsPackExpansion : 1; + unsigned Implicit : 1; + unsigned IsLateParsed : 1; + unsigned DuplicatesAllowed : 1; void *operator new(size_t bytes) LLVM_NOEXCEPT { llvm_unreachable("Attrs cannot be allocated with regular 'new'."); Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=273646=273645=273646=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Thu Jun 23 23:05:35 2016 @@ -2270,7 +2270,7 @@ public: /// represent a member of a struct/union/class. class FieldDecl : public DeclaratorDecl, public Mergeable { // FIXME: This can be packed into the bitfields in Decl. - bool Mutable : 1; + unsigned Mutable : 1; mutable unsigned CachedFieldIndex : 31; /// The kinds of value we can store in InitializerOrBitWidth. @@ -2717,20 +2717,20 @@ private: /// IsCompleteDefinition - True if this is a definition ("struct foo /// {};"), false if it is a declaration ("struct foo;"). It is not /// a definition until the definition has been fully processed. - bool IsCompleteDefinition : 1; + unsigned IsCompleteDefinition : 1; protected: /// IsBeingDefined - True if this is currently being defined. - bool IsBeingDefined : 1; + unsigned IsBeingDefined : 1; private: /// IsEmbeddedInDeclarator - True if this tag declaration is /// "embedded" (i.e., defined or declared for the very first time) /// in the syntax of a declarator. - bool IsEmbeddedInDeclarator : 1; + unsigned IsEmbeddedInDeclarator : 1; /// \brief True if this tag is free standing, e.g. "struct foo;". - bool IsFreeStanding : 1; + unsigned IsFreeStanding : 1; protected: // These are used by (and only defined for) EnumDecl. @@ -2739,26 +2739,26 @@ protected: /// IsScoped - True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. - bool IsScoped : 1; + unsigned IsScoped : 1; /// IsScopedUsingClassTag - If this tag declaration is a scoped enum, /// then this is true if the scoped enum was declared using the class /// tag, false if it was declared with the struct tag. No meaning is /// associated if this tag declaration is not a scoped enum. - bool IsScopedUsingClassTag : 1; + unsigned IsScopedUsingClassTag : 1; /// IsFixed - True if this is an enumeration with fixed underlying type. Only /// possible in C++11, Microsoft extensions, or Objective C mode. - bool IsFixed : 1; + unsigned IsFixed : 1; /// \brief Indicates whether it is possible for declarations of this kind /// to have an out-of-date definition. /// /// This option is only enabled when modules are enabled. - bool MayHaveOutOfDateDef : 1; + unsigned MayHaveOutOfDateDef : 1; /// Has the full definition of this type been required by a use somewhere in /// the TU. - bool IsCompleteDefinitionRequired : 1; + unsigned IsCompleteDefinitionRequired : 1; private: SourceLocation RBraceLoc; Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=273646=273645=273646=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Jun 23 23:05:35 2016 @@ -165,13 +165,13 @@ class CXXBaseSpecifier { SourceLocation EllipsisLoc; /// \brief Whether this is a virtual base class or not. - bool Virtual : 1; + unsigned Virtual : 1; /// \brief Whether this is the base of a class (true) or of a struct (false). ///
r273647 - Use more ArrayRefs
Author: majnemer Date: Thu Jun 23 23:05:48 2016 New Revision: 273647 URL: http://llvm.org/viewvc/llvm-project?rev=273647=rev Log: Use more ArrayRefs No functional change is intended, just a small refactoring. Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/AST/DeclObjC.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTDumper.cpp cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/Comment.cpp cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/AST/DeclPrinter.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/Analysis/Consumed.cpp cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGObjCMac.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp cfe/trunk/lib/Frontend/ASTConsumers.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=273647=273646=273647=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Thu Jun 23 23:05:48 2016 @@ -1952,29 +1952,24 @@ public: unsigned getBuiltinID() const; - // Iterator access to formal parameters. - unsigned param_size() const { return getNumParams(); } - typedef ParmVarDecl **param_iterator; - typedef ParmVarDecl * const *param_const_iterator; - typedef llvm::iterator_range param_range; - typedef llvm::iterator_range param_const_range; - - param_iterator param_begin() { return param_iterator(ParamInfo); } - param_iterator param_end() { -return param_iterator(ParamInfo + param_size()); - } - param_range params() { return param_range(param_begin(), param_end()); } - - param_const_iterator param_begin() const { -return param_const_iterator(ParamInfo); - } - param_const_iterator param_end() const { -return param_const_iterator(ParamInfo + param_size()); + // ArrayRef interface to parameters. + ArrayRef parameters() const { +return {ParamInfo, getNumParams()}; } - param_const_range params() const { -return param_const_range(param_begin(), param_end()); + MutableArrayRef parameters() { +return {ParamInfo, getNumParams()}; } + // Iterator access to formal parameters. + typedef MutableArrayRef::iterator param_iterator; + typedef ArrayRef::const_iterator param_const_iterator; + bool param_empty() const { return parameters().empty(); } + param_iterator param_begin() { return parameters().begin(); } + param_iterator param_end() { return parameters().end(); } + param_const_iterator param_begin() const { return parameters().begin(); } + param_const_iterator param_end() const { return parameters().end(); } + size_t param_size() const { return parameters().size(); } + /// getNumParams - Return the number of parameters this function must have /// based on its FunctionType. This is the length of the ParamInfo array /// after it has been created. @@ -1992,12 +1987,6 @@ public: setParams(getASTContext(), NewParamInfo); } - // ArrayRef iterface to parameters. - // FIXME: Should one day replace iterator interface. - ArrayRefparameters() const { -return llvm::makeArrayRef(ParamInfo, getNumParams()); - } - ArrayRef getDeclsInPrototypeScope() const { return DeclsInPrototypeScope; } @@ -2504,34 +2493,33 @@ class IndirectFieldDecl : public ValueDe IndirectFieldDecl(ASTContext , DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, -NamedDecl **CH, unsigned CHS); +MutableArrayRef CH); public: static IndirectFieldDecl *Create(ASTContext , DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - QualType T, NamedDecl **CH, unsigned CHS); +
[PATCH] D21673: [libcxx] guard throw with exception enabling check
weimingz created this revision. weimingz added a subscriber: cfe-commits. this fixes build error when built with c++14 and no exceptions http://reviews.llvm.org/D21673 Files: include/experimental/optional Index: include/experimental/optional === --- include/experimental/optional +++ include/experimental/optional @@ -517,7 +517,11 @@ constexpr value_type const& value() const { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else +assert(!"bad optional access"); +#endif return this->__val_; } @@ -525,7 +529,11 @@ value_type& value() { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else +assert(!"bad optional access"); +#endif return this->__val_; } Index: include/experimental/optional === --- include/experimental/optional +++ include/experimental/optional @@ -517,7 +517,11 @@ constexpr value_type const& value() const { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else +assert(!"bad optional access"); +#endif return this->__val_; } @@ -525,7 +529,11 @@ value_type& value() { if (!this->__engaged_) +#ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); +#else +assert(!"bad optional access"); +#endif return this->__val_; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [gentoo-musl] Re: Add support for musl-libc on Linux
2016-06-22 16:55 GMT+08:00 Peter Smith: > Hello Lei, > > Thanks for all the updates. That looks good to me from an ARM perspective. Ping. Are the patches good enough to be committed? Lei ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21564: [OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'
ABataev added a comment. LG Comment at: lib/Sema/SemaOpenMP.cpp:1826-1827 @@ +1825,4 @@ +std::make_pair(".bound_tid.", KmpInt32PtrTy), +std::make_pair(".previous.lb.", KmpUInt64Ty), +std::make_pair(".previous.ub.", KmpUInt64Ty), +std::make_pair(StringRef(), QualType()) // __context with shared vars Just a small comment - I believe, it is better to use SizeTy, rather than KmpUInt64Ty. SizeTy is platform dependent and on 32 bit targets may result in more effective code. Repository: rL LLVM http://reviews.llvm.org/D21564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21564: [OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'
ABataev accepted this revision. ABataev added a comment. This revision is now accepted and ready to land. LG Repository: rL LLVM http://reviews.llvm.org/D21564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Fwd: Buildbot numbers for the last week of 6/12/2016 - 6/18/2016
Hello everyone, Below are some buildbot numbers for the last week of 6/12/2016 - 6/18/2016. Please see the same data in attached csv files: The longest time each builder was red during the last week; "Status change ratio" by active builder (percent of builds that changed the builder status from greed to red or from red to green); Count of commits by project; Number of completed builds, failed builds and average build time for successful builds per active builder; Average waiting time for a revision to get build result per active builder (response time); Thanks Galina The longest time each builder was red during the last week: buildername | was_red ---+--- libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11 | 77:19:45 sanitizer-windows | 64:33:03 clang-ppc64be-linux-multistage| 63:36:04 clang-3stage-ubuntu | 50:33:16 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 37:13:20 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 37:12:29 libcxx-libcxxabi-x86_64-linux-debian | 35:59:28 perf-x86_64-penryn-O3 | 33:55:39 sanitizer-x86_64-linux-fuzzer | 25:54:53 lldb-windows7-android | 23:28:39 clang-x64-ninja-win7 | 23:20:06 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only | 21:34:12 sanitizer-ppc64le-linux | 17:50:45 perf-x86_64-penryn-O3-polly | 16:10:25 clang-cmake-mipsel| 14:38:58 sanitizer-x86_64-linux-bootstrap | 13:03:49 perf-x86_64-penryn-O3-polly-unprofitable | 12:41:56 polly-amd64-linux | 12:28:35 clang-ppc64le-linux-multistage| 12:28:10 perf-x86_64-penryn-O3-polly-fast | 12:22:48 perf-x86_64-penryn-O3-polly-parallel-fast | 12:21:54 clang-native-aarch64-full | 10:11:10 clang-cmake-thumbv7-a15-full-sh | 07:00:56 clang-cmake-armv7-a15-selfhost| 06:45:33 lld-x86_64-win7 | 06:43:04 clang-x86-win2008-selfhost| 06:11:55 clang-sphinx-docs | 05:55:06 clang-ppc64le-linux-lnt | 05:16:48 clang-atom-d525-fedora-rel| 04:35:52 sanitizer-x86_64-linux-fast | 04:35:43 clang-cmake-mips | 04:26:54 clang-cmake-armv7-a15-full| 04:17:07 sanitizer-x86_64-linux-autoconf | 04:03:28 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian | 04:01:44 llvm-clang-lld-x86_64-debian-fast | 03:55:00 sanitizer-x86_64-linux| 03:50:31 clang-cmake-armv7-a15-selfhost-neon | 03:44:48 clang-cmake-thumbv7-a15 | 03:43:24 lldb-x86_64-ubuntu-14.04-cmake| 03:42:26 clang-cmake-aarch64-quick | 03:42:07 clang-cmake-armv7-a15 | 03:41:26 clang-cmake-aarch64-42vma | 03:36:25 clang-x86_64-linux-selfhost-modules | 03:28:11 lldb-x86_64-ubuntu-14.04-buildserver | 03:22:24 clang-s390x-linux | 03:16:36 clang-ppc64be-linux-lnt | 03:16:21 clang-ppc64be-linux | 03:15:32 clang-x86_64-debian-fast | 03:06:23 clang-cmake-aarch64-full | 03:03:15 clang-ppc64le-linux | 03:02:44 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 02:57:02 clang-cuda-build | 02:56:20 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11| 02:54:48 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 02:54:44 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z| 02:42:51 clang-native-arm-lnt | 02:38:46 llvm-mips-linux | 02:22:35 lldb-x86_64-darwin-13.4 | 02:04:39 lldb-x86_64-ubuntu-14.04-android | 01:49:47 sanitizer-ppc64be-linux | 01:47:19
[PATCH] D21667: [analyzer] Add rudimentary handling of AtomicExpr.
dcoughlin created this revision. dcoughlin added reviewers: zaks.anna, rsmith. dcoughlin added a subscriber: cfe-commits. This proposed patch adds crude handling of atomics to the static analyzer. Rather than ignore AtomicExprs, as we now do, this patch causes the analyzer to escape the arguments. This is imprecise -- and we should model the expressions fully in the future -- but it is less wrong than ignoring their effects altogether. Richard: Would you mind reviewing the changes I made to AtomicExpr in the AST? I had to add a const accessor for the subexpressions. Anna: Would you review the static analyzer portion? This is rdar://problem/25353187 http://reviews.llvm.org/D21667 Files: include/clang/AST/Expr.h include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h lib/StaticAnalyzer/Core/ExprEngine.cpp test/Analysis/atomics.c Index: test/Analysis/atomics.c === --- /dev/null +++ test/Analysis/atomics.c @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s + +// Tests for c11 atomics. Many of these tests currently yield unknown +// because we don't folly model the atomics and instead imprecisely +// treat their arguments as escaping. + +typedef unsigned int uint32_t; +typedef enum memory_order { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +void clang_analyzer_eval(int); + +struct RefCountedStruct { + uint32_t refCount; + void *ptr; +}; + +void test_atomic_fetch_add(struct RefCountedStruct *s) { + s->refCount = 1; + + uint32_t result = __c11_atomic_fetch_add((volatile _Atomic(uint32_t) *)>refCount,- 1, memory_order_relaxed); + + // When we model atomics fully this should (probably) be FALSE. It should never + // be TRUE (because the operation mutates the passed in storage). + clang_analyzer_eval(s->refCount == 1); // expected-warning {{UNKNOWN}} + + // When fully modeled this should be TRUE + clang_analyzer_eval(result == 1); // expected-warning {{UNKNOWN}} +} + +void test_atomic_load(struct RefCountedStruct *s) { + s->refCount = 1; + + uint32_t result = __c11_atomic_load((volatile _Atomic(uint32_t) *)>refCount, memory_order_relaxed); + + // When we model atomics fully this should (probably) be TRUE. + clang_analyzer_eval(s->refCount == 1); // expected-warning {{UNKNOWN}} + + // When fully modeled this should be TRUE + clang_analyzer_eval(result == 1); // expected-warning {{UNKNOWN}} +} + +void test_atomic_store(struct RefCountedStruct *s) { + s->refCount = 1; + + __c11_atomic_store((volatile _Atomic(uint32_t) *)>refCount, 2, memory_order_relaxed); + + // When we model atomics fully this should (probably) be FALSE. It should never + // be TRUE (because the operation mutates the passed in storage). + clang_analyzer_eval(s->refCount == 1); // expected-warning {{UNKNOWN}} +} + +void test_atomic_exchange(struct RefCountedStruct *s) { + s->refCount = 1; + + uint32_t result = __c11_atomic_exchange((volatile _Atomic(uint32_t) *)>refCount, 2, memory_order_relaxed); + + // When we model atomics fully this should (probably) be FALSE. It should never + // be TRUE (because the operation mutates the passed in storage). + clang_analyzer_eval(s->refCount == 1); // expected-warning {{UNKNOWN}} + + // When fully modeled this should be TRUE + clang_analyzer_eval(result == 1); // expected-warning {{UNKNOWN}} +} + + +void test_atomic_compare_exchange_strong(struct RefCountedStruct *s) { + s->refCount = 1; + uint32_t expected = 2; + uint32_t desired = 3; + _Bool result = __c11_atomic_compare_exchange_strong((volatile _Atomic(uint32_t) *)>refCount, , desired, memory_order_relaxed, memory_order_relaxed); + + // For now we expect both expected and refCount to be invalidated by the + // call. In the future we should model more precisely. + clang_analyzer_eval(s->refCount == 3); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(expected == 2); // expected-warning {{UNKNOWN}} +} + +void test_atomic_compare_exchange_weak(struct RefCountedStruct *s) { + s->refCount = 1; + uint32_t expected = 2; + uint32_t desired = 3; + _Bool result = __c11_atomic_compare_exchange_weak((volatile _Atomic(uint32_t) *)>refCount, , desired, memory_order_relaxed, memory_order_relaxed); + + // For now we expect both expected and refCount to be invalidated by the + // call. In the future we should model more precisely. + clang_analyzer_eval(s->refCount == 3); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(expected == 2); // expected-warning {{UNKNOWN}} +} Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++
Re: [PATCH] D21453: Add support for attribute "overallocated"
ahatanak updated this revision to Diff 61743. ahatanak added a comment. Address review comments and change the wording in AttrDocs.td to explain what the attribute means and how it is used. Also, fixed the code in VisitMemberExpr to set LValue::OverAllocated before the base class of the member expression is visited. This change was needed because the base class of the innermost MemberExpr has to be examined to see whether the member belongs to an overallocated class. Without this change, the last check in test/CodeGen/object-size.c fails. http://reviews.llvm.org/D21453 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td lib/AST/ExprConstant.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGen/object-size.c test/CodeGen/object-size.cpp Index: test/CodeGen/object-size.cpp === --- test/CodeGen/object-size.cpp +++ test/CodeGen/object-size.cpp @@ -62,3 +62,29 @@ // CHECK: store i32 16 gi = __builtin_object_size(>bs[0].buf[0], 3); } + +struct S0 { + int a[16], b[16]; +} __attribute__((overallocated)); + +struct S1 : S0 { +}; + +struct S2 : S1 { +} __attribute__((overallocated)); + +// CHECK-LABEL: define void @_Z5test3v() +void test3() { + struct S0 *s0; + struct S1 *s1; + struct S2 *s2; + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(s0->b, 1); + + // CHECK: store i32 64, i32* @gi + gi = __builtin_object_size(s1->b, 1); + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(s2->b, 1); +} Index: test/CodeGen/object-size.c === --- test/CodeGen/object-size.c +++ test/CodeGen/object-size.c @@ -517,3 +517,52 @@ // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) gi = __builtin_object_size([9].snd[0], 1); } + +union U0 { + int a[16], b[16]; +} __attribute__((overallocated)); + +struct S0 { + int a[16], b[16]; +}; + +struct S1 { + int a[16], b[16]; +} __attribute__((overallocated)); + +struct S2 { + int a[16], b[16]; + struct S1 s1; + struct S0 s0; +} __attribute__((overallocated)); + +// CHECK-LABEL: @test32 +void test32() { + union U0 *u0; + struct S1 *s1; + struct S2 *s2; + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(u0->a, 1); + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(u0->b, 1); + + // CHECK: store i32 64, i32* @gi + gi = __builtin_object_size(s1->a, 1); + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(s1->b, 1); + + // CHECK: store i32 64, i32* @gi + gi = __builtin_object_size(s2->b, 1); + + // CHECK: store i32 64, i32* @gi + gi = __builtin_object_size(s2->s1.b, 1); + + // CHECK: store i32 128, i32* @gi + gi = __builtin_object_size(>s0, 1); + + // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false) + gi = __builtin_object_size(s2->s0.b, 1); +} Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -5394,6 +5394,9 @@ case AttributeList::AT_X86ForceAlignArgPointer: handleX86ForceAlignArgPointerAttr(S, D, Attr); break; + case AttributeList::AT_OverAllocated: +handleSimpleAttribute(S, D, Attr); +break; case AttributeList::AT_DLLExport: case AttributeList::AT_DLLImport: handleDLLAttr(S, D, Attr); Index: lib/AST/ExprConstant.cpp === --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -1049,7 +1049,12 @@ APValue::LValueBase Base; CharUnits Offset; bool InvalidBase : 1; -unsigned CallIndex : 31; + +// Indicates the enclosing struct is marked overallocated. This is used in +// computation of __builtin_object_size. +bool OverAllocated : 1; + +unsigned CallIndex : 30; SubobjectDesignator Designator; const APValue::LValueBase getLValueBase() const { return Base; } @@ -1059,6 +1064,8 @@ SubobjectDesignator () { return Designator; } const SubobjectDesignator () const { return Designator;} +LValue() : OverAllocated(false) {} + void moveInto(APValue ) const { if (Designator.Invalid) V = APValue(Base, Offset, APValue::NoLValuePath(), CallIndex); @@ -4559,19 +4566,34 @@ bool VisitMemberExpr(const MemberExpr *E) { // Handle non-static data members. + +// Check to see if the record is marked overallocated. +auto IsOverAllocated = [](QualType RT, const MemberExpr *ME) { + const TagDecl *TD = RT->getAsTagDecl(); + + if (isa(TD)) +TD = ME->getBase()->getBestDynamicClassType(); + + return TD->hasAttr(); +}; + QualType BaseTy; bool EvalOK; if (E->isArrow()) { - EvalOK =
[PATCH] D21666: [Tooling] Add optional argument to getFullyQualifiedName to prepend "::".
sivachandra created this revision. sivachandra added reviewers: rnk, saugustine. sivachandra added a subscriber: cfe-commits. Herald added a subscriber: klimek. http://reviews.llvm.org/D21666 Files: include/clang/AST/NestedNameSpecifier.h include/clang/Tooling/Core/QualTypeNames.h lib/AST/NestedNameSpecifier.cpp lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp === --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -14,6 +14,7 @@ namespace { struct TypeNameVisitor : TestVisitor { llvm::StringMap ExpectedQualTypeNames; + bool WithGlobalNsPrefix = false; // ValueDecls are the least-derived decl with both a qualtype and a // name. @@ -26,7 +27,8 @@ ExpectedQualTypeNames.lookup(VD->getNameAsString()); if (ExpectedName != "") { std::string ActualName = - TypeName::getFullyQualifiedName(VD->getType(), *Context); + TypeName::getFullyQualifiedName(VD->getType(), *Context, + WithGlobalNsPrefix); if (ExpectedName != ActualName) { // A custom message makes it much easier to see what declaration // failed compared to EXPECT_EQ. @@ -179,6 +181,27 @@ " TX CheckTX;" " struct A { typedef int X; };" "}"); + + TypeNameVisitor GlobalNsPrefix; + GlobalNsPrefix.WithGlobalNsPrefix = true; + GlobalNsPrefix.ExpectedQualTypeNames["IntVal"] = "int"; + GlobalNsPrefix.ExpectedQualTypeNames["BoolVal"] = "bool"; + GlobalNsPrefix.ExpectedQualTypeNames["XVal"] = "::A::B::X"; + GlobalNsPrefix.ExpectedQualTypeNames["IntAliasVal"] = "::A::B::Alias"; + GlobalNsPrefix.runOver( + "namespace A {" + " namespace B {" + "int IntVal;" + "bool BoolVal;" + "struct X {};" + "X XVal;" + "template class CCC { };" + "template \n" + "using Alias = CCC;\n" + "Alias IntAliasVal;\n" + " }" + "}" + ); } } // end anonymous namespace Index: lib/Tooling/Core/QualTypeNames.cpp === --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -30,7 +30,8 @@ /// \param[in] QT - the type for which the fully qualified type will be /// returned. /// \param[in] Ctx - the ASTContext to be used. -static QualType getFullyQualifiedType(QualType QT, const ASTContext ); +static QualType getFullyQualifiedType(QualType QT, const ASTContext , + bool WithGlobalNsPrefix); /// \brief Create a NestedNameSpecifier for Namesp and its enclosing /// scopes. @@ -90,7 +91,8 @@ } static bool getFullyQualifiedTemplateArgument(const ASTContext , - TemplateArgument ) { + TemplateArgument , + bool WithGlobalNsPrefix) { bool Changed = false; // Note: we do not handle TemplateArgument::Expression, to replace it @@ -105,7 +107,7 @@ } else if (Arg.getKind() == TemplateArgument::Type) { QualType SubTy = Arg.getAsType(); // Check if the type needs more desugaring and recurse. -QualType QTFQ = getFullyQualifiedType(SubTy, Ctx); +QualType QTFQ = getFullyQualifiedType(SubTy, Ctx, WithGlobalNsPrefix); if (QTFQ != SubTy) { Arg = TemplateArgument(QTFQ); Changed = true; @@ -115,7 +117,8 @@ } static const Type *getFullyQualifiedTemplateType(const ASTContext , - const Type *TypePtr) { + const Type *TypePtr, + bool WithGlobalNsPrefix) { // DependentTemplateTypes exist within template declarations and // definitions. Therefore we shouldn't encounter them at the end of // a translation unit. If we do, the caller has made an error. @@ -130,7 +133,8 @@ // Cheap to copy and potentially modified by // getFullyQualifedTemplateArgument. TemplateArgument Arg(*I); - MightHaveChanged |= getFullyQualifiedTemplateArgument(Ctx, Arg); + MightHaveChanged |= getFullyQualifiedTemplateArgument( + Ctx, Arg, WithGlobalNsPrefix); FQArgs.push_back(Arg); } @@ -160,7 +164,8 @@ // cheap to copy and potentially modified by // getFullyQualifedTemplateArgument TemplateArgument Arg(TemplateArgs[I]); -MightHaveChanged |= getFullyQualifiedTemplateArgument(Ctx, Arg); +MightHaveChanged |= getFullyQualifiedTemplateArgument( +Ctx, Arg, WithGlobalNsPrefix); FQArgs.push_back(Arg); } @@ -337,13 +342,14 @@ /// \brief Return the fully qualified type, including fully-qualified /// versions of any template parameters. -QualType
r273624 - Parser::ParseCXXCondition(): Prune \param in r273548 [-Wdocumentation]
Author: chapuni Date: Thu Jun 23 17:47:59 2016 New Revision: 273624 URL: http://llvm.org/viewvc/llvm-project?rev=273624=rev Log: Parser::ParseCXXCondition(): Prune \param in r273548 [-Wdocumentation] Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=273624=273623=273624=diff == --- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original) +++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu Jun 23 17:47:59 2016 @@ -1729,9 +1729,6 @@ Parser::ParseCXXTypeConstructExpression( /// \param Loc The location of the start of the statement that requires this /// condition, e.g., the "for" in a for loop. /// -/// \param ConvertToBoolean Whether the condition expression should be -/// converted to a boolean value. -/// /// \returns The parsed condition. Sema::ConditionResult Parser::ParseCXXCondition(SourceLocation Loc, Sema::ConditionKind CK) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21658: clang-format: [JS] handle conditionals in fields, default params.
This revision was automatically updated to reflect the committed changes. Closed by commit rL273619: clang-format: [JS] handle conditionals in fields, default params. (authored by mprobst). Changed prior to commit: http://reviews.llvm.org/D21658?vs=61726=61729#toc Repository: rL LLVM http://reviews.llvm.org/D21658 Files: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -639,7 +639,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -1009,7 +1009,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1253,7 +1253,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1350,5 +1349,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -639,7 +639,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -1009,7 +1009,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1253,7 +1253,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1350,5 +1349,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273619 - clang-format: [JS] handle conditionals in fields, default params.
Author: mprobst Date: Thu Jun 23 16:51:49 2016 New Revision: 273619 URL: http://llvm.org/viewvc/llvm-project?rev=273619=rev Log: clang-format: [JS] handle conditionals in fields, default params. Summary: Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21658 Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=273619=273618=273619=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jun 23 16:51:49 2016 @@ -639,7 +639,7 @@ private: } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -1009,7 +1009,7 @@ private: Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=273619=273618=273619=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Jun 23 16:51:49 2016 @@ -1253,7 +1253,6 @@ TEST_F(FormatTestJS, OptionalTypes) { verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1350,5 +1349,14 @@ TEST_F(FormatTestJS, NonNullAssertionOpe verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21658: clang-format: [JS] handle conditionals in fields, default params.
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good except that the patch description can now be updated. http://reviews.llvm.org/D21658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21658: clang-format: [JS] handle conditionals in fields, default params.
mprobst updated this revision to Diff 61726. mprobst added a comment. ok http://reviews.llvm.org/D21658 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1247,7 +1247,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1344,5 +1343,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -631,7 +631,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -998,7 +998,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1247,7 +1247,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1344,5 +1343,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x ? 1 : 2;"); + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -631,7 +631,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -998,7 +998,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + Line.MustBeDeclaration && !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21658: clang-format: [JS] handle conditionals in fields, default params.
djasper added inline comments. Comment at: lib/Format/TokenAnnotator.cpp:1001 @@ -1000,3 +1000,3 @@ if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method Well, if you keep the Line.MustBeDeclaration here, then the test case does not regress. I believe that the test in itself probably doesn't make much sense, but at least then we aren't regressing it. At any rate, it seems bad to keep the Line.MustBeDeclaration above and remove it here. http://reviews.llvm.org/D21658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21659: AMDGPU: Add builtin to read exec mask
arsenm created this revision. arsenm added a subscriber: cfe-commits. Herald added a reviewer: tstellarAMD. Herald added a subscriber: kzhuravl. http://reviews.llvm.org/D21659 Files: include/clang/Basic/BuiltinsAMDGPU.def lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/builtins-amdgcn.cl Index: test/CodeGenOpenCL/builtins-amdgcn.cl === --- test/CodeGenOpenCL/builtins-amdgcn.cl +++ test/CodeGenOpenCL/builtins-amdgcn.cl @@ -253,6 +253,14 @@ *out = __builtin_amdgcn_cubema(a, b, c); } +// CHECK-LABEL: @test_read_exec( +// CHECK: call i64 @llvm.read_register.i64(metadata ![[EXEC:[0-9]+]]) #[[READ_EXEC_ATTRS:[0-9]+]] +void test_read_exec(global ulong* out) { + *out = __builtin_amdgcn_read_exec(); +} + +// CHECK: declare i64 @llvm.read_register.i64(metadata) #[[NOUNWIND_READONLY:[0-9]+]] + // Legacy intrinsics with AMDGPU prefix // CHECK-LABEL: @test_legacy_rsq_f32 @@ -282,3 +290,7 @@ { *out = __builtin_amdgpu_ldexp(a, b); } + +// CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly } +// CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent } +// CHECK: ![[EXEC]] = !{!"exec"} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -3650,17 +3650,21 @@ static Value *EmitSpecialRegisterBuiltin(CodeGenFunction , const CallExpr *E, llvm::Type *RegisterType, - llvm::Type *ValueType, bool IsRead) { + llvm::Type *ValueType, + bool IsRead, + StringRef SysReg = "") { // write and register intrinsics only support 32 and 64 bit operations. assert((RegisterType->isIntegerTy(32) || RegisterType->isIntegerTy(64)) && "Unsupported size for register."); CodeGen::CGBuilderTy = CGF.Builder; CodeGen::CodeGenModule = CGF.CGM; LLVMContext = CGM.getLLVMContext(); - const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts(); - StringRef SysReg = cast(SysRegStrExpr)->getString(); + if (SysReg.empty()) { +const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts(); +SysReg = cast(SysRegStrExpr)->getString(); + } llvm::Metadata *Ops[] = { llvm::MDString::get(Context, SysReg) }; llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops); @@ -7413,7 +7417,13 @@ case AMDGPU::BI__builtin_amdgcn_classf: return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_class); -// Legacy amdgpu prefix + case AMDGPU::BI__builtin_amdgcn_read_exec: { +CallInst *CI = cast( + EmitSpecialRegisterBuiltin(*this, E, Int64Ty, Int64Ty, true, "exec")); +CI->setConvergent(); +return CI; + } + // Legacy amdgpu prefix case AMDGPU::BI__builtin_amdgpu_rsq: case AMDGPU::BI__builtin_amdgpu_rsqf: { if (getTarget().getTriple().getArch() == Triple::amdgcn) Index: include/clang/Basic/BuiltinsAMDGPU.def === --- include/clang/Basic/BuiltinsAMDGPU.def +++ include/clang/Basic/BuiltinsAMDGPU.def @@ -18,6 +18,9 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif +//===--===// +// Instruction builtins. +//===--===// BUILTIN(__builtin_amdgcn_s_barrier, "v", "n") BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n") BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n") @@ -60,6 +63,11 @@ TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime") //===--===// +// Special builtins. +//===--===// +BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc") + +//===--===// // Legacy names with amdgpu prefix //===--===// Index: test/CodeGenOpenCL/builtins-amdgcn.cl === --- test/CodeGenOpenCL/builtins-amdgcn.cl +++ test/CodeGenOpenCL/builtins-amdgcn.cl @@ -253,6 +253,14 @@ *out = __builtin_amdgcn_cubema(a, b, c); } +// CHECK-LABEL: @test_read_exec( +// CHECK: call i64 @llvm.read_register.i64(metadata ![[EXEC:[0-9]+]]) #[[READ_EXEC_ATTRS:[0-9]+]] +void test_read_exec(global ulong* out) { + *out = __builtin_amdgcn_read_exec(); +} + +// CHECK: declare i64 @llvm.read_register.i64(metadata) #[[NOUNWIND_READONLY:[0-9]+]] + // Legacy intrinsics with AMDGPU prefix // CHECK-LABEL: @test_legacy_rsq_f32 @@ -282,3 +290,7 @@ { *out = __builtin_amdgpu_ldexp(a,
[PATCH] D21658: clang-format: [JS] handle conditionals in fields, default params.
mprobst created this revision. mprobst added a reviewer: djasper. mprobst added a subscriber: cfe-commits. Herald added a subscriber: klimek. This causes a regression for top level ternary expressions, but that's deemed acceptable, as those really should be very rare. http://reviews.llvm.org/D21658 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1247,7 +1247,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1344,5 +1343,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x? 1 : 2;"); // Known issue: top level expression not detected. + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -631,7 +631,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -998,7 +998,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1247,7 +1247,6 @@ verifyFormat("interface X {\n" " y?(): z;\n" "}"); - verifyFormat("x ? 1 : 2;"); verifyFormat("constructor({aa}: {\n" " aa?: string,\n" " ?: string,\n" @@ -1344,5 +1343,14 @@ verifyFormat("let x = {foo: 1}!;\n"); } +TEST_F(FormatTestJS, Conditional) { + verifyFormat("y = x ? 1 : 2;"); + verifyFormat("x? 1 : 2;"); // Known issue: top level expression not detected. + verifyFormat("class Foo {\n" + " field = true ? 1 : 2;\n" + " method(a = true ? 1 : 2) {}\n" + "}"); +} + } // end namespace tooling } // end namespace clang Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -631,7 +631,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && + if (Line.MustBeDeclaration && !Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); @@ -998,7 +998,7 @@ Current.Type = TT_UnaryOperator; } else if (Current.is(tok::question)) { if (Style.Language == FormatStyle::LK_JavaScript && - Line.MustBeDeclaration) { + !Contexts.back().IsExpression) { // In JavaScript, `interface X { foo?(): bar; }` is an optional method // on the interface, not a ternary expression. Current.Type = TT_JsTypeOptionalQuestion; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273606 - Invoke simplifycfg and sroa before instcombine.
Author: dehao Date: Thu Jun 23 15:13:10 2016 New Revision: 273606 URL: http://llvm.org/viewvc/llvm-project?rev=273606=rev Log: Invoke simplifycfg and sroa before instcombine. Summary: InstCombine needs to be performed after simplifycfg and sroa, otherwise it may make bad optimization decisions. Reviewers: davidxl, wmi, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21568 Added: cfe/trunk/test/CodeGen/pgo-sample-preparation.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/test/CodeGen/pgo-sample.c Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=273606=273605=273606=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jun 23 15:13:10 2016 @@ -178,8 +178,14 @@ static void addAddDiscriminatorsPass(con PM.add(createAddDiscriminatorsPass()); } -static void addInstructionCombiningPass(const PassManagerBuilder , -legacy::PassManagerBase ) { +static void addCleanupPassesForSampleProfiler( +const PassManagerBuilder , legacy::PassManagerBase ) { + // instcombine is needed before sample profile annotation because it converts + // certain function calls to be inlinable. simplifycfg and sroa are needed + // before instcombine for necessary preparation. E.g. load store is eliminated + // properly so that instcombine will not introduce unecessary liverange. + PM.add(createCFGSimplificationPass()); + PM.add(createSROAPass()); PM.add(createInstructionCombiningPass()); } @@ -492,7 +498,7 @@ void EmitAssemblyHelper::CreatePasses(Mo MPM->add(createPruneEHPass()); MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile)); PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, - addInstructionCombiningPass); + addCleanupPassesForSampleProfiler); } PMBuilder.populateFunctionPassManager(*FPM); Added: cfe/trunk/test/CodeGen/pgo-sample-preparation.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample-preparation.c?rev=273606=auto == --- cfe/trunk/test/CodeGen/pgo-sample-preparation.c (added) +++ cfe/trunk/test/CodeGen/pgo-sample-preparation.c Thu Jun 23 15:13:10 2016 @@ -0,0 +1,16 @@ +// Test if PGO sample use preparation passes are executed correctly. +// +// Ensure that instcombine is executed after simplifycfg and sroa so that +// "a < 255" will not be converted to a * 256 < 255 * 256. +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - 2>&1 | FileCheck %s + +void bar(int); +void foo(int x, int y, int z) { + int m; + for (m = 0; m < x ; m++) { +int a = (((y >> 8) & 0xff) * z) / 256; +bar(a < 255 ? a : 255); + } +} + +// CHECK-NOT: icmp slt i32 %mul, 65280 Modified: cfe/trunk/test/CodeGen/pgo-sample.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample.c?rev=273606=273605=273606=diff == --- cfe/trunk/test/CodeGen/pgo-sample.c (original) +++ cfe/trunk/test/CodeGen/pgo-sample.c Thu Jun 23 15:13:10 2016 @@ -2,5 +2,8 @@ // // Ensure Pass PGOInstrumentationGenPass is invoked. // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s +// CHECK: Simplify the CFG +// CHECK: SROA +// CHECK: Combine redundant instructions // CHECK: Remove unused exception handling info // CHECK: Sample profile pass ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer
yaxunl added inline comments. Comment at: include/clang/AST/BuiltinTypes.def:164 @@ +163,3 @@ +// Internal OpenCL sampler initializer type. +BUILTIN_TYPE(OCLSamplerInit, OCLSamplerInitTy) + Anastasia wrote: > I can't get why is this necessary to represent initializer as a special Clang > type? Could we avoid this additional complexity? If we don't change the type in AST, we need to translate the sampler type in AST to different types based on whether the entry is a variable or a function argument. This needs some ugly hacking of the codegen. Comment at: include/clang/AST/OperationKinds.def:328 @@ +327,3 @@ +// Convert an integer initializer to an OpenCL sampler initializer. +CAST_OPERATION(IntToOCLSamplerInitializer) + Anastasia wrote: > Could we just have only int->sampler conversion? Without having an extra type > for initializer? If we don't insert the sampler initializer to sampler cast in AST, when we want to insert the function call __translate_sampler_initializer in codegen, we have to hacking the generic translation of function call instruction and other instructions which may have a sampler variable as operand to insert the function call, which would be ugly. Or we could do a post-processing of the llvm module at the end of codegen to insert the function calls, if this approach is acceptable. Comment at: include/clang/Basic/DiagnosticGroups.td:876 @@ +875,3 @@ +// A warning group for warnings about code that clang accepts when +// compiling OpenCL C/C++ but which is not compatible with the SPIR spec. +def SpirCompat : DiagGroup<"spir-compat">; Anastasia wrote: > I don't understand the description really? Why not compatible? e.g. the sampler constant may take some literal value which is not compatible with SPIR/SPIR-V spec. A warning will be emitted. Such warning msg belongs to this category. Comment at: include/clang/Driver/CC1Options.td:690 @@ -689,1 +689,3 @@ HelpText<"OpenCL only. Allow denormals to be flushed to zero">; +def cl_sampler_type : Separate<["-"], "cl-sampler-type">, + HelpText<"OpenCL only. Specify type of sampler to emit. Valid values: \"opaque\"(default), \"i32\"">; Anastasia wrote: > Any reason to have this flag and support different sampler representations in > Clang? Give user some time for transition. Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:52 @@ +51,3 @@ + return llvm::PointerType::get(llvm::StructType::create( + Ctx, "__sampler"), + CGM.getContext().getTargetAddressSpace( Anastasia wrote: > Could you please keep coherency in type naming i.e. add "opencl." prefix. We need to be able to implement function __sampler* __translate_sampler_initializer(__sampler_initializer*); in library, where `__sampler` and `__sampler_initializer` are concrete struct types defined in the library source code. Therefore we cannot have dot in the struct type name. http://reviews.llvm.org/D21567 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21597: clang-format: [JS] recognize more type locations.
This revision was automatically updated to reflect the committed changes. Closed by commit rL273603: clang-format: [JS] recognize more type locations. (authored by mprobst). Changed prior to commit: http://reviews.llvm.org/D21597?vs=61706=61711#toc Repository: rL LLVM http://reviews.llvm.org/D21597 Files: cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -134,6 +134,10 @@ if (Left->is(TT_OverloadedOperatorLParen)) { Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) { + // type X = (...); + Contexts.back().IsExpression = false; } else if (Left->Previous && (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype, tok::kw_if, tok::kw_while, tok::l_paren, @@ -147,6 +151,10 @@ Keywords.kw_function { // function(...) or function f(...) Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); + Contexts.back().IsExpression = false; } else if (Left->Previous && Left->Previous->is(tok::r_square) && Left->Previous->MatchingParen && Left->Previous->MatchingParen->is(TT_LambdaLSquare)) { @@ -913,6 +921,9 @@ void modifyContext(const FormatToken ) { if (Current.getPrecedence() == prec::Assignment && !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) && +// Type aliases use `type X = ...;` in TypeScript. +!(Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) && (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) { Contexts.back().IsExpression = true; if (!Line.startsWith(TT_UnaryOperator)) { Index: cfe/trunk/lib/Format/FormatToken.h === --- cfe/trunk/lib/Format/FormatToken.h +++ cfe/trunk/lib/Format/FormatToken.h @@ -586,6 +586,7 @@ kw_import = ("import"); kw_is = ("is"); kw_let = ("let"); +kw_type = ("type"); kw_var = ("var"); kw_yield = ("yield"); @@ -637,6 +638,7 @@ IdentifierInfo *kw_import; IdentifierInfo *kw_is; IdentifierInfo *kw_let; + IdentifierInfo *kw_type; IdentifierInfo *kw_var; IdentifierInfo *kw_yield; Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -914,6 +914,12 @@ verifyFormat("function(x: A|B = A | B): C {}"); verifyFormat("function x(path: number|string) {}"); verifyFormat("function x(): string|number {}"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = (Bar|Baz);"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: (Foo|Bar)[];"); } TEST_F(FormatTestJS, ClassDeclarations) { Index: cfe/trunk/lib/Format/TokenAnnotator.cpp === --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -134,6 +134,10 @@ if (Left->is(TT_OverloadedOperatorLParen)) { Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) { + // type X = (...); + Contexts.back().IsExpression = false; } else if (Left->Previous && (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype, tok::kw_if, tok::kw_while, tok::l_paren, @@ -147,6 +151,10 @@ Keywords.kw_function { // function(...) or function f(...) Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); + Contexts.back().IsExpression = false; } else if (Left->Previous && Left->Previous->is(tok::r_square) && Left->Previous->MatchingParen && Left->Previous->MatchingParen->is(TT_LambdaLSquare)) { @@ -913,6 +921,9 @@ void modifyContext(const FormatToken ) { if (Current.getPrecedence() == prec::Assignment && !Line.First->isOneOf(tok::kw_template, tok::kw_using,
r273603 - clang-format: [JS] recognize more type locations.
Author: mprobst Date: Thu Jun 23 14:52:32 2016 New Revision: 273603 URL: http://llvm.org/viewvc/llvm-project?rev=273603=rev Log: clang-format: [JS] recognize more type locations. Summary: Includes parenthesized type expressions and type aliases. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21597 Modified: cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/FormatToken.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=273603=273602=273603=diff == --- cfe/trunk/lib/Format/FormatToken.h (original) +++ cfe/trunk/lib/Format/FormatToken.h Thu Jun 23 14:52:32 2016 @@ -586,6 +586,7 @@ struct AdditionalKeywords { kw_import = ("import"); kw_is = ("is"); kw_let = ("let"); +kw_type = ("type"); kw_var = ("var"); kw_yield = ("yield"); @@ -637,6 +638,7 @@ struct AdditionalKeywords { IdentifierInfo *kw_import; IdentifierInfo *kw_is; IdentifierInfo *kw_let; + IdentifierInfo *kw_type; IdentifierInfo *kw_var; IdentifierInfo *kw_yield; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=273603=273602=273603=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jun 23 14:52:32 2016 @@ -134,6 +134,10 @@ private: if (Left->is(TT_OverloadedOperatorLParen)) { Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) { + // type X = (...); + Contexts.back().IsExpression = false; } else if (Left->Previous && (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype, tok::kw_if, tok::kw_while, tok::l_paren, @@ -147,6 +151,10 @@ private: Keywords.kw_function { // function(...) or function f(...) Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); + Contexts.back().IsExpression = false; } else if (Left->Previous && Left->Previous->is(tok::r_square) && Left->Previous->MatchingParen && Left->Previous->MatchingParen->is(TT_LambdaLSquare)) { @@ -913,6 +921,9 @@ private: void modifyContext(const FormatToken ) { if (Current.getPrecedence() == prec::Assignment && !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) && +// Type aliases use `type X = ...;` in TypeScript. +!(Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) && (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) { Contexts.back().IsExpression = true; if (!Line.startsWith(TT_UnaryOperator)) { Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=273603=273602=273603=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Jun 23 14:52:32 2016 @@ -914,6 +914,12 @@ TEST_F(FormatTestJS, UnionIntersectionTy verifyFormat("function(x: A|B = A | B): C {}"); verifyFormat("function x(path: number|string) {}"); verifyFormat("function x(): string|number {}"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = (Bar|Baz);"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: (Foo|Bar)[];"); } TEST_F(FormatTestJS, ClassDeclarations) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r273602 - Implement p0292r2 (constexpr if), a likely C++1z feature.
On Thu, Jun 23, 2016 at 3:16 PM, Richard Smith via cfe-commitswrote: > Author: rsmith > Date: Thu Jun 23 14:16:49 2016 > New Revision: 273602 > > URL: http://llvm.org/viewvc/llvm-project?rev=273602=rev > Log: > Implement p0292r2 (constexpr if), a likely C++1z feature. Is there a feature testing macro for this, or is one not required (or is one not determined by SG10 yet)? ~Aaron > > Added: > cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp > cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp > cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp > Modified: > cfe/trunk/include/clang/AST/Stmt.h > cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td > cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > cfe/trunk/include/clang/Sema/Sema.h > cfe/trunk/lib/AST/ASTImporter.cpp > cfe/trunk/lib/AST/Stmt.cpp > cfe/trunk/lib/Analysis/BodyFarm.cpp > cfe/trunk/lib/CodeGen/CGStmt.cpp > cfe/trunk/lib/CodeGen/CodeGenFunction.cpp > cfe/trunk/lib/CodeGen/CodeGenFunction.h > cfe/trunk/lib/Parse/ParseStmt.cpp > cfe/trunk/lib/Sema/JumpDiagnostics.cpp > cfe/trunk/lib/Sema/SemaExpr.cpp > cfe/trunk/lib/Sema/SemaExprCXX.cpp > cfe/trunk/lib/Sema/SemaExprMember.cpp > cfe/trunk/lib/Sema/SemaLambda.cpp > cfe/trunk/lib/Sema/SemaStmt.cpp > cfe/trunk/lib/Sema/TreeTransform.h > cfe/trunk/lib/Serialization/ASTReaderStmt.cpp > cfe/trunk/lib/Serialization/ASTWriterStmt.cpp > cfe/trunk/www/cxx_status.html > > Modified: cfe/trunk/include/clang/AST/Stmt.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=273602=273601=273602=diff > == > --- cfe/trunk/include/clang/AST/Stmt.h (original) > +++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun 23 14:16:49 2016 > @@ -93,6 +93,13 @@ protected: > unsigned NumStmts : 32 - NumStmtBits; >}; > > + class IfStmtBitfields { > +friend class IfStmt; > +unsigned : NumStmtBits; > + > +unsigned IsConstexpr : 1; > + }; > + >class ExprBitfields { > friend class Expr; > friend class DeclRefExpr; // computeDependence > @@ -248,6 +255,7 @@ protected: >union { > StmtBitfields StmtBits; > CompoundStmtBitfields CompoundStmtBits; > +IfStmtBitfields IfStmtBits; > ExprBitfields ExprBits; > CharacterLiteralBitfields CharacterLiteralBits; > FloatingLiteralBitfields FloatingLiteralBits; > @@ -878,7 +886,8 @@ class IfStmt : public Stmt { >SourceLocation ElseLoc; > > public: > - IfStmt(const ASTContext , SourceLocation IL, VarDecl *var, Expr *cond, > + IfStmt(const ASTContext , SourceLocation IL, > + bool IsConstexpr, VarDecl *var, Expr *cond, > Stmt *then, SourceLocation EL = SourceLocation(), > Stmt *elsev = nullptr); > > @@ -918,6 +927,9 @@ public: >SourceLocation getElseLoc() const { return ElseLoc; } >void setElseLoc(SourceLocation L) { ElseLoc = L; } > > + bool isConstexpr() const { return IfStmtBits.IsConstexpr; } > + void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } > + >SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; } >SourceLocation getLocEnd() const LLVM_READONLY { > if (SubExprs[ELSE]) > > Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=273602=273601=273602=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jun 23 14:16:49 > 2016 > @@ -512,6 +512,11 @@ def err_function_is_not_record : Error< >"unexpected %0 in function call; perhaps remove the %0?">; > def err_super_in_using_declaration : Error< >"'__super' cannot be used with a using declaration">; > +def ext_constexpr_if : ExtWarn< > + "constexpr if is a C++1z extension">, InGroup; > +def warn_cxx14_compat_constexpr_if : Warning< > + "constexpr if is incompatible with C++ standards before C++1z">, > + DefaultIgnore, InGroup; > > // C++ derived classes > def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">; > > Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=273602=273601=273602=diff > == > --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 23 14:16:49 > 2016 > @@ -75,10 +75,12 @@ def err_typecheck_converted_constant_exp >"conversion from %0 to %1 in converted constant expression would " >"bind reference to a temporary">; > def err_expr_not_cce : Error< > -
r273602 - Implement p0292r2 (constexpr if), a likely C++1z feature.
Author: rsmith Date: Thu Jun 23 14:16:49 2016 New Revision: 273602 URL: http://llvm.org/viewvc/llvm-project?rev=273602=rev Log: Implement p0292r2 (constexpr if), a likely C++1z feature. Added: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp cfe/trunk/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp cfe/trunk/test/CodeGenCXX/cxx1z-constexpr-if.cpp Modified: cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/Stmt.cpp cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/lib/CodeGen/CGStmt.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/JumpDiagnostics.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/www/cxx_status.html Modified: cfe/trunk/include/clang/AST/Stmt.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=273602=273601=273602=diff == --- cfe/trunk/include/clang/AST/Stmt.h (original) +++ cfe/trunk/include/clang/AST/Stmt.h Thu Jun 23 14:16:49 2016 @@ -93,6 +93,13 @@ protected: unsigned NumStmts : 32 - NumStmtBits; }; + class IfStmtBitfields { +friend class IfStmt; +unsigned : NumStmtBits; + +unsigned IsConstexpr : 1; + }; + class ExprBitfields { friend class Expr; friend class DeclRefExpr; // computeDependence @@ -248,6 +255,7 @@ protected: union { StmtBitfields StmtBits; CompoundStmtBitfields CompoundStmtBits; +IfStmtBitfields IfStmtBits; ExprBitfields ExprBits; CharacterLiteralBitfields CharacterLiteralBits; FloatingLiteralBitfields FloatingLiteralBits; @@ -878,7 +886,8 @@ class IfStmt : public Stmt { SourceLocation ElseLoc; public: - IfStmt(const ASTContext , SourceLocation IL, VarDecl *var, Expr *cond, + IfStmt(const ASTContext , SourceLocation IL, + bool IsConstexpr, VarDecl *var, Expr *cond, Stmt *then, SourceLocation EL = SourceLocation(), Stmt *elsev = nullptr); @@ -918,6 +927,9 @@ public: SourceLocation getElseLoc() const { return ElseLoc; } void setElseLoc(SourceLocation L) { ElseLoc = L; } + bool isConstexpr() const { return IfStmtBits.IsConstexpr; } + void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } + SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; } SourceLocation getLocEnd() const LLVM_READONLY { if (SubExprs[ELSE]) Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=273602=273601=273602=diff == --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Jun 23 14:16:49 2016 @@ -512,6 +512,11 @@ def err_function_is_not_record : Error< "unexpected %0 in function call; perhaps remove the %0?">; def err_super_in_using_declaration : Error< "'__super' cannot be used with a using declaration">; +def ext_constexpr_if : ExtWarn< + "constexpr if is a C++1z extension">, InGroup; +def warn_cxx14_compat_constexpr_if : Warning< + "constexpr if is incompatible with C++ standards before C++1z">, + DefaultIgnore, InGroup; // C++ derived classes def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=273602=273601=273602=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jun 23 14:16:49 2016 @@ -75,10 +75,12 @@ def err_typecheck_converted_constant_exp "conversion from %0 to %1 in converted constant expression would " "bind reference to a temporary">; def err_expr_not_cce : Error< - "%select{case value|enumerator value|non-type template argument|array size}0 " + "%select{case value|enumerator value|non-type template argument|" + "array size|constexpr if condition}0 " "is not a constant expression">; def ext_cce_narrowing : ExtWarn< - "%select{case value|enumerator value|non-type template argument|array size}0 " + "%select{case value|enumerator value|non-type template argument|" + "array
Re: [PATCH] D21643: Default to using the Unicode version of Win32 APIs
aaron.ballman closed this revision. aaron.ballman added a comment. Commit in r273599. http://reviews.llvm.org/D21643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273600 - Re-commit r273548, reverted in r273589, with a fix to not produce
Author: rsmith Date: Thu Jun 23 14:02:52 2016 New Revision: 273600 URL: http://llvm.org/viewvc/llvm-project?rev=273600=rev Log: Re-commit r273548, reverted in r273589, with a fix to not produce -Wfor-loop-analysis warnings for a for-loop with a condition variable. In such a case, the loop condition variable is modified on each iteration of the loop by definition. Original commit message: Rearrange condition handling so that semantic checks on a condition variable are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/FixIt/fixit-vexing-parse.cpp cfe/trunk/test/Parser/cxx0x-condition.cpp cfe/trunk/test/SemaCXX/crashes.cpp cfe/trunk/test/SemaCXX/for-range-examples.cpp cfe/trunk/test/SemaObjCXX/foreach.mm Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=273600=273599=273600=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Thu Jun 23 14:02:52 2016 @@ -1588,8 +1588,8 @@ private: //======// // C++ if/switch/while condition expression. - bool ParseCXXCondition(ExprResult , Decl *, - SourceLocation Loc, bool ConvertToBoolean); + Sema::ConditionResult ParseCXXCondition(SourceLocation Loc, + Sema::ConditionKind CK); //======// // C++ Coroutines @@ -1680,10 +1680,9 @@ private: unsigned ScopeFlags); void ParseCompoundStatementLeadingPragmas(); StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); - bool ParseParenExprOrCondition(ExprResult , - Decl *, + bool ParseParenExprOrCondition(Sema::ConditionResult , SourceLocation Loc, - bool ConvertToBoolean); + Sema::ConditionKind CK); StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=273600=273599=273600=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun 23 14:02:52 2016 @@ -3298,6 +3298,7 @@ public: public: class FullExprArg { public: +FullExprArg() : E(nullptr) { } FullExprArg(Sema ) : E(nullptr) { } ExprResult release() { @@ -3391,27 +3392,23 @@ public: ArrayRef Attrs, Stmt *SubStmt); - StmtResult ActOnIfStmt(SourceLocation IfLoc, - FullExprArg CondVal, Decl *CondVar, - Stmt *ThenVal, - SourceLocation ElseLoc, Stmt *ElseVal); + class ConditionResult; + StmtResult ActOnIfStmt(SourceLocation IfLoc, ConditionResult Cond, + Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal); StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, -Expr *Cond, -Decl *CondVar); +ConditionResult Cond); StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body); - StmtResult ActOnWhileStmt(SourceLocation WhileLoc, -FullExprArg Cond, -Decl *CondVar, Stmt *Body); + StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, +Stmt *Body); StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, - SourceLocation WhileLoc, - SourceLocation CondLParen, Expr *Cond, - SourceLocation CondRParen); +
Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
jvesely added a comment. In http://reviews.llvm.org/D19932#465807, @yaxunl wrote: > > this is not true. as I pointed out earlier, take a look at libclc headers. > > a lot functions are defined for multiple types while maintaining type > > safety. > > > there is no problem having TYPE * to_global(TYPE *), for every permissible > > CLC type, declared in headers without any builtin. > > > This function allows user defined types. How do you declare that in a header > file? ah, now it makes sense, thanks. the void* argument let me astray. I'd say you can still do it using //typeof//, but I see how builtin would be preferable to that. Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
yaxunl added a comment. > this is not true. as I pointed out earlier, take a look at libclc headers. a > lot functions are defined for multiple types while maintaining type safety. > there is no problem having TYPE * to_global(TYPE *), for every permissible > CLC type, declared in headers without any builtin. This function allows user defined types. How do you declare that in a header file? Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21597: clang-format: [JS] recognize more type locations.
mprobst updated this revision to Diff 61706. mprobst marked an inline comment as done. mprobst added a comment. - progress http://reviews.llvm.org/D21597 Files: lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -914,6 +914,12 @@ verifyFormat("function(x: A|B = A | B): C {}"); verifyFormat("function x(path: number|string) {}"); verifyFormat("function x(): string|number {}"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = (Bar|Baz);"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: (Foo|Bar)[];"); } TEST_F(FormatTestJS, ClassDeclarations) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -134,6 +134,10 @@ if (Left->is(TT_OverloadedOperatorLParen)) { Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) { + // type X = (...); + Contexts.back().IsExpression = false; } else if (Left->Previous && (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype, tok::kw_if, tok::kw_while, tok::l_paren, @@ -147,6 +151,10 @@ Keywords.kw_function { // function(...) or function f(...) Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); + Contexts.back().IsExpression = false; } else if (Left->Previous && Left->Previous->is(tok::r_square) && Left->Previous->MatchingParen && Left->Previous->MatchingParen->is(TT_LambdaLSquare)) { @@ -913,6 +921,9 @@ void modifyContext(const FormatToken ) { if (Current.getPrecedence() == prec::Assignment && !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) && +// Type aliases use `type X = ...;` in TypeScript. +!(Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) && (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) { Contexts.back().IsExpression = true; if (!Line.startsWith(TT_UnaryOperator)) { Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -586,6 +586,7 @@ kw_import = ("import"); kw_is = ("is"); kw_let = ("let"); +kw_type = ("type"); kw_var = ("var"); kw_yield = ("yield"); @@ -637,6 +638,7 @@ IdentifierInfo *kw_import; IdentifierInfo *kw_is; IdentifierInfo *kw_let; + IdentifierInfo *kw_type; IdentifierInfo *kw_var; IdentifierInfo *kw_yield; Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -914,6 +914,12 @@ verifyFormat("function(x: A|B = A | B): C {}"); verifyFormat("function x(path: number|string) {}"); verifyFormat("function x(): string|number {}"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = Bar|Baz;"); + verifyFormat("type Foo = (Bar|Baz);"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: Bar|Baz;"); + verifyFormat("let x: (Foo|Bar)[];"); } TEST_F(FormatTestJS, ClassDeclarations) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -134,6 +134,10 @@ if (Left->is(TT_OverloadedOperatorLParen)) { Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && + Line.startsWith(Keywords.kw_type, tok::identifier)) { + // type X = (...); + Contexts.back().IsExpression = false; } else if (Left->Previous && (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype, tok::kw_if, tok::kw_while, tok::l_paren, @@ -147,6 +151,10 @@ Keywords.kw_function { // function(...) or function f(...) Contexts.back().IsExpression = false; +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); + Contexts.back().IsExpression = false; } else if (Left->Previous
Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
jvesely added a comment. In http://reviews.llvm.org/D19932#465784, @yaxunl wrote: > In http://reviews.llvm.org/D19932#465781, @jvesely wrote: > > > In http://reviews.llvm.org/D19932#465763, @cfe-commits wrote: > > > > > The returned pointer should point to the same pointee type as the > > > argument. Header file cannot guarantee that. > > > > > > Sam > > > > > > how come? is there a possibility to have two different types using the same > > name? > > > Because the pointee type is arbitrary, you can only define it as > > global void* to_global(void*); > > > in the header file. Then you could have > > int *a; > global double *b = to_global(a); > > > without diagnostics, but the spec requires that to_global(a) should have > global int* type, therefore there should be some diagnostics. this is not true. as I pointed out earlier, take a look at libclc headers. a lot functions are defined for multiple types while maintaining type safety. there is no problem having TYPE * to_global(TYPE *), for every permissible CLC type, declared in headers without any builtin. Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21597: clang-format: [JS] recognize more type locations.
mprobst marked 2 inline comments as done. Comment at: lib/Format/TokenAnnotator.cpp:155 @@ +154,3 @@ +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); djasper wrote: > I'd merge this one in with the previous.. And maybe even the one from above > so that we end up with: > > } else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous > && >(Line.First->is(Keywords.kw_type) || > Left->Previous->isOneOf(Keywords.kw_function, TT_JsTypeColon) > || > (Left->Previous->endsSequence(tok::identifier, > Keywords.kw_function { > > (in order for Line.First to be "type", Left->Previous cannot be nullptr, so > this should be equivalent) I think I'd prefer keeping this as is. The way it is now formulated is more verbose, but that's to communicate and keep apart three very different situations (type alias, (async)? function, variable declaration). Merging the boolean conditions in some clever way will make it very hard to reverse-decipher which partially overlapping boolean clause is for which of these situations, and it's usually non-obvious if test coverage is good enough to make sure nothing breaks if you refactor. The could would also be harder to read, e.g. the is(kw_function) part is logically related to the endsSeqeunce call, but they end up in different parts of the clause. So, in the interest of readability and maintainability, I'll keep it like this, and assume by accepting the diff you're cool with that :-) If not, please do push back. Comment at: lib/Format/TokenAnnotator.cpp:926 @@ +925,3 @@ +// Type aliases use `type X = ...;` in TypeScript. +!(Style.Language == FormatStyle::LK_JavaScript && + Line.First->is(Keywords.kw_type)) && djasper wrote: > I'd move the ! into the parentheses, but doesn't matter much. I've formulated it like this intentionally – it follows my brain waves, as in "mark this as an expression if not this is javascript and it's a type def". Changing it to "mark this as an expression if language is not javascript or line is not a typedef" is less readable to me. http://reviews.llvm.org/D21597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
yaxunl added a comment. In http://reviews.llvm.org/D19932#465781, @jvesely wrote: > In http://reviews.llvm.org/D19932#465763, @cfe-commits wrote: > > > The returned pointer should point to the same pointee type as the argument. > > Header file cannot guarantee that. > > > > Sam > > > how come? is there a possibility to have two different types using the same > name? Because the pointee type is arbitrary, you can only define it as global void* to_global(void*); in the header file. Then you could have int *a; global double *b = to_global(a); without diagnostics, but the spec requires that to_global(a) should have global int* type, therefore there should be some diagnostics. Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
jvesely added a comment. In http://reviews.llvm.org/D19932#465763, @cfe-commits wrote: > The returned pointer should point to the same pointee type as the argument. > Header file cannot guarantee that. > > Sam how come? is there a possibility to have two different types using the same name? Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273589 - Revert r273548, "Rearrange condition handling so that semantic checks on a condition variable"
Author: pcc Date: Thu Jun 23 13:11:15 2016 New Revision: 273589 URL: http://llvm.org/viewvc/llvm-project?rev=273589=rev Log: Revert r273548, "Rearrange condition handling so that semantic checks on a condition variable" as it caused a regression in -Wfor-loop-analysis. Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/FixIt/fixit-vexing-parse.cpp cfe/trunk/test/Parser/cxx0x-condition.cpp cfe/trunk/test/SemaCXX/crashes.cpp cfe/trunk/test/SemaCXX/for-range-examples.cpp cfe/trunk/test/SemaObjCXX/foreach.mm Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=273589=273588=273589=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Thu Jun 23 13:11:15 2016 @@ -1588,8 +1588,8 @@ private: //======// // C++ if/switch/while condition expression. - Sema::ConditionResult ParseCXXCondition(SourceLocation Loc, - Sema::ConditionKind CK); + bool ParseCXXCondition(ExprResult , Decl *, + SourceLocation Loc, bool ConvertToBoolean); //======// // C++ Coroutines @@ -1680,9 +1680,10 @@ private: unsigned ScopeFlags); void ParseCompoundStatementLeadingPragmas(); StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); - bool ParseParenExprOrCondition(Sema::ConditionResult , + bool ParseParenExprOrCondition(ExprResult , + Decl *, SourceLocation Loc, - Sema::ConditionKind CK); + bool ConvertToBoolean); StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=273589=273588=273589=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun 23 13:11:15 2016 @@ -3298,7 +3298,6 @@ public: public: class FullExprArg { public: -FullExprArg() : E(nullptr) { } FullExprArg(Sema ) : E(nullptr) { } ExprResult release() { @@ -3392,23 +3391,27 @@ public: ArrayRef Attrs, Stmt *SubStmt); - class ConditionResult; - StmtResult ActOnIfStmt(SourceLocation IfLoc, ConditionResult Cond, - Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal); + StmtResult ActOnIfStmt(SourceLocation IfLoc, + FullExprArg CondVal, Decl *CondVar, + Stmt *ThenVal, + SourceLocation ElseLoc, Stmt *ElseVal); StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, -ConditionResult Cond); +Expr *Cond, +Decl *CondVar); StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body); - StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, -Stmt *Body); + StmtResult ActOnWhileStmt(SourceLocation WhileLoc, +FullExprArg Cond, +Decl *CondVar, Stmt *Body); StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, - SourceLocation WhileLoc, SourceLocation CondLParen, - Expr *Cond, SourceLocation CondRParen); + SourceLocation WhileLoc, + SourceLocation CondLParen, Expr *Cond, + SourceLocation CondRParen); StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, - Stmt *First, - ConditionResult Second, + Stmt *First, FullExprArg Second, + Decl *SecondVar, FullExprArg Third,
r273590 - Add a test case for the regression in -Wfor-loop-analysis caused by r273548.
Author: pcc Date: Thu Jun 23 13:11:19 2016 New Revision: 273590 URL: http://llvm.org/viewvc/llvm-project?rev=273590=rev Log: Add a test case for the regression in -Wfor-loop-analysis caused by r273548. Modified: cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp Modified: cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp?rev=273590=273589=273590=diff == --- cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp (original) +++ cfe/trunk/test/SemaCXX/warn-loop-analysis.cpp Thu Jun 23 13:11:19 2016 @@ -260,3 +260,9 @@ void test8() { i--; } } + +int f(int); +void test9() { + // Don't warn when variable is defined by the loop condition. + for (int i = 0; int x = f(i); ++i) {} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.
The returned pointer should point to the same pointee type as the argument. Header file cannot guarantee that. Sam -Original Message- From: Jan Vesely [mailto:jan.ves...@rutgers.edu] Sent: Wednesday, June 22, 2016 10:20 PM To: Liu, Yaxun (Sam); xiuli...@outlook.com; anastasia.stul...@arm.com Cc: jan.ves...@rutgers.edu; Stellard, Thomas ; cfe-commits@lists.llvm.org Subject: Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions. jvesely added a subscriber: jvesely. jvesely added a comment. Why couldn't this be declared in CLC header? There are multiple instances of declaring functions for all available types in libclc (see for example convert functions in convert.h). Repository: rL LLVM http://reviews.llvm.org/D19932 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21507: Changes after running check modernize-use-emplace (D20964)
sanjoy added a comment. One other thing to point out -- have you verified that the changes in `unittests/` are benign (i.e. you're not semantically changing the tests)? Repository: rL LLVM http://reviews.llvm.org/D21507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r273191 - [OpenCL] Include opencl-c.h by default as a clang module
Hi, I won't have access to the system for ~2 weeks but the change looks fine. Please commit if it passes the test on Linux with that. Regards, ismail On Thu, Jun 23, 2016 at 4:39 PM, Liu, Yaxun (Sam)wrote: > I have a patch which may workaround this issue, however I could not test it > in Cygwin since I got issues build latest cmake in Cygwin and the downloaded > cmake does not work. > > Could you please try it? > > Thanks. > > Sam > > -Original Message- > From: Ismail Donmez [mailto:ism...@i10z.com] > Sent: Wednesday, June 22, 2016 1:52 PM > To: Liu, Yaxun (Sam) > Cc: cfe-commits > Subject: Re: r273191 - [OpenCL] Include opencl-c.h by default as a clang > module > > Hi, > > On Wed, Jun 22, 2016 at 7:55 PM, Liu, Yaxun (Sam) wrote: >> The cmake of Cygwin itself does not support llvm. Which cmake did you use on >> Cygwin? Thanks. > > I use native windows cmake and this is the only test that ever failed with > this setup. chmod is from native cygwin which seems to be the problem. > > ismail ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21653: [Sema] Disallow ambiguous base-to-derived conversion in template argument deduction
erik.pilkington created this revision. erik.pilkington added reviewers: rsmith, faisalv. erik.pilkington added a subscriber: cfe-commits. Previously, Clang would incorrectly accept the following: ``` template struct A {}; struct B : A<0>, A<1> {}; template int f(A); int main() { f(B()); } ``` The problem is that when considering the base classes of B, there are 2 possible ambiguous bases that could be deduced. Therefore, deduction ought to fail (temp.deduct.call p5). There are 3 improvements that I want to make here as well: 1. Introduce a TDK_AmbiguousBaseClasses so that this diagnostic isn't terrible. 2. Reapply Richard's r267453, (with some modifications) which previously broke stdlibc++'s tuple implementation (PR27601, reverted in r270016). This refactors the handmade base class traversal I fixed here to instead use CXXRecordDecl::forallBases(), I believe that requiring matching number of arguments in the DeduceTemplateArguments at SemaTemplateDeduction.cpp:433 will fix it. 3. A NFC patch to rename the 10 (!) overloads of DeduceTemplateArguments to have more descriptive names. These functions are *really* annoying to deal with because of that. If it would be better to do a subset (or all) of these improvements here, I could always update the diff. Fixes PR28195. Thanks! http://reviews.llvm.org/D21653 Files: lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp === --- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp +++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp @@ -160,3 +160,16 @@ } } + +namespace PR28195 { + +template struct B {}; +struct D : B<0>, B<1> {}; + +template int callee(B); // expected-note{{failed template argument deduction}} + +int caller() { + callee(D()); // expected-error{{no matching function}} +} + +} Index: lib/Sema/SemaTemplateDeduction.cpp === --- lib/Sema/SemaTemplateDeduction.cpp +++ lib/Sema/SemaTemplateDeduction.cpp @@ -103,12 +103,12 @@ bool PartialOrdering = false); static Sema::TemplateDeductionResult -DeduceTemplateArguments(Sema , -TemplateParameterList *TemplateParams, +DeduceTemplateArguments(Sema , TemplateParameterList *TemplateParams, const TemplateArgument *Params, unsigned NumParams, const TemplateArgument *Args, unsigned NumArgs, TemplateDeductionInfo , -SmallVectorImpl ); +SmallVectorImpl , +bool NumberOfArgumentsMustMatch); /// \brief If the given expression is of a form that permits the deduction /// of a non-type template parameter, return the declaration of that @@ -453,10 +453,10 @@ // Perform template argument deduction on each template // argument. Ignore any missing/extra arguments, since they could be // filled in by default arguments. -return DeduceTemplateArguments(S, TemplateParams, - Param->getArgs(), Param->getNumArgs(), - SpecArg->getArgs(), SpecArg->getNumArgs(), - Info, Deduced); +return DeduceTemplateArguments(S, TemplateParams, Param->getArgs(), + Param->getNumArgs(), SpecArg->getArgs(), + SpecArg->getNumArgs(), Info, Deduced, + /*NumberOfArgumentsMustMatch=*/false); } // If the argument type is a class template specialization, we @@ -487,11 +487,10 @@ return Result; // Perform template argument deduction for the template arguments. - return DeduceTemplateArguments(S, TemplateParams, - Param->getArgs(), Param->getNumArgs(), - SpecArg->getTemplateArgs().data(), - SpecArg->getTemplateArgs().size(), - Info, Deduced); + return DeduceTemplateArguments( + S, TemplateParams, Param->getArgs(), Param->getNumArgs(), + SpecArg->getTemplateArgs().data(), SpecArg->getTemplateArgs().size(), + Info, Deduced, /*NumberOfArgumentsMustMatch=*/true); } /// \brief Determines whether the given type is an opaque type that @@ -1461,6 +1460,7 @@ SmallVector ToVisit; ToVisit.push_back(RecordT); bool Successful = false; + SmallVectorSuccessfulDeduced; while (!ToVisit.empty()) { // Retrieve the next class in the inheritance hierarchy. const RecordType *NextT = ToVisit.pop_back_val(); @@ -1481,14 +1481,20 @@ // note that we had some success. Otherwise, ignore any deductions
Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.
ikudrin added a comment. Ping... This patch is under review for more than two months, and I believe I've addressed all the comments. Could someone take a look at it, please? http://reviews.llvm.org/D17815 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21564: [OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'
carlo.bertolli added a comment. Thanks for these further comments. I have just updated the diff applying the suggestions. Repository: rL LLVM http://reviews.llvm.org/D21564 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21229: [Analyzer] Don't cache report generation ExplodedNodes
bcraig closed this revision. bcraig added a comment. Old: 106,657,666 New: 105,346,818 Submitted in r273572 http://reviews.llvm.org/D21229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273572 - [Analyzer] Don't cache report generation ExplodedNodes
Author: bcraig Date: Thu Jun 23 10:47:12 2016 New Revision: 273572 URL: http://llvm.org/viewvc/llvm-project?rev=273572=rev Log: [Analyzer] Don't cache report generation ExplodedNodes During the core analysis, ExplodedNodes are added to the ExplodedGraph, and those nodes are cached for deduplication purposes. After core analysis, reports are generated. Here, trimmed copies of the ExplodedGraph are made. Since the ExplodedGraph has already been deduplicated, there is no need to deduplicate again. This change makes it possible to add ExplodedNodes to an ExplodedGraph without the overhead of deduplication. "Uncached" nodes also cannot be iterated over, but none of the report generation code attempts to iterate over all nodes. This change reduces the analysis time of a large .C file from 3m43.941s to 3m40.256s (~1.6% speedup). It should slightly reduce memory consumption. Gains should be roughly proportional to the number (and path length) of static analysis warnings. This patch enables future work that should remove the need for an InterExplodedGraphMap inverse map. I plan on using the (now unused) ExplodedNode link to connect new nodes to the original nodes. http://reviews.llvm.org/D21229 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h?rev=273572=273571=273572=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h Thu Jun 23 10:47:12 2016 @@ -295,6 +295,14 @@ public: bool IsSink = false, bool* IsNew = nullptr); + /// \brief Create a node for a (Location, State) pair, + /// but don't store it for deduplication later. This + /// is useful when copying an already completed + /// ExplodedGraph for further processing. + ExplodedNode *createUncachedNode(const ProgramPoint , +ProgramStateRef State, +bool IsSink = false); + std::unique_ptr MakeEmptyGraph() const { return llvm::make_unique(); } Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=273572=273571=273572=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Thu Jun 23 10:47:12 2016 @@ -2922,7 +2922,7 @@ bool TrimmedGraph::popNextReportGraph(Re while (true) { // Create the equivalent node in the new graph with the same state // and location. -ExplodedNode *NewN = GNew->getNode(OrigN->getLocation(), OrigN->getState(), +ExplodedNode *NewN = GNew->createUncachedNode(OrigN->getLocation(), OrigN->getState(), OrigN->isSink()); // Store the mapping to the original node. Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=273572=273571=273572=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Thu Jun 23 10:47:12 2016 @@ -336,6 +336,14 @@ ExplodedNode *ExplodedGraph::getNode(con return V; } +ExplodedNode *ExplodedGraph::createUncachedNode(const ProgramPoint , +ProgramStateRef State, +bool IsSink) { + NodeTy *V = (NodeTy *) getAllocator().Allocate(); + new (V) NodeTy(L, State, IsSink); + return V; +} + std::unique_ptr ExplodedGraph::trim(ArrayRef Sinks, InterExplodedGraphMap *ForwardMap, @@ -395,8 +403,7 @@ ExplodedGraph::trim(ArrayRefgetNode(N->getLocation(), N->State, N->isSink(), -nullptr); +ExplodedNode *NewN = G->createUncachedNode(N->getLocation(), N->State, N->isSink()); Pass2[N] = NewN; // Also record the reverse mapping from the new node to the old node. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21643: Default to using the Unicode version of Win32 APIs
aaron.ballman added a comment. In http://reviews.llvm.org/D21643#465583, @llvm-commits wrote: > Should we add overloads of the UTF8 conversion functions that accept > wstrings? I think we should eventually consider cleaning up our Unicode APIs because they're kind of all over the place. For instance, WindowsSupport.h has a different set of APIs for handling Unicode conversions that compete with the ones exposed by ConvertUTF.h. > In line with what rnk said, I'm curious about the implications of simply > #undef'ing all the non A/W versions of functions so that you have to make > the choice explicit I'm not certain I follow along. Are you suggesting we explicitly #undef something like RegQueryValueEx so that you must explicitly call RegQueryValueExW or RegQueryValueExA, as needed? That seems like something that will quickly get forgotten about and not really used. http://reviews.llvm.org/D21643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21643: Default to using the Unicode version of Win32 APIs
rnk added a comment. In http://reviews.llvm.org/D21643#465584, @aaron.ballman wrote: > I have never successfully built compiler-rt with MSVC. Every time I've tried > (the last time was 6+ months ago, so I will try again), the MSVC solution > generated by CMake refuses to compile. From what I understand, it basically > only works with ninja, which I do not have installed. :-( Etienne and Wei started working on ASan, and they got the ASan build working in MSBuild a few months ago, so I'd give it another shot. Let me know if you can't build it, and I can take a moment to patch in this change. http://reviews.llvm.org/D21643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21643: Default to using the Unicode version of Win32 APIs
aaron.ballman added a comment. In http://reviews.llvm.org/D21643#465579, @rnk wrote: > Sure, this serves as a reminder that you should always convert from UTF-8 to > wide in Windows support code. I still think we should always explicitly call > the wide variants, and it seems like you agree. Defining these macros is just > a way to ensure we don't accidentally regress. Exactly! This patch was motivated by a recent bug I found where we used an unprefixed function that defaulted to ANSI instead of Wide. > Can you build asan with this change? I suspect it will be sensitive to it > because it wraps the win32 API directly rather than going through Support. I have never successfully built compiler-rt with MSVC. Every time I've tried (the last time was 6+ months ago, so I will try again), the MSVC solution generated by CMake refuses to compile. From what I understand, it basically only works with ninja, which I do not have installed. :-( If you wouldn't mind giving it a shot, I would be curious to know what the state of it is with this change. http://reviews.llvm.org/D21643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21643: Default to using the Unicode version of Win32 APIs
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. Sure, this serves as a reminder that you should always convert from UTF-8 to wide in Windows support code. I still think we should always explicitly call the wide variants, and it seems like you agree. Defining these macros is just a way to ensure we don't accidentally regress. Can you build asan with this change? I suspect it will be sensitive to it because it wraps the win32 API directly rather than going through Support. http://reviews.llvm.org/D21643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273566 - Restructure the propagation of -fPIC/-fPIE.
Author: rafael Date: Thu Jun 23 10:07:32 2016 New Revision: 273566 URL: http://llvm.org/viewvc/llvm-project?rev=273566=rev Log: Restructure the propagation of -fPIC/-fPIE. The PIC and PIE levels are not independent. In fact, if PIE is defined it is always the same as PIC. This is clear in the driver where ParsePICArgs returns a PIC level and a IsPIE boolean. Unfortunately that is currently lost and we pass two redundant levels down the pipeline. This patch keeps a bool and a PIC level all the way down to codegen. Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/CodeGen/CGObjCGNU.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp cfe/trunk/test/Driver/fsanitize.c cfe/trunk/test/Driver/pic.c cfe/trunk/test/Driver/ps4-pic.c cfe/trunk/test/Modules/explicit-build-flags.cpp cfe/trunk/test/Preprocessor/pic.c Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=273566=273565=273566=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Jun 23 10:07:32 2016 @@ -158,7 +158,7 @@ VALUE_LANGOPT(MaxTypeAlign , 32, 0, "default maximum alignment for types") VALUE_LANGOPT(AlignDouble, 1, 0, "Controls if doubles should be aligned to 8 bytes (x86 only)") COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level") -COMPATIBLE_VALUE_LANGOPT(PIELevel, 2, 0, "__PIE__ level") +COMPATIBLE_VALUE_LANGOPT(PIE , 1, 0, "is pie") COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics") COMPATIBLE_LANGOPT(NoInlineDefine, 1, 0, "__NO_INLINE__ predefined macro") COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro") Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=273566=273565=273566=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Jun 23 10:07:32 2016 @@ -546,8 +546,8 @@ def fencode_extended_block_signature : F HelpText<"enable extended encoding of block type signature">; def pic_level : Separate<["-"], "pic-level">, HelpText<"Value for __PIC__">; -def pie_level : Separate<["-"], "pie-level">, - HelpText<"Value for __PIE__">; +def pic_is_pie : Flag<["-"], "pic-is-pie">, + HelpText<"File is for a position independent executable">; def fno_validate_pch : Flag<["-"], "fno-validate-pch">, HelpText<"Disable validation of precompiled headers">; def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">, Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=273566=273565=273566=diff == --- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Thu Jun 23 10:07:32 2016 @@ -2830,7 +2830,7 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIva // to replace it with the real version for a library. In non-PIC code you // must compile with the fragile ABI if you want to use ivars from a // GCC-compiled class. -if (CGM.getLangOpts().PICLevel || CGM.getLangOpts().PIELevel) { +if (CGM.getLangOpts().PICLevel) { llvm::GlobalVariable *IvarOffsetGV = new llvm::GlobalVariable(TheModule, Int32Ty, false, llvm::GlobalValue::PrivateLinkage, OffsetGuess, Name+".guess"); Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=273566=273565=273566=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jun 23 10:07:32 2016 @@ -480,11 +480,8 @@ void CodeGenModule::Release() { if (uint32_t PLevel = Context.getLangOpts().PICLevel) { assert(PLevel < 3 && "Invalid PIC Level"); getModule().setPICLevel(static_cast(PLevel)); - } - - if (uint32_t PLevel = Context.getLangOpts().PIELevel) { -assert(PLevel < 3 && "Invalid PIE Level"); -getModule().setPIELevel(static_cast(PLevel)); +if (Context.getLangOpts().PIE) + getModule().setPIELevel(static_cast(PLevel)); } SimplifyPersonality(); Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=273566=273565=273566=diff
[PATCH] D21643: Default to using the Unicode version of Win32 APIs
aaron.ballman created this revision. aaron.ballman added reviewers: rnk, majnemer, chapuni, zturner. aaron.ballman added subscribers: llvm-commits, cfe-commits. We currently default to using the multibyte character versions of Win32 APIs, commonly suffixed with an "A". However, this causes problems because many of the Win32 APIs that we use are for things like file paths, where non-ASCII characters are commonly expected. This patch defaults us to using the "W" versions of the Win32 APIs, which helps to remind us to properly handle non-ASCII input. We can still fall back on the multibyte APIs by explicitly specifying the "A" version of the function, but we no longer run into issues where we call a Win32 API without a suffix and accidentally wind up using the A version on UTF-8 data (which will fail) instead of using the W version on UTF-16 data (which will succeed). I have tested this patch with MSVC 2015 and LLVM, Clang, and clang-tools-extra all compile cleanly (after a few cleanup patches) and all tests pass. I have not tried other projects as I do not have them locally, but hopefully they: work with this patch as-is, require minimal changes to support this patch, or can override the behavior with their own CMake settings. Before committing, I plan to make sure these projects all continue to compile, but I wanted to make sure the community was okay with this direction before doing that work. http://reviews.llvm.org/D21643 Files: cmake/modules/HandleLLVMOptions.cmake Index: cmake/modules/HandleLLVMOptions.cmake === --- cmake/modules/HandleLLVMOptions.cmake +++ cmake/modules/HandleLLVMOptions.cmake @@ -249,6 +249,12 @@ -D_SCL_SECURE_NO_WARNINGS ) + # Tell MSVC to use the Unicode version of the Win32 APIs instead of ANSI. + add_llvm_definitions( +-DUNICODE +-D_UNICODE + ) + set(msvc_warning_flags # Disabled warnings. -wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline) Index: cmake/modules/HandleLLVMOptions.cmake === --- cmake/modules/HandleLLVMOptions.cmake +++ cmake/modules/HandleLLVMOptions.cmake @@ -249,6 +249,12 @@ -D_SCL_SECURE_NO_WARNINGS ) + # Tell MSVC to use the Unicode version of the Win32 APIs instead of ANSI. + add_llvm_definitions( +-DUNICODE +-D_UNICODE + ) + set(msvc_warning_flags # Disabled warnings. -wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21507: Changes after running check modernize-use-emplace (D20964)
vsk added a comment. In http://reviews.llvm.org/D21507#465444, @Prazek wrote: > In http://reviews.llvm.org/D21507#464791, @vsk wrote: > > > Neat! It would help to upload a git-clang-format'd. Fwiw I only managed to > > look over the changes in lib/{ARCMigrate,AST,Analysis}. > > > > Have you run check-all and the full test-suite? > > > Yep, didn't have any problems with dat Ok great! This looks good then. I'd wait for one of the clang-tidy devs to give an actual lgtm. It might also be worth sending a "heads-up" email to llvm-dev once it's approved. Repository: rL LLVM http://reviews.llvm.org/D21507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21504: [X86] add _mm_loadu_si64
craig.topper added a subscriber: craig.topper. Comment at: tools/clang/test/CodeGen/sse2-builtins.c:1526 @@ +1525,3 @@ + // CHECK-LABEL: test_mm_loadu_si64 + // CHECK: load i64, i64* %{{.*}}, align 1 + // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0 You need {{$}} after the 1 to indicate end of line or it can match 16 too. Repository: rL LLVM http://reviews.llvm.org/D21504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273563 - Fixing a FIXME related to Unicode support on Windows. Converted the Win32 APIs to explicitly use the W version when it involves strings that can hold non-ASCII characters (like file paths).
Author: aaronballman Date: Thu Jun 23 09:33:53 2016 New Revision: 273563 URL: http://llvm.org/viewvc/llvm-project?rev=273563=rev Log: Fixing a FIXME related to Unicode support on Windows. Converted the Win32 APIs to explicitly use the W version when it involves strings that can hold non-ASCII characters (like file paths). Now explicitly using the A version for strings that will always be ASCII (like registry key paths). No extra tests required as this is currently covered by existing testing, and this is basically impossible to write Unicode-specific tests for. Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=273563=273562=273563=diff == --- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original) +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Thu Jun 23 09:33:53 2016 @@ -95,23 +95,31 @@ bool MSVCToolChain::isPICDefaultForced() #ifdef USE_WIN32 static bool readFullStringValue(HKEY hkey, const char *valueName, std::string ) { - // FIXME: We should be using the W versions of the registry functions, but - // doing so requires UTF8 / UTF16 conversions similar to how we handle command - // line arguments. The UTF8 conversion functions are not exposed publicly - // from LLVM though, so in order to do this we will probably need to create - // a registry abstraction in LLVMSupport that is Windows only. + std::wstring WideValueName; + if (!llvm::ConvertUTF8toWide(valueName, WideValueName)) +return false; + DWORD result = 0; DWORD valueSize = 0; DWORD type = 0; // First just query for the required size. - result = RegQueryValueEx(hkey, valueName, NULL, , NULL, ); - if (result != ERROR_SUCCESS || type != REG_SZ) + result = RegQueryValueExW(hkey, WideValueName.c_str(), NULL, , NULL, +); + if (result != ERROR_SUCCESS || type != REG_SZ || !valueSize) return false; std::vector buffer(valueSize); - result = RegQueryValueEx(hkey, valueName, NULL, NULL, [0], ); - if (result == ERROR_SUCCESS) -value.assign(reinterpret_cast(buffer.data())); - return result; + result = RegQueryValueExW(hkey, WideValueName.c_str(), NULL, NULL, [0], +); + if (result == ERROR_SUCCESS) { +std::wstring WideValue(reinterpret_cast(buffer.data()), + valueSize / sizeof(wchar_t)); +// The destination buffer must be empty as an invariant of the conversion +// function; but this function is sometimes called in a loop that passes in +// the same buffer, however. Simply clear it out so we can overwrite it. +value.clear(); +return llvm::convertWideToUTF8(WideValue, value); + } + return false; } #endif @@ -152,14 +160,15 @@ static bool getSystemRegistryString(cons strncpy(partialKey, keyPath, partialKeyLength); partialKey[partialKeyLength] = '\0'; HKEY hTopKey = NULL; -lResult = RegOpenKeyEx(hRootKey, partialKey, 0, KEY_READ | KEY_WOW64_32KEY, - ); +lResult = RegOpenKeyExA(hRootKey, partialKey, 0, KEY_READ | KEY_WOW64_32KEY, +); if (lResult == ERROR_SUCCESS) { char keyName[256]; double bestValue = 0.0; DWORD index, size = sizeof(keyName) - 1; - for (index = 0; RegEnumKeyEx(hTopKey, index, keyName, , NULL, - NULL, NULL, NULL) == ERROR_SUCCESS; index++) { + for (index = 0; RegEnumKeyExA(hTopKey, index, keyName, , NULL, NULL, +NULL, NULL) == ERROR_SUCCESS; + index++) { const char *sp = keyName; while (*sp && !isDigit(*sp)) sp++; @@ -178,8 +187,8 @@ static bool getSystemRegistryString(cons bestName = keyName; // Append rest of key. bestName.append(nextKey); - lResult = RegOpenKeyEx(hTopKey, bestName.c_str(), 0, - KEY_READ | KEY_WOW64_32KEY, ); + lResult = RegOpenKeyExA(hTopKey, bestName.c_str(), 0, + KEY_READ | KEY_WOW64_32KEY, ); if (lResult == ERROR_SUCCESS) { lResult = readFullStringValue(hKey, valueName, value); if (lResult == ERROR_SUCCESS) { @@ -197,7 +206,7 @@ static bool getSystemRegistryString(cons } } else { lResult = -RegOpenKeyEx(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, ); +RegOpenKeyExA(hRootKey, keyPath, 0, KEY_READ | KEY_WOW64_32KEY, ); if (lResult == ERROR_SUCCESS) { lResult = readFullStringValue(hKey, valueName, value); if (lResult == ERROR_SUCCESS) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21637: [libcxx] Don't use pthread initializers in constexpr constructors
On Thu, Jun 23, 2016 at 02:27:12PM +, Ben Craig via cfe-commits wrote: > bcraig added subscribers: joerg, bcraig. > bcraig added a comment. > > @joerg. I think this has been fixed in newer versions of NetBSD. > > Sure would be nice if someone could fix this on the MUSL side of things. > > See https://bugs.musicpd.org/view.php?id=4110 for fun conversations about > mutex, PTHREAD_MUTEX_INIT and constexpr. > > Also, the first revision of this review: > http://reviews.llvm.org/D19344 Right. Strictly speaking, the problem is the use of nested subfields, which is a language defect. The only question for me is whether this syntax works in pre-C++11 mode. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21637: [libcxx] Don't use pthread initializers in constexpr constructors
bcraig added subscribers: joerg, bcraig. bcraig added a comment. @joerg. I think this has been fixed in newer versions of NetBSD. Sure would be nice if someone could fix this on the MUSL side of things. See https://bugs.musicpd.org/view.php?id=4110 for fun conversations about mutex, PTHREAD_MUTEX_INIT and constexpr. Also, the first revision of this review: http://reviews.llvm.org/D19344 http://reviews.llvm.org/D21637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21601: Make tooling::applyAllReplacements return llvm::Expected instead of empty string to indicate potential error.
klimek added inline comments. Comment at: lib/Format/Format.cpp:1395 @@ -1394,2 +1394,3 @@ +// If any replacements in \p Replaces fails to apply, this returns \p Replaces. template ioeric wrote: > klimek wrote: > > Why would we want to return the same replacements? > this is just a temp solution to keep the current interfaces of > processReplacements and formatReplacements...should I add a FIXME or can I > change them in this patch as well? Both are good options :) Choose one. http://reviews.llvm.org/D21601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21567: [OpenCL] Generate struct type for sampler_t and function call for the initializer
Anastasia added inline comments. Comment at: include/clang/AST/BuiltinTypes.def:164 @@ +163,3 @@ +// Internal OpenCL sampler initializer type. +BUILTIN_TYPE(OCLSamplerInit, OCLSamplerInitTy) + I can't get why is this necessary to represent initializer as a special Clang type? Could we avoid this additional complexity? Comment at: include/clang/AST/OperationKinds.def:328 @@ +327,3 @@ +// Convert an integer initializer to an OpenCL sampler initializer. +CAST_OPERATION(IntToOCLSamplerInitializer) + Could we just have only int->sampler conversion? Without having an extra type for initializer? Comment at: include/clang/Basic/DiagnosticGroups.td:876 @@ +875,3 @@ +// A warning group for warnings about code that clang accepts when +// compiling OpenCL C/C++ but which is not compatible with the SPIR spec. +def SpirCompat : DiagGroup<"spir-compat">; I don't understand the description really? Why not compatible? Comment at: include/clang/Driver/CC1Options.td:690 @@ -689,1 +689,3 @@ HelpText<"OpenCL only. Allow denormals to be flushed to zero">; +def cl_sampler_type : Separate<["-"], "cl-sampler-type">, + HelpText<"OpenCL only. Specify type of sampler to emit. Valid values: \"opaque\"(default), \"i32\"">; Any reason to have this flag and support different sampler representations in Clang? Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:52 @@ +51,3 @@ + return llvm::PointerType::get(llvm::StructType::create( + Ctx, "__sampler"), + CGM.getContext().getTargetAddressSpace( Could you please keep coherency in type naming i.e. add "opencl." prefix. http://reviews.llvm.org/D21567 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21385: Adjust Registry interface to not require plugins to export a registry
john.brawn added a comment. Ping. Repository: rL LLVM http://reviews.llvm.org/D21385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21601: Make tooling::applyAllReplacements return llvm::Expected instead of empty string to indicate potential error.
ioeric added inline comments. Comment at: lib/Format/Format.cpp:1395 @@ -1394,2 +1394,3 @@ +// If any replacements in \p Replaces fails to apply, this returns \p Replaces. template klimek wrote: > Why would we want to return the same replacements? this is just a temp solution to keep the current interfaces of processReplacements and formatReplacements...should I add a FIXME or can I change them in this patch as well? http://reviews.llvm.org/D21601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273558 - CodeGen: support linker options on Windows ARM
Author: compnerd Date: Thu Jun 23 08:45:33 2016 New Revision: 273558 URL: http://llvm.org/viewvc/llvm-project?rev=273558=rev Log: CodeGen: support linker options on Windows ARM We would incorrectly emit the directive sections due to the missing overridden methods. We now emit the expected "/DEFAULTLIB" rather than "-l" options for requested linkage Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGen/dependent-lib.c cfe/trunk/test/CodeGen/pragma-comment.c cfe/trunk/test/CodeGen/pragma-detect_mismatch.c cfe/trunk/test/PCH/pragma-comment.c cfe/trunk/test/PCH/pragma-detect_mismatch.c Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=273558=273557=273558=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Jun 23 08:45:33 2016 @@ -5083,6 +5083,16 @@ public: void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const override; + + void getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> ) const override { +Opt = "/DEFAULTLIB:" + qualifyWindowsLibrary(Lib); + } + + void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value, + llvm::SmallString<32> ) const override { +Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; + } }; void WindowsARMTargetCodeGenInfo::setTargetAttributes( Modified: cfe/trunk/test/CodeGen/dependent-lib.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/dependent-lib.c?rev=273558=273557=273558=diff == --- cfe/trunk/test/CodeGen/dependent-lib.c (original) +++ cfe/trunk/test/CodeGen/dependent-lib.c Thu Jun 23 08:45:33 2016 @@ -1,3 +1,4 @@ +// RUN: %clang_cc1 %s --dependent-lib=msvcrt -triple thumbv7-windows -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s --dependent-lib=msvcrt -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s --dependent-lib=msvcrt -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s --dependent-lib=msvcrt -triple i686-pc-linux -emit-llvm -o - | FileCheck -check-prefix LINUX %s Modified: cfe/trunk/test/CodeGen/pragma-comment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-comment.c?rev=273558=273557=273558=diff == --- cfe/trunk/test/CodeGen/pragma-comment.c (original) +++ cfe/trunk/test/CodeGen/pragma-comment.c Thu Jun 23 08:45:33 2016 @@ -1,5 +1,7 @@ // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple thumbv7-windows -fms-extensions -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple thumbv7-linux-gnueabihf -fms-extensions -emit-llvm -o - | FileCheck -check-prefix LINUX %s // RUN: %clang_cc1 %s -triple i686-pc-linux -fms-extensions -emit-llvm -o - | FileCheck -check-prefix LINUX %s // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - | FileCheck -check-prefix PS4 %s Modified: cfe/trunk/test/CodeGen/pragma-detect_mismatch.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-detect_mismatch.c?rev=273558=273557=273558=diff == --- cfe/trunk/test/CodeGen/pragma-detect_mismatch.c (original) +++ cfe/trunk/test/CodeGen/pragma-detect_mismatch.c Thu Jun 23 08:45:33 2016 @@ -1,4 +1,5 @@ // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple thumbv7-windows -fms-extensions -emit-llvm -o - | FileCheck %s #pragma detect_mismatch("test", "1") Modified: cfe/trunk/test/PCH/pragma-comment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-comment.c?rev=273558=273557=273558=diff == --- cfe/trunk/test/PCH/pragma-comment.c (original) +++ cfe/trunk/test/PCH/pragma-comment.c Thu Jun 23 08:45:33 2016 @@ -1,7 +1,10 @@ // Test this without pch. +// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple thumbv7-windows -fms-extensions -emit-llvm -include %s -o - | FileCheck %s // RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple x86_64-pc-win32 -fms-extensions -emit-llvm -include %s -o - | FileCheck %s // Test with pch. +// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple thumbv7-windows -fms-extensions -emit-pch -o %t +// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple thumbv7-windows -fms-extensions -emit-llvm
Re: [PATCH] D21611: Fix small structures calling convention issue for some big endian architectures
john.brawn accepted this revision. john.brawn added a comment. Looks OK from the ARM side as well. http://reviews.llvm.org/D21611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r273191 - [OpenCL] Include opencl-c.h by default as a clang module
I have a patch which may workaround this issue, however I could not test it in Cygwin since I got issues build latest cmake in Cygwin and the downloaded cmake does not work. Could you please try it? Thanks. Sam -Original Message- From: Ismail Donmez [mailto:ism...@i10z.com] Sent: Wednesday, June 22, 2016 1:52 PM To: Liu, Yaxun (Sam)Cc: cfe-commits Subject: Re: r273191 - [OpenCL] Include opencl-c.h by default as a clang module Hi, On Wed, Jun 22, 2016 at 7:55 PM, Liu, Yaxun (Sam) wrote: > The cmake of Cygwin itself does not support llvm. Which cmake did you use on > Cygwin? Thanks. I use native windows cmake and this is the only test that ever failed with this setup. chmod is from native cygwin which seems to be the problem. ismail diff --git a/test/Headers/opencl-c-header.cl b/test/Headers/opencl-c-header.cl index 4ba3b27..3723935 100644 --- a/test/Headers/opencl-c-header.cl +++ b/test/Headers/opencl-c-header.cl @@ -71,11 +71,11 @@ // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s -// RUN: chmod u-w %t/* +// RUN: chmod u-w %t // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s -// RUN: chmod u+w %t/* +// RUN: chmod u+w %t char f(char x) { #if __OPENCL_C_VERSION__ != CL_VERSION_2_0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21611: Fix small structures calling convention issue for some big endian architectures
dsanders accepted this revision. dsanders added a comment. This revision is now accepted and ready to land. In that case the MIPS side of this LGTM. Someone more familiar with ARM should approve it for ARM. http://reviews.llvm.org/D21611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support
DmitryPolukhin updated the summary for this revision. DmitryPolukhin updated this revision to Diff 61642. DmitryPolukhin added a comment. Fixed issue with substitution from function name used in bare type encoding and added test. With this patch Clang passes self build with GCC 5.3.1 headers and C++ libraries so it gives some level of confidence that it works on real apps. PTAL! http://reviews.llvm.org/D18035 Files: lib/AST/ItaniumMangle.cpp lib/Sema/SemaDeclAttr.cpp test/CodeGenCXX/mangle-abi-tag.cpp test/PCH/attrs.c test/SemaCXX/attr-abi-tag-syntax.cpp Index: test/SemaCXX/attr-abi-tag-syntax.cpp === --- test/SemaCXX/attr-abi-tag-syntax.cpp +++ test/SemaCXX/attr-abi-tag-syntax.cpp @@ -16,28 +16,18 @@ // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}} inline namespace N __attribute__((__abi_tag__)) {} -// FIXME: remove this warning as soon as attribute fully supported. -// expected-warning@-2 {{'__abi_tag__' attribute ignored}} } // namespcace N2 __attribute__((abi_tag("B", "A"))) extern int a1; -// FIXME: remove this warning as soon as attribute fully supported. -// expected-warning@-2 {{'abi_tag' attribute ignored}} __attribute__((abi_tag("A", "B"))) extern int a1; // expected-note@-1 {{previous declaration is here}} -// FIXME: remove this warning as soon as attribute fully supported. -// expected-warning@-3 {{'abi_tag' attribute ignored}} __attribute__((abi_tag("A", "C"))) extern int a1; // expected-error@-1 {{'abi_tag' C missing in original declaration}} -// FIXME: remove this warning as soon as attribute fully supported. -// expected-warning@-3 {{'abi_tag' attribute ignored}} extern int a2; // expected-note@-1 {{previous declaration is here}} __attribute__((abi_tag("A")))extern int a2; // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}} -// FIXME: remove this warning as soon as attribute fully supported. -// expected-warning@-3 {{'abi_tag' attribute ignored}} Index: test/PCH/attrs.c === --- test/PCH/attrs.c +++ test/PCH/attrs.c @@ -9,7 +9,7 @@ #define HEADER int f(int) __attribute__((visibility("default"), overloadable)); -int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory"))); // expected-warning {{ignored}} +int g(int) __attribute__((abi_tag("foo", "bar", "baz"), no_sanitize("address", "memory"))); #else Index: test/CodeGenCXX/mangle-abi-tag.cpp === --- /dev/null +++ test/CodeGenCXX/mangle-abi-tag.cpp @@ -0,0 +1,195 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s + +struct __attribute__((abi_tag("A", "B"))) A { }; + +struct B: A { }; + +template + +struct C { +}; + +struct D { A* p; }; + +template +struct __attribute__((abi_tag("C", "D"))) E { +}; + +struct __attribute__((abi_tag("A", "B"))) F { }; + +A a1; +// CHECK-DAG: @_Z2a1B1AB1B = + +__attribute__((abi_tag("C", "D"))) +A a2; +// CHECK-DAG: @_Z2a2B1AB1BB1CB1D = + +B a3; +// CHECK-DAG: @a3 = + +C a4; +// CHECK-DAG: @_Z2a4B1AB1B = + +D a5; +// CHECK-DAG: @a5 = + +E a6; +// CHECK-DAG: @_Z2a6B1CB1D = + +E a7; +// CHECK-DAG: @_Z2a7B1AB1BB1CB1D = + +template<> +struct E { + static float a8; +}; +float E::a8; +// CHECK-DAG: @_ZN1EB1CB1DIfE2a8E = + +template<> +struct E { + static bool a9; +}; +bool E::a9; +// CHECK-DAG: @_ZN1EB1CB1DI1FB1AB1BE2a9E = + +struct __attribute__((abi_tag("A", "B"))) A10 { + virtual ~A10() {} +} a10; +// vtable +// CHECK-DAG: @_ZTV3A10B1AB1B = +// typeinfo +// CHECK-DAG: @_ZTI3A10B1AB1B = + +struct __attribute__((abi_tag("A"))) B11 { + static A10 b; +}; +A10 B11::b; +// B11[abi:A]::b[abi:B] +// CHECK-DAG: @_ZN3B11B1A1bB1BE = + +__attribute__ ((abi_tag("C", "D"))) +void* f1() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f1B1CB1Dv( + +__attribute__ ((abi_tag("C", "D"))) +A* f2() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f2B1AB1BB1CB1Dv( + +B* f3() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f3v( + +C* f4() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f4B1AB1Bv( + +D* f5() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f5v( + +E* f6() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f6B1CB1Dv( + +E* f7() { + return 0; +} +// CHECK-DAG: define {{.*}} @_Z2f7B1AB1BB1CB1Dv( + +void f8(E*) { +} +// CHECK-DAG: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE( + +inline namespace Names1 __attribute__((__abi_tag__)) { +class C1 {}; +} +C1 f9() { return C1(); } +// CHECK-DAG: @_Z2f9B6Names1v( + +inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) { +class C2 {}; +} +C2 f10() { return C2(); } +// CHECK-DAG: @_Z3f10B4Tag1B4Tag2v( + +void
Re: [PATCH] D19586: Misleading Indentation check
Pajesz updated this revision to Diff 61651. Pajesz added a comment. Checker now works with for and while statements as well, new tests were added, other syntactical and logical updates have been made. http://reviews.llvm.org/D19586 Files: clang-tidy/readability/MisleadingIndentationCheck.h clang-tidy/readability/ReadabilityTidyModule.cpp docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-misleading-indentation.rst test/clang-tidy/readability-misleading-indentation.cpp Index: test/clang-tidy/readability-misleading-indentation.cpp === --- /dev/null +++ test/clang-tidy/readability-misleading-indentation.cpp @@ -0,0 +1,131 @@ +// RUN: %check_clang_tidy %s readability-misleading-indentation %t + +void foo1() {} +void foo2() {} + +int main() { + bool cond1 = true; + bool cond2 = true; + + if (cond1) +if (cond2) + foo1(); +else + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: wrong indentation, else belongs to + // if(cond2) statement + // CHECK-FIXES: {{^}} // comment + + if (cond1) { +if (cond2) + foo1(); + } else +foo2(); // ok, else belongs to if(cond1) statement + + if (cond1) +if (cond2) + foo1(); +else + foo2(); // ok, indentation matches to syntactical structure + + if (cond1) +foo1(); + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond1) + // CHECK-FIXES: {{^}} // comment + + if (cond2) +foo1(); + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond2) + // CHECK-FIXES: {{^}} // comment + + if (cond1) { +foo1(); + } + foo2(); // ok + + if (cond1) +foo1(); + foo2(); // ok + + if (cond1) +foo1(); + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of if(cond1) + // CHECK-FIXES: {{^}} // comment + foo2(); // no need for redundant warning + + if (cond1) { // ok +foo1(); + } else { +foo2(); + } + + if (cond1) +foo1(); + else +foo2(); // ok + + if (cond1) { // ok +foo1(); + } else { +foo2(); + } + + if (cond1) // ok + { +foo1(); + } else { +foo2(); + } + + if (cond1) // ok + { +foo1(); + } else { +foo2(); + } + + while (cond1) { +foo1(); + } + foo2(); // ok + + while (cond1) +foo1(); + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of while(cond1) + // CHECK-FIXES: {{^}} // comment + + while (cond1) { +foo1(); + } + foo2(); // ok + + while (cond1) +foo1(); + foo2(); // ok + + for (;;) { +foo1(); + } + foo2(); // ok + + for (;;) +foo1(); + foo2(); // comment + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: not part of for(;;) + // CHECK-FIXES: {{^}} // comment + + for (;;) { +foo1(); + } + foo2(); // ok + + for (;;) +foo1(); + foo2(); // ok + + return 0; +} Index: docs/clang-tidy/checks/readability-misleading-indentation.rst === --- /dev/null +++ docs/clang-tidy/checks/readability-misleading-indentation.rst @@ -0,0 +1,36 @@ +.. title:: clang-tidy - readability-misleading-indentation + +readability-misleading-indentation +== + +Description + +Correct indentation helps to understand code. Mismatch of the syntactical +structure and the indentation of the code may reveal serious problems. +Missing braces can also cause some problems in analyzing the code, +therefore it is important to use braces. + +The way to avoid dangling else is to always check that an "else" belongs +to the "if" that begins in the same column. + +You can omit braces when your inner part of e.g. an "if" statement has only +one statement in it. Although in that case you should begin the next statement +in the same column with the "if". + +Examples: + +.. code-block:: c++ + + // Dangling else: + + if (cond1) +if (cond2) + foo1(); + else +foo2(); // wrong indentation: else belongs to if(cond2) statement + + // Missing braces + + if (cond1) +foo1(); +foo2(); // not part of if(cond1) Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -93,6 +93,7 @@ readability-identifier-naming readability-implicit-bool-cast readability-inconsistent-declaration-parameter-name + readability-misleading-indentation readability-named-parameter readability-redundant-control-flow readability-redundant-smartptr-get Index: clang-tidy/readability/ReadabilityTidyModule.cpp === --- clang-tidy/readability/ReadabilityTidyModule.cpp +++ clang-tidy/readability/ReadabilityTidyModule.cpp @@ -17,6 +17,7 @@ #include
Re: [PATCH] D21611: Fix small structures calling convention issue for some big endian architectures
spetrovic added a comment. Yes, I tried all caller - callee combinations for ARM32 big endian and MIPS/MIPS64 big endian, and it works properly with this patch. http://reviews.llvm.org/D21611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21637: [libcxx] Don't use pthread initializers in constexpr constructors
elram created this revision. elram added a reviewer: EricWF. elram added a subscriber: cfe-commits. Some pthread implementations use volatile types in their structs. C++11 does not allow initializing volatile types in constexpr constructors. This fixes building libcxx on musl-libc and NetBSD. http://reviews.llvm.org/D21637 Files: include/__mutex_base Index: include/__mutex_base === --- include/__mutex_base +++ include/__mutex_base @@ -34,15 +34,14 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex { -__libcpp_mutex_t __m_; +__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR -constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {} -#else -mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} +constexpr #endif +mutex() _NOEXCEPT = default; ~mutex(); private: @@ -287,15 +286,15 @@ class _LIBCPP_TYPE_VIS condition_variable { -__libcpp_condvar_t __cv_; +__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; + public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR -constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {} -#else -condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} +constexpr #endif -~condition_variable(); +condition_variable() _NOEXCEPT; +~condition_variable() _NOEXCEPT; private: condition_variable(const condition_variable&); // = delete; Index: include/__mutex_base === --- include/__mutex_base +++ include/__mutex_base @@ -34,15 +34,14 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex { -__libcpp_mutex_t __m_; +__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR -constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {} -#else -mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} +constexpr #endif +mutex() _NOEXCEPT = default; ~mutex(); private: @@ -287,15 +286,15 @@ class _LIBCPP_TYPE_VIS condition_variable { -__libcpp_condvar_t __cv_; +__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; + public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_CONSTEXPR -constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {} -#else -condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} +constexpr #endif -~condition_variable(); +condition_variable() _NOEXCEPT; +~condition_variable() _NOEXCEPT; private: condition_variable(const condition_variable&); // = delete; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21601: Make tooling::applyAllReplacements return llvm::Expected instead of empty string to indicate potential error.
klimek added inline comments. Comment at: include/clang/Tooling/Core/Replacement.h:170 @@ +169,3 @@ +/// This completely ignores the path stored in each replacement. If all +/// replacements are applied successfully, this returns the result code; +/// otherwise, an llvm::Error carrying llvm::StringError is returned (the Error When I read "result code" I imagine a number. Perhaps "returns the code with the replacements applied" or "resulting code"? Comment at: lib/Format/Format.cpp:1395 @@ -1394,2 +1394,3 @@ +// If any replacements in \p Replaces fails to apply, this returns \p Replaces. template Why would we want to return the same replacements? http://reviews.llvm.org/D21601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21642: [clang-tidy] boost-use-to-string arg expr location bugfix
Prazek updated this revision to Diff 61665. Prazek added a comment. - small fix http://reviews.llvm.org/D21642 Files: clang-tidy/boost/UseToStringCheck.cpp test/clang-tidy/boost-use-to-string.cpp Index: test/clang-tidy/boost-use-to-string.cpp === --- test/clang-tidy/boost-use-to-string.cpp +++ test/clang-tidy/boost-use-to-string.cpp @@ -147,3 +147,23 @@ string_as_T(); string_as_T(); } + +struct Fields { + int integer; + float floating; + Fields* wierd; + const int () const {return integer;} +}; + +void testFields() { + Fields fields; + auto s1 = boost::lexical_cast(fields.integer); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: auto s1 = std::to_string(fields.integer); + + auto s2 = boost::lexical_cast(fields.floating); + auto s3 = boost::lexical_cast(fields.wierd); + auto s4 = boost::lexical_cast(fields.getConstInteger()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: auto s4 = std::to_string(fields.getConstInteger()); +} Index: clang-tidy/boost/UseToStringCheck.cpp === --- clang-tidy/boost/UseToStringCheck.cpp +++ clang-tidy/boost/UseToStringCheck.cpp @@ -64,7 +64,7 @@ Diag << FixItHint::CreateReplacement( CharSourceRange::getCharRange(Call->getLocStart(), -Call->getArg(0)->getExprLoc()), +Call->getArg(0)->getLocStart()), (llvm::Twine("std::to_") + StringType + "(").str()); } Index: test/clang-tidy/boost-use-to-string.cpp === --- test/clang-tidy/boost-use-to-string.cpp +++ test/clang-tidy/boost-use-to-string.cpp @@ -147,3 +147,23 @@ string_as_T(); string_as_T(); } + +struct Fields { + int integer; + float floating; + Fields* wierd; + const int () const {return integer;} +}; + +void testFields() { + Fields fields; + auto s1 = boost::lexical_cast(fields.integer); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: auto s1 = std::to_string(fields.integer); + + auto s2 = boost::lexical_cast(fields.floating); + auto s3 = boost::lexical_cast(fields.wierd); + auto s4 = boost::lexical_cast(fields.getConstInteger()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: auto s4 = std::to_string(fields.getConstInteger()); +} Index: clang-tidy/boost/UseToStringCheck.cpp === --- clang-tidy/boost/UseToStringCheck.cpp +++ clang-tidy/boost/UseToStringCheck.cpp @@ -64,7 +64,7 @@ Diag << FixItHint::CreateReplacement( CharSourceRange::getCharRange(Call->getLocStart(), -Call->getArg(0)->getExprLoc()), +Call->getArg(0)->getLocStart()), (llvm::Twine("std::to_") + StringType + "(").str()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0
bader added a comment. Hi Anastasia, Sorry for the delay. I have just a few comments. Thanks, Alexey Comment at: lib/Sema/SemaChecking.cpp:95 @@ +94,3 @@ + IllegalParams = true; + break; +} It looks like this function will report only first invalid parameter. Can we report all of them by moving code from lines 109-120 inside the loop? Comment at: lib/Sema/SemaChecking.cpp:145 @@ +144,3 @@ + for (unsigned i = Start; i < End; ++i) +if (!TheCall->getArg(i)->getType().getTypePtr()->isIntegerType()) + return false; If I understand it correctly the intention is to convert this integer type to i32. Am I right? By the spec it must be unsigned 32-bit integer, not just any integer type. Comment at: lib/Sema/SemaChecking.cpp:201 @@ +200,3 @@ +///clk_event_t *event_ret, +///void (^block)(void*, ...), +///uint size0, ...) block arguments must be pointers to the local memory (the same as previous declaration). Comment at: lib/Sema/SemaChecking.cpp:249 @@ +248,3 @@ +} else + return checkBlockArgs(S, Arg3); + } else if (NumArgs >= 5) { Could you clarify that code path? My understanding is that if NumArgs ==4, clang should except only block with empty parameter list. Am I right? /// int enqueue_kernel(queue_t queue, ///kernel_enqueue_flags_t flags, ///const ndrange_t ndrange, ///void (^block)(void)) Comment at: lib/Sema/SemaChecking.cpp:250 @@ +249,3 @@ + return checkBlockArgs(S, Arg3); + } else if (NumArgs >= 5) { +// we can have block + varargs. This check is redundant. It's known to be always true at this point. Comment at: lib/Sema/SemaChecking.cpp:297 @@ +296,3 @@ +return false; + else if (NumArgs >= 7) // check if varargs are correct types. +return checkEnqueueVariadicArgs(S, TheCall, Arg6, 7); This check is redundant. This condition is known to be true at line 250. Comment at: lib/Sema/SemaChecking.cpp:302 @@ +301,3 @@ + + // None of the specific case has been detected, give generic error + S.Diag(TheCall->getLocStart(), Shouldn't by default we return false and report an error only if checks above find inconsistency? I expect code to be much simpler with this approach. http://reviews.llvm.org/D20249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21642: [clang-tidy] boost-use-to-string arg expr location bugfix
Prazek created this revision. Prazek added reviewers: alexfh, sbenza, hokein. Prazek added a subscriber: cfe-commits. getExprLoc returns location after dot for member call. http://reviews.llvm.org/D21642 Files: clang-tidy/boost/UseToStringCheck.cpp test/clang-tidy/boost-use-to-string.cpp Index: test/clang-tidy/boost-use-to-string.cpp === --- test/clang-tidy/boost-use-to-string.cpp +++ test/clang-tidy/boost-use-to-string.cpp @@ -147,3 +147,23 @@ string_as_T(); string_as_T(); } + +struct Fields { + int integer; + float floating; + Fields* wierd; + const int () const {return integer;} +}; + +void testFields() { + Fields fields; + auto s1 = boost::lexical_cast(fields.integer); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: std::to_string(fields.integer); + + auto s2 = boost::lexical_cast(fields.floating); + auto s3 = boost::lexical_cast(fields.wierd); + auto s4 = boost::lexical_cast(fields.getConstInteger()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: std::to_string(fields.getConstInteger()); +} Index: clang-tidy/boost/UseToStringCheck.cpp === --- clang-tidy/boost/UseToStringCheck.cpp +++ clang-tidy/boost/UseToStringCheck.cpp @@ -64,7 +64,7 @@ Diag << FixItHint::CreateReplacement( CharSourceRange::getCharRange(Call->getLocStart(), -Call->getArg(0)->getExprLoc()), +Call->getArg(0)->getLocStart()), (llvm::Twine("std::to_") + StringType + "(").str()); } Index: test/clang-tidy/boost-use-to-string.cpp === --- test/clang-tidy/boost-use-to-string.cpp +++ test/clang-tidy/boost-use-to-string.cpp @@ -147,3 +147,23 @@ string_as_T(); string_as_T(); } + +struct Fields { + int integer; + float floating; + Fields* wierd; + const int () const {return integer;} +}; + +void testFields() { + Fields fields; + auto s1 = boost::lexical_cast(fields.integer); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: std::to_string(fields.integer); + + auto s2 = boost::lexical_cast(fields.floating); + auto s3 = boost::lexical_cast(fields.wierd); + auto s4 = boost::lexical_cast(fields.getConstInteger()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string{{..}} + // CHECK-FIXES: std::to_string(fields.getConstInteger()); +} Index: clang-tidy/boost/UseToStringCheck.cpp === --- clang-tidy/boost/UseToStringCheck.cpp +++ clang-tidy/boost/UseToStringCheck.cpp @@ -64,7 +64,7 @@ Diag << FixItHint::CreateReplacement( CharSourceRange::getCharRange(Call->getLocStart(), -Call->getArg(0)->getExprLoc()), +Call->getArg(0)->getLocStart()), (llvm::Twine("std::to_") + StringType + "(").str()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21641: Use ArgList::hasFlag to check if -miamcu/-mno-iamcu is passed. NFC.
aturetsk added a comment. Hi Bruno, As you suggested I changed -miamcu/-mno-iamcu handling code to use hasFlag. http://reviews.llvm.org/D21641 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21641: Use ArgList::hasFlag to check if -miamcu/-mno-iamcu is passed. NFC.
aturetsk created this revision. aturetsk added a reviewer: bruno. aturetsk added a subscriber: cfe-commits. Use ArgList::hasFlag to check if -miamcu/-mno-iamcu is passed. NFC. http://reviews.llvm.org/D21641 Files: lib/Driver/Driver.cpp lib/Driver/Tools.cpp Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2243,12 +2243,10 @@ } // Set flags to support MCU ABI. - if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { -if (A->getOption().matches(options::OPT_miamcu)) { - CmdArgs.push_back("-mfloat-abi"); - CmdArgs.push_back("soft"); - CmdArgs.push_back("-mstack-alignment=4"); -} + if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) { +CmdArgs.push_back("-mfloat-abi"); +CmdArgs.push_back("soft"); +CmdArgs.push_back("-mstack-alignment=4"); } } Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -280,9 +280,8 @@ } // Enforce -static if -miamcu is present. - if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) -if (Ar->getOption().matches(options::OPT_miamcu)) - DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); + if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) +DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); // Add a default value of -mlinker-version=, if one was given and the user // didn't specify one. @@ -376,24 +375,22 @@ } // Handle -miamcu flag. - if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { -if (Ar->getOption().matches(options::OPT_miamcu)) { - if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86) -D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu" - << Target.str(); - - if (A && !A->getOption().matches(options::OPT_m32)) -D.Diag(diag::err_drv_argument_not_allowed_with) -<< "-miamcu" << A->getBaseArg().getAsString(Args); - - Target.setArch(llvm::Triple::x86); - Target.setArchName("i586"); - Target.setEnvironment(llvm::Triple::UnknownEnvironment); - Target.setEnvironmentName(""); - Target.setOS(llvm::Triple::ELFIAMCU); - Target.setVendor(llvm::Triple::UnknownVendor); - Target.setVendorName("intel"); -} + if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) { +if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86) + D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu" + << Target.str(); + +if (A && !A->getOption().matches(options::OPT_m32)) + D.Diag(diag::err_drv_argument_not_allowed_with) + << "-miamcu" << A->getBaseArg().getAsString(Args); + +Target.setArch(llvm::Triple::x86); +Target.setArchName("i586"); +Target.setEnvironment(llvm::Triple::UnknownEnvironment); +Target.setEnvironmentName(""); +Target.setOS(llvm::Triple::ELFIAMCU); +Target.setVendor(llvm::Triple::UnknownVendor); +Target.setVendorName("intel"); } return Target; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2243,12 +2243,10 @@ } // Set flags to support MCU ABI. - if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { -if (A->getOption().matches(options::OPT_miamcu)) { - CmdArgs.push_back("-mfloat-abi"); - CmdArgs.push_back("soft"); - CmdArgs.push_back("-mstack-alignment=4"); -} + if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) { +CmdArgs.push_back("-mfloat-abi"); +CmdArgs.push_back("soft"); +CmdArgs.push_back("-mstack-alignment=4"); } } Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -280,9 +280,8 @@ } // Enforce -static if -miamcu is present. - if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) -if (Ar->getOption().matches(options::OPT_miamcu)) - DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); + if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) +DAL->AddFlagArg(0, Opts->getOption(options::OPT_static)); // Add a default value of -mlinker-version=, if one was given and the user // didn't specify one. @@ -376,24 +375,22 @@ } // Handle -miamcu flag. - if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) { -if (Ar->getOption().matches(options::OPT_miamcu)) { - if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86) -D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu" -
Re: [PATCH] D21504: [X86] add _mm_loadu_si64
AsafBadouh updated this revision to Diff 61661. AsafBadouh added a comment. add align to CHECK Repository: rL LLVM http://reviews.llvm.org/D21504 Files: tools/clang/lib/Headers/emmintrin.h tools/clang/test/CodeGen/sse2-builtins.c Index: tools/clang/lib/Headers/emmintrin.h === --- tools/clang/lib/Headers/emmintrin.h +++ tools/clang/lib/Headers/emmintrin.h @@ -505,6 +505,16 @@ return ((struct __loadu_pd*)__dp)->__v; } +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_loadu_si64(void const *__a) +{ + struct __loadu_si64 { +long long __v; + } __attribute__((__packed__, __may_alias__)); + long long __u = ((struct __loadu_si64*)__a)->__v; + return (__m128i){__u, 0L}; +} + static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_load_sd(double const *__dp) { Index: tools/clang/test/CodeGen/sse2-builtins.c === --- tools/clang/test/CodeGen/sse2-builtins.c +++ tools/clang/test/CodeGen/sse2-builtins.c @@ -1520,3 +1520,12 @@ // CHECK: xor <2 x i64> %{{.*}}, %{{.*}} return _mm_xor_si128(A, B); } + +__m128i test_mm_loadu_si64(void const* A) { + // CHECK-LABEL: test_mm_loadu_si64 + // CHECK: load i64, i64* %{{.*}}, align 1 + // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0 + // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1 + return _mm_loadu_si64(A); +} + Index: tools/clang/lib/Headers/emmintrin.h === --- tools/clang/lib/Headers/emmintrin.h +++ tools/clang/lib/Headers/emmintrin.h @@ -505,6 +505,16 @@ return ((struct __loadu_pd*)__dp)->__v; } +static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_loadu_si64(void const *__a) +{ + struct __loadu_si64 { +long long __v; + } __attribute__((__packed__, __may_alias__)); + long long __u = ((struct __loadu_si64*)__a)->__v; + return (__m128i){__u, 0L}; +} + static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_load_sd(double const *__dp) { Index: tools/clang/test/CodeGen/sse2-builtins.c === --- tools/clang/test/CodeGen/sse2-builtins.c +++ tools/clang/test/CodeGen/sse2-builtins.c @@ -1520,3 +1520,12 @@ // CHECK: xor <2 x i64> %{{.*}}, %{{.*}} return _mm_xor_si128(A, B); } + +__m128i test_mm_loadu_si64(void const* A) { + // CHECK-LABEL: test_mm_loadu_si64 + // CHECK: load i64, i64* %{{.*}}, align 1 + // CHECK: insertelement <2 x i64> undef, i64 %{{.*}}, i32 0 + // CHECK: insertelement <2 x i64> %{{.*}}, i64 0, i32 1 + return _mm_loadu_si64(A); +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21031: [OpenCL] Allow -cl-std and other standard -cl- options in driver
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Thanks! http://reviews.llvm.org/D21031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21611: Fix small structures calling convention issue for some big endian architectures
dsanders added a comment. This change agrees with what I think the calling convention is and the documentation. However, I've hit quite a few discrepancies between the documented calling convention and the de-facto one implemented by gcc so I'm wary of going by that alone. Have you tried putting the caller and callee side of this test in different compilation units and then linking a gcc-compiled caller with a clang-compiled callee (and then repeating that for the other three combinations) like the test generator in tools/clang/utils/ABITest does? Does this produce a program that executes correctly for all four combinations? > > Hmm. On MIPS64, a slot is 64 bits, right? How is a float passed? > Oh, floats are promoted to doubles in varargs, of course, which neatly makes > that an impossible situation. > > My inclination is that the right condition here is that only integer types > should be right-justified in their slot, but I'll admit to not having an easy > example of a type for which your condition doesn't work. Floats are left justified according to the 'MIPSproTM N32 ABI Handbook' (which also discusses the O32 and N64 ABI's) but I can't think of a test case that would expose a problem due to the promotion to double. Comment at: test/CodeGen/struct-union-BE.c:1-3 @@ +1,4 @@ +// RUN: %clang -O2 -target mips-linux-gnu -EB -S -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS +// RUN: %clang -O2 -target mips64-linux-gnu -EB -S -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64 +// RUN: %clang -O2 -target armeb-linux-gnueabihf -march=armv7a -EB -S -emit-llvm %s -o - | FileCheck %s -check-prefix=ARM + Do we need %clang and -O2? Can we use %clang_cc1 and the default optimization level instead? http://reviews.llvm.org/D21611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21507: Changes after running check modernize-use-emplace (D20964)
Prazek added a comment. In http://reviews.llvm.org/D21507#464791, @vsk wrote: > Neat! It would help to upload a git-clang-format'd. Fwiw I only managed to > look over the changes in lib/{ARCMigrate,AST,Analysis}. > > Have you run check-all and the full test-suite? Yep, didn't have any problems with dat Repository: rL LLVM http://reviews.llvm.org/D21507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21597: clang-format: [JS] recognize more type locations.
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Basically looks good. Comment at: lib/Format/TokenAnnotator.cpp:155 @@ +154,3 @@ +} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && + Left->Previous->is(TT_JsTypeColon)) { + // let x: (SomeType); I'd merge this one in with the previous.. And maybe even the one from above so that we end up with: } else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous && (Line.First->is(Keywords.kw_type) || Left->Previous->isOneOf(Keywords.kw_function, TT_JsTypeColon) || (Left->Previous->endsSequence(tok::identifier, Keywords.kw_function { (in order for Line.First to be "type", Left->Previous cannot be nullptr, so this should be equivalent) Comment at: lib/Format/TokenAnnotator.cpp:664 @@ -655,2 +663,3 @@ } + return true; nit: undo Comment at: lib/Format/TokenAnnotator.cpp:926 @@ +925,3 @@ +// Type aliases use `type X = ...;` in TypeScript. +!(Style.Language == FormatStyle::LK_JavaScript && + Line.First->is(Keywords.kw_type)) && I'd move the ! into the parentheses, but doesn't matter much. http://reviews.llvm.org/D21597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273553 - clang-format: [Proto] Use more compact format for text-formatted options
Author: djasper Date: Thu Jun 23 04:40:19 2016 New Revision: 273553 URL: http://llvm.org/viewvc/llvm-project?rev=273553=rev Log: clang-format: [Proto] Use more compact format for text-formatted options Before: enum Type { UNKNOWN = 0 [(some_options) = { a: aa, b: bb }]; }; After: enum Type { UNKNOWN = 0 [(some_options) = {a: aa, b: bb}]; }; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestProto.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=273553=273552=273553=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Jun 23 04:40:19 2016 @@ -2332,9 +2332,6 @@ bool TokenAnnotator::mustBreakBefore(con return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) || (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) || (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct); - if (Style.Language == FormatStyle::LK_Proto && Left.isNot(tok::l_brace) && - Right.is(TT_SelectorName)) -return true; if (Left.is(TT_ObjCBlockLBrace) && !Style.AllowShortBlocksOnASingleLine) return true; Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=273553=273552=273553=diff == --- cfe/trunk/unittests/Format/FormatTestProto.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestProto.cpp Thu Jun 23 04:40:19 2016 @@ -74,8 +74,11 @@ TEST_F(FormatTestProto, FormatsEnums) { " TYPE_B = 2;\n" "};"); verifyFormat("enum Type {\n" + " UNKNOWN = 0 [(some_options) = {a: aa, b: bb}];\n" + "};"); + verifyFormat("enum Type {\n" " UNKNOWN = 0 [(some_options) = {\n" - "a: aa,\n" + "a: aa, // wrap\n" "b: bb\n" " }];\n" "};"); @@ -153,10 +156,7 @@ TEST_F(FormatTestProto, FormatsOptions) " field_a: OK\n" " field_b: \"OK\"\n" " field_c: \"OK\"\n" - " msg_field: {\n" - "field_d: 123\n" - "field_e: OK\n" - " }\n" + " msg_field: {field_d: 123 field_e: OK}\n" "};"); verifyFormat("option (MyProto.options) = {\n" " field_a: OK // Comment\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273552 - Attempt to fix MIPS buildbots after r273425.
Author: dsanders Date: Thu Jun 23 04:29:38 2016 New Revision: 273552 URL: http://llvm.org/viewvc/llvm-project?rev=273552=rev Log: Attempt to fix MIPS buildbots after r273425. MIPS has a 'signext' attribute that was causing the check to fail. Modified: cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl Modified: cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl?rev=273552=273551=273552=diff == --- cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl Thu Jun 23 04:29:38 2016 @@ -3,10 +3,10 @@ typedef unsigned int uint4 __attribute__((ext_vector_type(4))); kernel __attribute__((vec_type_hint(int))) __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {} -// CHECK: define void @kernel1(i32 %a) {{[^{]+}} !vec_type_hint ![[MD1:[0-9]+]] !reqd_work_group_size ![[MD2:[0-9]+]] +// CHECK: define void @kernel1(i32 {{[^%]*}}%a) {{[^{]+}} !vec_type_hint ![[MD1:[0-9]+]] !reqd_work_group_size ![[MD2:[0-9]+]] kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {} -// CHECK: define void @kernel2(i32 %a) {{[^{]+}} !vec_type_hint ![[MD3:[0-9]+]] !work_group_size_hint ![[MD4:[0-9]+]] +// CHECK: define void @kernel2(i32 {{[^%]*}}%a) {{[^{]+}} !vec_type_hint ![[MD3:[0-9]+]] !work_group_size_hint ![[MD4:[0-9]+]] // CHECK: [[MD1]] = !{i32 undef, i32 1} // CHECK: [[MD2]] = !{i32 1, i32 2, i32 4} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r273548 - Rearrange condition handling so that semantic checks on a condition variable
Author: rsmith Date: Thu Jun 23 03:41:20 2016 New Revision: 273548 URL: http://llvm.org/viewvc/llvm-project?rev=273548=rev Log: Rearrange condition handling so that semantic checks on a condition variable are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseStmt.cpp cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/FixIt/fixit-vexing-parse.cpp cfe/trunk/test/Parser/cxx0x-condition.cpp cfe/trunk/test/SemaCXX/crashes.cpp cfe/trunk/test/SemaCXX/for-range-examples.cpp cfe/trunk/test/SemaObjCXX/foreach.mm Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=273548=273547=273548=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Thu Jun 23 03:41:20 2016 @@ -1588,8 +1588,8 @@ private: //======// // C++ if/switch/while condition expression. - bool ParseCXXCondition(ExprResult , Decl *, - SourceLocation Loc, bool ConvertToBoolean); + Sema::ConditionResult ParseCXXCondition(SourceLocation Loc, + Sema::ConditionKind CK); //======// // C++ Coroutines @@ -1680,10 +1680,9 @@ private: unsigned ScopeFlags); void ParseCompoundStatementLeadingPragmas(); StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); - bool ParseParenExprOrCondition(ExprResult , - Decl *, + bool ParseParenExprOrCondition(Sema::ConditionResult , SourceLocation Loc, - bool ConvertToBoolean); + Sema::ConditionKind CK); StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=273548=273547=273548=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jun 23 03:41:20 2016 @@ -3298,6 +3298,7 @@ public: public: class FullExprArg { public: +FullExprArg() : E(nullptr) { } FullExprArg(Sema ) : E(nullptr) { } ExprResult release() { @@ -3391,27 +3392,23 @@ public: ArrayRef Attrs, Stmt *SubStmt); - StmtResult ActOnIfStmt(SourceLocation IfLoc, - FullExprArg CondVal, Decl *CondVar, - Stmt *ThenVal, - SourceLocation ElseLoc, Stmt *ElseVal); + class ConditionResult; + StmtResult ActOnIfStmt(SourceLocation IfLoc, ConditionResult Cond, + Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal); StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, -Expr *Cond, -Decl *CondVar); +ConditionResult Cond); StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body); - StmtResult ActOnWhileStmt(SourceLocation WhileLoc, -FullExprArg Cond, -Decl *CondVar, Stmt *Body); + StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, +Stmt *Body); StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, - SourceLocation WhileLoc, - SourceLocation CondLParen, Expr *Cond, - SourceLocation CondRParen); + SourceLocation WhileLoc, SourceLocation CondLParen, + Expr *Cond, SourceLocation CondRParen); StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, - Stmt *First,
r273533 - [AVX512] Replace masked unpack builtins with shufflevector and selects.
Author: ctopper Date: Thu Jun 23 01:36:42 2016 New Revision: 273533 URL: http://llvm.org/viewvc/llvm-project?rev=273533=rev Log: [AVX512] Replace masked unpack builtins with shufflevector and selects. Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/Headers/avx512bwintrin.h cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/lib/Headers/avx512vlbwintrin.h cfe/trunk/lib/Headers/avx512vlintrin.h cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=273533=273532=273533=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Thu Jun 23 01:36:42 2016 @@ -1469,10 +1469,6 @@ TARGET_BUILTIN(__builtin_ia32_vpermt2var TARGET_BUILTIN(__builtin_ia32_pmovswb512_mask, "V32cV32sV32cUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_pmovuswb512_mask, "V32cV32sV32cUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_pmovwb512_mask, "V32cV32sV32cUi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhbw512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhwd512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklbw512_mask, "V64cV64cV64cV64cULLi", "", "avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklwd512_mask, "V32sV32sV32sV32sUi", "", "avx512bw") TARGET_BUILTIN(__builtin_ia32_cvtpd2qq128_mask, "V2LLiV2dV2LLiUc", "", "avx512vl,avx512dq") TARGET_BUILTIN(__builtin_ia32_cvtpd2qq256_mask, "V4LLiV4dV4LLiUc", "", "avx512vl,avx512dq") TARGET_BUILTIN(__builtin_ia32_cvtpd2uqq128_mask, "V2LLiV2dV2LLiUc", "", "avx512vl,avx512dq") @@ -1525,14 +1521,6 @@ TARGET_BUILTIN(__builtin_ia32_pmulhuw128 TARGET_BUILTIN(__builtin_ia32_pmulhuw256_mask, "V16sV16sV16sV16sUs", "", "avx512vl,avx512bw") TARGET_BUILTIN(__builtin_ia32_pmulhw128_mask, "V8sV8sV8sV8sUc", "", "avx512vl,avx512bw") TARGET_BUILTIN(__builtin_ia32_pmulhw256_mask, "V16sV16sV16sV16sUs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhbw128_mask, "V16cV16cV16cV16cUs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhbw256_mask, "V32cV32cV32cV32cUi", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhwd128_mask, "V8sV8sV8sV8sUc", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpckhwd256_mask, "V16sV16sV16sV16sUs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklbw128_mask, "V16cV16cV16cV16cUs", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklbw256_mask, "V32cV32cV32cV32cUi", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklwd128_mask, "V8sV8sV8sV8sUc", "", "avx512vl,avx512bw") -TARGET_BUILTIN(__builtin_ia32_punpcklwd256_mask, "V16sV16sV16sV16sUs", "", "avx512vl,avx512bw") TARGET_BUILTIN(__builtin_ia32_cvtpd2qq512_mask, "V8LLiV8dV8LLiUcIi", "", "avx512dq") TARGET_BUILTIN(__builtin_ia32_cvtpd2uqq512_mask, "V8LLiV8dV8LLiUcIi", "", "avx512dq") TARGET_BUILTIN(__builtin_ia32_cvtps2qq512_mask, "V8LLiV8fV8LLiUcIi", "", "avx512dq") @@ -1776,18 +1764,6 @@ TARGET_BUILTIN(__builtin_ia32_storeupd12 TARGET_BUILTIN(__builtin_ia32_storeupd256_mask, "vV4d*V4dUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_storeups128_mask, "vV4f*V4fUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_storeups256_mask, "vV8f*V8fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpckhpd512_mask, "V8dV8dV8dV8dUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_unpckhps512_mask, "V16fV16fV16fV16fUs","","avx512f") -TARGET_BUILTIN(__builtin_ia32_unpcklpd512_mask, "V8dV8dV8dV8dUc","","avx512f") -TARGET_BUILTIN(__builtin_ia32_unpcklps512_mask, "V16fV16fV16fV16fUs","","avx512f") -TARGET_BUILTIN(__builtin_ia32_unpckhpd128_mask, "V2dV2dV2dV2dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpckhpd256_mask, "V4dV4dV4dV4dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpckhps128_mask, "V4fV4fV4fV4fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpckhps256_mask, "V8fV8fV8fV8fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpcklpd128_mask, "V2dV2dV2dV2dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpcklpd256_mask, "V4dV4dV4dV4dUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpcklps128_mask, "V4fV4fV4fV4fUc","","avx512vl") -TARGET_BUILTIN(__builtin_ia32_unpcklps256_mask, "V8fV8fV8fV8fUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_rcp14pd128_mask, "V2dV2dV2dUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_rcp14pd256_mask, "V4dV4dV4dUc","","avx512vl") TARGET_BUILTIN(__builtin_ia32_rcp14ps128_mask, "V4fV4fV4fUc","","avx512vl") @@ -1854,18 +1830,6 @@ TARGET_BUILTIN(__builtin_ia32_ptestnmq12 TARGET_BUILTIN(__builtin_ia32_ptestnmq256, "UcV4LLiV4LLiUc","","avx512vl")