Re: [PATCH] D24879: [libc++] Remove math_win32.h
EricWF accepted this revision. EricWF added a comment. This revision is now accepted and ready to land. I'll take your word for it. Thanks for the patch. https://reviews.llvm.org/D24879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24754: [cleanup] Remove excessive padding from RedeclarableResult
This revision was automatically updated to reflect the committed changes. Closed by commit rL282322: Remove excessive padding from RedeclarableResult (authored by alexshap). Changed prior to commit: https://reviews.llvm.org/D24754?vs=71903=72388#toc Repository: rL LLVM https://reviews.llvm.org/D24754 Files: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Index: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp === --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp @@ -146,13 +146,13 @@ /// Results from loading a RedeclarableDecl. class RedeclarableResult { - GlobalDeclID FirstID; Decl *MergeWith; + GlobalDeclID FirstID; bool IsKeyDecl; public: - RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl) - : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {} + RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl) +: MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {} /// \brief Retrieve the first ID. GlobalDeclID getFirstID() const { return FirstID; } @@ -2311,7 +2311,7 @@ if (IsFirstLocalDecl) Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset)); - return RedeclarableResult(FirstDeclID, MergeWith, IsKeyDecl); + return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl); } /// \brief Attempts to merge the given declaration (D) with another declaration @@ -2353,9 +2353,10 @@ DeclID DsID, bool IsKeyDecl) { auto *DPattern = D->getTemplatedDecl(); auto *ExistingPattern = Existing->getTemplatedDecl(); - RedeclarableResult Result(DPattern->getCanonicalDecl()->getGlobalID(), -/*MergeWith*/ ExistingPattern, IsKeyDecl); - + RedeclarableResult Result(/*MergeWith*/ ExistingPattern, +DPattern->getCanonicalDecl()->getGlobalID(), +IsKeyDecl); + if (auto *DClass = dyn_cast(DPattern)) { // Merge with any existing definition. // FIXME: This is duplicated in several places. Refactor. Index: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp === --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp @@ -146,13 +146,13 @@ /// Results from loading a RedeclarableDecl. class RedeclarableResult { - GlobalDeclID FirstID; Decl *MergeWith; + GlobalDeclID FirstID; bool IsKeyDecl; public: - RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl) - : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {} + RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl) +: MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {} /// \brief Retrieve the first ID. GlobalDeclID getFirstID() const { return FirstID; } @@ -2311,7 +2311,7 @@ if (IsFirstLocalDecl) Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset)); - return RedeclarableResult(FirstDeclID, MergeWith, IsKeyDecl); + return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl); } /// \brief Attempts to merge the given declaration (D) with another declaration @@ -2353,9 +2353,10 @@ DeclID DsID, bool IsKeyDecl) { auto *DPattern = D->getTemplatedDecl(); auto *ExistingPattern = Existing->getTemplatedDecl(); - RedeclarableResult Result(DPattern->getCanonicalDecl()->getGlobalID(), -/*MergeWith*/ ExistingPattern, IsKeyDecl); - + RedeclarableResult Result(/*MergeWith*/ ExistingPattern, +DPattern->getCanonicalDecl()->getGlobalID(), +IsKeyDecl); + if (auto *DClass = dyn_cast(DPattern)) { // Merge with any existing definition. // FIXME: This is duplicated in several places. Refactor. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282322 - Remove excessive padding from RedeclarableResult
Author: alexshap Date: Fri Sep 23 23:21:53 2016 New Revision: 282322 URL: http://llvm.org/viewvc/llvm-project?rev=282322=rev Log: Remove excessive padding from RedeclarableResult This diff reorders the fields of the class RedeclarableResult to remove excessive padding. Test plan: make -j8 check-clang Differential revision: https://reviews.llvm.org/D24754 Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=282322=282321=282322=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Sep 23 23:21:53 2016 @@ -146,13 +146,13 @@ namespace clang { /// Results from loading a RedeclarableDecl. class RedeclarableResult { - GlobalDeclID FirstID; Decl *MergeWith; + GlobalDeclID FirstID; bool IsKeyDecl; public: - RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl) - : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {} + RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl) +: MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {} /// \brief Retrieve the first ID. GlobalDeclID getFirstID() const { return FirstID; } @@ -2311,7 +2311,7 @@ ASTDeclReader::VisitRedeclarable(Redecla if (IsFirstLocalDecl) Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset)); - return RedeclarableResult(FirstDeclID, MergeWith, IsKeyDecl); + return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl); } /// \brief Attempts to merge the given declaration (D) with another declaration @@ -2353,9 +2353,10 @@ void ASTDeclReader::mergeTemplatePattern DeclID DsID, bool IsKeyDecl) { auto *DPattern = D->getTemplatedDecl(); auto *ExistingPattern = Existing->getTemplatedDecl(); - RedeclarableResult Result(DPattern->getCanonicalDecl()->getGlobalID(), -/*MergeWith*/ ExistingPattern, IsKeyDecl); - + RedeclarableResult Result(/*MergeWith*/ ExistingPattern, +DPattern->getCanonicalDecl()->getGlobalID(), +IsKeyDecl); + if (auto *DClass = dyn_cast(DPattern)) { // Merge with any existing definition. // FIXME: This is duplicated in several places. Refactor. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22968: [analyzer] A checker for macOS-specific bool-like objects.
zaks.anna added a comment. Here are more comments. Could you address/answer these and upload the latest patch that compares NSNumber to other numbers? Thanks! Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:88 @@ +87,3 @@ + +auto NSNumberExprM = +expr(ignoringParenImpCasts(expr(hasType(hasCanonicalType( Can you test if matching for NSNumber works when they come from ivars, properties, and method returns, works? Comment at: lib/StaticAnalyzer/Checkers/BoolConversionChecker.cpp:117 @@ +116,3 @@ +auto ConversionThroughComparisonM = +binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasEitherOperand(NSNumberExprM), Can we use any binary operator here without any restrictions? Comment at: test/Analysis/bool-conversion.cpp:18 @@ +17,3 @@ +#ifdef PEDANTIC + if (p) {} // expected-warning{{}} + if (!p) {} // expected-warning{{}} dcoughlin wrote: > It is generally good to include the diagnostic text in the test for the > warning. This way we make sure we get the warning we expected. +1 Are these pedantic because we assume these are comparing the pointer and not the value? Have you checked that this is a common idiom? Same comment applies to NSNumber. If it is common practice to compare against nil.. Comment at: test/Analysis/bool-conversion.cpp:21 @@ +20,3 @@ + p ? 1 : 2; // expected-warning{{}} + (bool)p; // expected-warning{{}} +#endif Why is this OK? Comment at: test/Analysis/bool-conversion.m:2 @@ +1,3 @@ +// RUN: %clang_cc1 -fblocks -w -analyze -analyzer-checker=alpha.osx.BoolConversion %s -verify +// RUN: %clang_cc1 -fblocks -w -analyze -analyzer-checker=alpha.osx.BoolConversion -analyzer-config alpha.osx.BoolConversion:Pedantic=true -DPEDANTIC %s -verify + dcoughlin wrote: > You should add a test invocation here where -fobjc-arc is set as well. This > adds a bunch of implicit goop that it would be good to test with. + 1!!! Especially, since we are matching the AST. Comment at: test/Analysis/bool-conversion.m:10 @@ +9,3 @@ + if (!p) {} // expected-warning{{}} + if (p == YES) {} // expected-warning{{}} + if (p == NO) {} // expected-warning{{}} dcoughlin wrote: > There is a Sema warning for `p == YES` already, right? ("comparison between > pointer and integer ('NSNumber *' and 'int')") These tests seem to be even more relevant to OSBoolean. https://reviews.llvm.org/D22968 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24652: [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix
alexfh requested changes to this revision. This revision now requires changes to proceed. Comment at: clang-tidy/readability/AvoidConstParamsInDecls.cpp:39 @@ -38,2 +38,3 @@ // generate a non-definition FunctionDecl too. Ignore those. - unless(cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(), + // Ignore template instantiations too. + unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf( Would be helpful to expand on why we're ignoring only member function of class instantiations (and not instantiations of member or free standing functions, for example). https://reviews.llvm.org/D24652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23765: Fix for clang PR 29087
twoh added a comment. ping https://reviews.llvm.org/D23765 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r282319 - [clang-tidy] Cleaning up language options.
Author: xazax Date: Fri Sep 23 21:13:45 2016 New Revision: 282319 URL: http://llvm.org/viewvc/llvm-project?rev=282319=rev Log: [clang-tidy] Cleaning up language options. Differential Revision: https://reviews.llvm.org/D24881 Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/StringIntegerAssignmentCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/AvoidConstParamsInDecls.cpp clang-tools-extra/trunk/clang-tidy/readability/ContainerSizeEmptyCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/NamespaceCommentCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp?rev=282319=282318=282319=diff == --- clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp Fri Sep 23 21:13:45 2016 @@ -214,7 +214,7 @@ void StrToNumCheck::check(const MatchFin // Formatted input functions need further checking of the format string to // determine whether a problematic conversion may be happening. -Conversion = ClassifyFormatString(FmtStr, Result.Context->getLangOpts(), +Conversion = ClassifyFormatString(FmtStr, getLangOpts(), Result.Context->getTargetInfo()); if (Conversion != ConversionKind::None) FuncDecl = FFD; Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp?rev=282319=282318=282319=diff == --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp Fri Sep 23 21:13:45 2016 @@ -68,7 +68,7 @@ void ProTypeCstyleCastCheck::check(const CharSourceRange::getTokenRange( MatchedCast->getLParenLoc().getLocWithOffset(1), MatchedCast->getRParenLoc().getLocWithOffset(-1)), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); auto diag_builder = diag( MatchedCast->getLocStart(), @@ -82,8 +82,7 @@ void ProTypeCstyleCastCheck::check(const CastText.push_back('('); diag_builder << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, - *Result.SourceManager, - Result.Context->getLangOpts()), + *Result.SourceManager, getLangOpts()), ")"); } auto ParenRange = CharSourceRange::getTokenRange( Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=282319=282318=282319=diff
Re: [PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. If this kind of an error is not too frequent, it might make sense as a clang diagnostic, indeed. Having it in clang-tidy until then doesn't hurt, though. Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:36 @@ +35,3 @@ + const SourceManager = *Result.SourceManager; + if (SM.isInSystemHeader(VD->getLocation())) +return; Don't check for system headers, clang-tidy takes care of this (and sometimes, warnings in system headers are interesting to the standard library maintainers). Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:38 @@ +37,3 @@ +return; + if (!SM.isInMainFile(VD->getLocation()) && + !SM.isWrittenInSameFile(Prev->getLocation(), VD->getLocation())) Don't check for the same file. It will prevent fixing headers. Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:44 @@ +43,3 @@ + bool MultiVar = false; + for (const char *Code = SM.getCharacterData(VD->getLocStart()); + *Code && *Code != ';'; ++Code) { There should be a better way of checking for multi variable declarations. Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:58-64 @@ +57,9 @@ + } else { +SourceLocation EndLoc = Lexer::getLocForEndOfToken( +VD->getLocEnd(), 0, SM, Result.Context->getLangOpts()); +diag(VD->getLocation(), "redundant variable %0 declaration") +<< VD->getName() +<< FixItHint::CreateRemoval(SourceRange(VD->getLocStart(), EndLoc)); +diag(VD->getPreviousDecl()->getLocation(), "previously declared here", + DiagnosticIDs::Note); + } No need to duplicate this code. Store the diagnostic builder and conditionally insert the fix: { auto Diag = diag(...); if (x) Diag << FixItHint::; } diag(..., Note); https://reviews.llvm.org/D24656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282318 - Remove excessive padding from ObjCCategoriesVisitor
Author: alexshap Date: Fri Sep 23 21:07:19 2016 New Revision: 282318 URL: http://llvm.org/viewvc/llvm-project?rev=282318=rev Log: Remove excessive padding from ObjCCategoriesVisitor This diff reorders the fields of ObjCCategoriesVisitor to remove excessive padding. Test plan: make -j8 check-clang Differential revision: https://reviews.llvm.org/D24753 Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=282318=282317=282318=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Sep 23 21:07:19 2016 @@ -3615,12 +3615,12 @@ namespace { /// interface all the categories for it. class ObjCCategoriesVisitor { ASTReader -serialization::GlobalDeclID InterfaceID; ObjCInterfaceDecl *Interface; llvm::SmallPtrSetImpl -unsigned PreviousGeneration; ObjCCategoryDecl *Tail; llvm::DenseMapNameCategoryMap; +serialization::GlobalDeclID InterfaceID; +unsigned PreviousGeneration; void add(ObjCCategoryDecl *Cat) { // Only process each category once. @@ -3663,13 +3663,13 @@ namespace { public: ObjCCategoriesVisitor(ASTReader , - serialization::GlobalDeclID InterfaceID, ObjCInterfaceDecl *Interface, -llvm::SmallPtrSetImpl , + llvm::SmallPtrSetImpl , + serialization::GlobalDeclID InterfaceID, unsigned PreviousGeneration) - : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface), -Deserialized(Deserialized), PreviousGeneration(PreviousGeneration), -Tail(nullptr) + : Reader(Reader), Interface(Interface), Deserialized(Deserialized), +Tail(nullptr), InterfaceID(InterfaceID), +PreviousGeneration(PreviousGeneration) { // Populate the name -> category map with the set of known categories. for (auto *Cat : Interface->known_categories()) { @@ -3724,7 +3724,7 @@ namespace { void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, unsigned PreviousGeneration) { - ObjCCategoriesVisitor Visitor(*this, ID, D, CategoriesDeserialized, + ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID, PreviousGeneration); ModuleMgr.visit(Visitor); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22507: Clang-tidy - Enum misuse check
alexfh requested changes to this revision. alexfh added a comment. This revision now requires changes to proceed. Thank you for the updates! Please re-run the check on LLVM to see what has changed. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:53 @@ +52,3 @@ +} +static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) { + if (const Expr *InitExpr = EnumConst->getInitExpr()) { nit: Add an empty line above. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:61 @@ +60,3 @@ +} +static bool isMaxValAllBitSetLiteral(const EnumDecl *EnumDec) { + auto EnumConst = std::max_element( nit: Add an empty line above. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:67 @@ +66,3 @@ + }); + if (const Expr *InitExpr = EnumConst->getInitExpr()) +return EnumConst->getInitVal().countTrailingOnes() == nit: Please add braces, since the body doesn't fit on a line. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:155 @@ +154,3 @@ + +if (EnumDec->enumerator_begin() == EnumDec->enumerator_end() || +OtherEnumDec->enumerator_begin() == OtherEnumDec->enumerator_end()) Why? Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:175 @@ +174,3 @@ +int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec); +if (isPossiblyBitMask(NonPowOfTwoCounter, EnumLen, VR, EnumDec)) { + const auto *EnumDecExpr = dyn_cast(EnumExpr); Use early return here. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:208 @@ +207,3 @@ + RhsDecExpr ? dyn_cast(RhsDecExpr->getDecl()) : nullptr; + bool LhsVar = !LhsConstant, RhsVar = !RhsConstant; + One variable definition at a time, please. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:216 @@ +215,3 @@ + int EnumLen = enumLength(EnumDec); + if (isPossiblyBitMask(NonPowOfTwoCounter, EnumLen, VR, EnumDec) && + (StrictMode || Use early return here. Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.h:32-35 @@ +31,6 @@ + const bool StrictMode; + const char* DifferentEnumErrorMessage; + const char* BitmaskErrorMessage; + const char* BitmaskVarErrorMessage; + const char* BitmaskNoteMessage; +}; These can be just static constants in the .cpp file. Apart from that, `const char X[] = ...;` is a better way to define string constants, otherwise you would have to go with `const char * const X = ...;` to make the pointer const as well. Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:4 @@ +3,3 @@ +misc-suspicious-enum-usage + + This line should be aligned with the line above. Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:9 @@ +8,3 @@ +1. When "ADD" or "bitwise OR" is used between two enum which come from different + types and these types value ranges are not disjoint. + Remove two spaces at the start of the line. Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:11 @@ +10,3 @@ + +In the following cases you can choose either "Strict" or "Weak" option. +In "Strict" mode we check if the used EnumConstantDecl type contains almost There's no "Weak" option, it's the "Strict" option set to false / 0. Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:12 @@ +11,3 @@ +In the following cases you can choose either "Strict" or "Weak" option. +In "Strict" mode we check if the used EnumConstantDecl type contains almost +only pow-of-2 numbers. Please use the `:option:` notation and add the option description (`.. option:: ...`). See, for example, modernize-use-emplace.rst. Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:31 @@ +30,3 @@ + +=== + This notation is used to make the previous line a heading. Doesn't seem to be the case here. See http://llvm.org/docs/SphinxQuickstartTemplate.html for some examples. Please also try to build your docs to check for obvious issues. Comment at: test/clang-tidy/misc-suspicious-enum-usage-strict.cpp:18 @@ +17,3 @@ + ZZ = 3 + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask (contains mostly power-of-2 literals), but this literal is not a power-of-2 [misc-suspicious-enum-usage] +}; Add check lines for notes as well (I don't think you'll be able to use [[@LINE]] for most of them, but you can probably just skip the line. https://reviews.llvm.org/D22507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. Thank you for the cleanup! Please clang-format-diff the files before submitting. Otherwise looks good. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18325: export additional header modules from xmmintrin
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko closed this revision. Eugene.Zelenko added a comment. Committed in r264092. https://reviews.llvm.org/D18325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18639: Use __builtin_isnan/isinf/isfinite in complex
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Looks like patch was not committed. https://reviews.llvm.org/D18639 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
Eugene.Zelenko added a comment. I think it's reasonable to compile code in C++11 with minimal changes (only modernize-replace-auto-ptr is really needed) and test it before further modernization. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
xazax.hun added a comment. In https://reviews.llvm.org/D24881#551487, @Eugene.Zelenko wrote: > I think will be good idea to enable modernize-loop-convert, > modernize-use-auto, modernize-use-default, modernize-use-nullptr only in > C++11 mode. > > Probably modernize-avoid-bind code code be simplified too. As far as I can see there is a discrepancy between these modernization checks. Loop convert, use auto, use default, use nullptr is registered for older standards deliberately. See the following comment: // Only register the matchers for C++. Because this checker is used for // modernization, it is reasonable to run it on any C++ standard with the // assumption the user is trying to modernize their codebase. So basically the question is: should we require the users to run the clang tidy in C++11 mode (hence change their build settings) to get these modernization checks? I am okay with either of the answers but I wonder what do you think. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24881: [clang-tidy] Cleaning up language options.
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. I think will be good idea to enable modernize-loop-convert, modernize-use-auto, modernize-use-default, modernize-use-nullptr only in C++11 mode. Probably modernize-avoid-bind code code be simplified too. Repository: rL LLVM https://reviews.llvm.org/D24881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19260: [analyzer][scan-build-py] subprocess output handling reviewed in clang module
rizsotto.mailinglist closed this revision. rizsotto.mailinglist added a comment. commited at r282317 https://reviews.llvm.org/D19260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282317 - [analyzer][scan-build-py] subprocess output handling reviewed in clang module
Author: rizsotto Date: Fri Sep 23 19:20:59 2016 New Revision: 282317 URL: http://llvm.org/viewvc/llvm-project?rev=282317=rev Log: [analyzer][scan-build-py] subprocess output handling reviewed in clang module Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py cfe/trunk/tools/scan-build-py/libscanbuild/clang.py cfe/trunk/tools/scan-build-py/tests/unit/test_clang.py Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py?rev=282317=282316=282317=diff == --- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py (original) +++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py Fri Sep 23 19:20:59 2016 @@ -269,6 +269,9 @@ def validate(parser, args, from_build_co """ Validation done by the parser itself, but semantic check still needs to be done. This method is doing that. """ +# Make plugins always a list. (It might be None when not specified.) +args.plugins = args.plugins if args.plugins else [] + if args.help_checkers_verbose: print_checkers(get_checkers(args.clang, args.plugins)) parser.exit() Modified: cfe/trunk/tools/scan-build-py/libscanbuild/clang.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/clang.py?rev=282317=282316=282317=diff == --- cfe/trunk/tools/scan-build-py/libscanbuild/clang.py (original) +++ cfe/trunk/tools/scan-build-py/libscanbuild/clang.py Fri Sep 23 19:20:59 2016 @@ -15,142 +15,143 @@ from libscanbuild.shell import decode __all__ = ['get_version', 'get_arguments', 'get_checkers'] +# regex for activated checker +ACTIVE_CHECKER_PATTERN = re.compile(r'^-analyzer-checker=(.*)$') -def get_version(cmd): -""" Returns the compiler version as string. """ -lines = subprocess.check_output([cmd, '-v'], stderr=subprocess.STDOUT) -return lines.decode('ascii').splitlines()[0] +def get_version(clang): +""" Returns the compiler version as string. + +:param clang: the compiler we are using +:return:the version string printed to stderr """ + +output = subprocess.check_output([clang, '-v'], stderr=subprocess.STDOUT) +return output.decode('utf-8').splitlines()[0] def get_arguments(command, cwd): """ Capture Clang invocation. -This method returns the front-end invocation that would be executed as -a result of the given driver invocation. """ - -def lastline(stream): -last = None -for line in stream: -last = line -if last is None: -raise Exception("output not found") -return last +:param command: the compilation command +:param cwd: the current working directory +:return:the detailed front-end invocation command """ cmd = command[:] cmd.insert(1, '-###') logging.debug('exec command in %s: %s', cwd, ' '.join(cmd)) -child = subprocess.Popen(cmd, - cwd=cwd, - universal_newlines=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) -line = lastline(child.stdout) -child.stdout.close() -child.wait() -if child.returncode == 0: -if re.search(r'clang(.*): error:', line): -raise Exception(line) -return decode(line) -else: -raise Exception(line) + +output = subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) +# The relevant information is in the last line of the output. +# Don't check if finding last line fails, would throw exception anyway. +last_line = output.decode('utf-8').splitlines()[-1] +if re.search(r'clang(.*): error:', last_line): +raise Exception(last_line) +return decode(last_line) def get_active_checkers(clang, plugins): -""" To get the default plugins we execute Clang to print how this -compilation would be called. +""" Get the active checker list. -For input file we specify stdin and pass only language information. """ +:param clang: the compiler we are using +:param plugins: list of plugins which was requested by the user +:return:list of checker names which are active + +To get the default checkers we execute Clang to print how this +compilation would be called. And take out the enabled checker from the +arguments. For input file we specify stdin and pass only language +information. """ -def checkers(language): +def get_active_checkers_for(language): """ Returns a list of active checkers for the given language. """ -load = [elem -for plugin in plugins -for elem in ['-Xclang', '-load', '-Xclang', plugin]] -cmd = [clang,
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
andrewford added a subscriber: andrewford. andrewford added a comment. This is breaking our android lldb build, because it uses std::to_string. Looks like there is llvm::to_string, which should be preferred. Would someone mind changing it? I don't have commit access or I would myself. :) Thanks in advance Repository: rL LLVM https://reviews.llvm.org/D24826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24884: Fix PR30274
arphaman added a comment. (Forgot to mention) This is a a fix for the regression introduced by r274049. Repository: rL LLVM https://reviews.llvm.org/D24884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
On Fri, Sep 23, 2016, 4:38 PM Andrew Fordwrote: > andrewford added a subscriber: andrewford. > andrewford added a comment. > > This is breaking our android lldb build, because it uses std::to_string. > Looks like there is llvm::to_string, which should be preferred. Would > someone mind changing it? I don't have commit access or I would myself. :) > Saw that and already fixed in rL282308. Teresa > Thanks in advance > > > Repository: > rL LLVM > > https://reviews.llvm.org/D24826 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r274222 - [GCC] PR23529 Mangler part of attrbute abi_tag support
Hi Dmitry, I think that this commit has caused a regression that's tracked by PR 30440. I'll try working on a fix for it. Alex On 30 June 2016 at 02:40, Dmitry Polukhin via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: dpolukhin > Date: Thu Jun 30 04:40:38 2016 > New Revision: 274222 > > URL: http://llvm.org/viewvc/llvm-project?rev=274222=rev > Log: > [GCC] PR23529 Mangler part of attrbute abi_tag support > > Original patch by Stefan Bühler http://reviews.llvm.org/D12834 > > Difference between original and this one: > - fixed all failing tests > - fixed mangling for global variable outside namespace > - emit ABI tags for guards and local names > - clang-format + other stylistic changes > - significantly reworked patch according to Richard's suggestions > > Sema part, committed before http://reviews.llvm.org/D17567 > > Differential revision: http://reviews.llvm.org/D18035 > > Added: > cfe/trunk/test/CodeGenCXX/mangle-abi-tag.cpp (with props) > Modified: > cfe/trunk/lib/AST/ItaniumMangle.cpp > cfe/trunk/lib/Sema/SemaDeclAttr.cpp > cfe/trunk/test/PCH/attrs.c > cfe/trunk/test/SemaCXX/attr-abi-tag-syntax.cpp > > Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ > ItaniumMangle.cpp?rev=274222=274221=274222=diff > > == > --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) > +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Jun 30 04:40:38 2016 > @@ -214,6 +214,12 @@ public: > class CXXNameMangler { >ItaniumMangleContextImpl >raw_ostream > + bool NullOut = false; > + /// In the "DisableDerivedAbiTags" mode derived ABI tags are not > calculated. > + /// This mode is used when mangler creates another mangler recursively > to > + /// calculate ABI tags for the function return value or the variable > type. > + /// Also it is required to avoid infinite recursion in some cases. > + bool DisableDerivedAbiTags = false; > >/// The "structor" is the top-level declaration being mangled, if >/// that's not a template specialization; otherwise it's the pattern > @@ -263,15 +269,126 @@ class CXXNameMangler { > >} FunctionTypeDepth; > > + // abi_tag is a gcc attribute, taking one or more strings called "tags". > + // The goal is to annotate against which version of a library an object > was > + // built and to be able to provide backwards compatibility ("dual abi"). > + // For more information see docs/ItaniumMangleAbiTags.rst. > + typedef SmallVectorAbiTagList; > + > + // State to gather all implicit and explicit tags used in a mangled > name. > + // Must always have an instance of this while emitting any name to keep > + // track. > + class AbiTagState final { > + public: > +explicit AbiTagState(AbiTagState *) : LinkHead(Head) { > + Parent = LinkHead; > + LinkHead = this; > +} > + > +// No copy, no move. > +AbiTagState(const AbiTagState &) = delete; > +AbiTagState =(const AbiTagState &) = delete; > + > +~AbiTagState() { pop(); } > + > +void write(raw_ostream , const NamedDecl *ND, > + const AbiTagList *AdditionalAbiTags) { > + ND = cast(ND->getCanonicalDecl()); > + if (!isa(ND) && !isa(ND)) { > +assert( > +!AdditionalAbiTags && > +"only function and variables need a list of additional abi > tags"); > +if (const auto *NS = dyn_cast(ND)) { > + if (const auto *AbiTag = NS->getAttr()) { > +UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(), > + AbiTag->tags().end()); > + } > + // Don't emit abi tags for namespaces. > + return; > +} > + } > + > + AbiTagList TagList; > + if (const auto *AbiTag = ND->getAttr()) { > +UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(), > + AbiTag->tags().end()); > +TagList.insert(TagList.end(), AbiTag->tags().begin(), > + AbiTag->tags().end()); > + } > + > + if (AdditionalAbiTags) { > +UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(), > + AdditionalAbiTags->end()); > +TagList.insert(TagList.end(), AdditionalAbiTags->begin(), > + AdditionalAbiTags->end()); > + } > + > + std::sort(TagList.begin(), TagList.end()); > + TagList.erase(std::unique(TagList.begin(), TagList.end()), > TagList.end()); > + > + writeSortedUniqueAbiTags(Out, TagList); > +} > + > +const AbiTagList () const { return UsedAbiTags; } > +void setUsedAbiTags(const AbiTagList ) { > + UsedAbiTags = AbiTags; > +} > + > +const AbiTagList () const { > + return EmittedAbiTags; > +} > + > +const AbiTagList () { > + std::sort(UsedAbiTags.begin(), UsedAbiTags.end()); > +
Re: [PATCH] D19170: [safestack] Link SafeStack runtime only when not using separate stack segment
Eugene.Zelenko added a comment. Please add dependencies to Differential revisions, so reasons for holding will be clear. https://reviews.llvm.org/D19170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19170: [safestack] Link SafeStack runtime only when not using separate stack segment
mlemay-intel added a comment. In https://reviews.llvm.org/D19170#551426, @Eugene.Zelenko wrote: > Looks like patch was not committed. This patch, https://reviews.llvm.org/D17092, https://reviews.llvm.org/D17094, and https://reviews.llvm.org/D17095 are all interdependent. I think it makes sense to wait until all four are approved so that they can all be committed together. https://reviews.llvm.org/D19170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19170: [safestack] Link SafeStack runtime only when not using separate stack segment
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Looks like patch was not committed. https://reviews.llvm.org/D19170 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19260: [analyzer][scan-build-py] subprocess output handling reviewed in clang module
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Looks like patch was not committed. https://reviews.llvm.org/D19260 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24820: Add -stats-stats option
MatzeB added inline comments. Comment at: test/Driver/save-stats.c:1 @@ +1,2 @@ +// RUN: %clang -target x86_64-apple-darwin -save-stats %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -save-stats=cwd %s -### 2>&1 | FileCheck %s bruno wrote: > Is -save-stats == -save-stats=cwd? It doesn't seem so by looking at > lib/Driver/Tools.cpp. Need test for the diag::err_drv_invalid_value as well. Yes, that aspect is handled by the options parser, look at the changes in Options.td Repository: rL LLVM https://reviews.llvm.org/D24820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24820: Add -stats-file option
MatzeB updated this revision to Diff 72376. MatzeB marked an inline comment as done. MatzeB added a comment. Thanks for the reviews. Addressed comments. Repository: rL LLVM https://reviews.llvm.org/D24820 Files: docs/CommandGuide/clang.rst include/clang/Basic/DiagnosticFrontendKinds.td include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/FrontendOptions.h lib/Driver/Tools.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp test/Driver/save-stats.c test/Frontend/stats-file.c test/Misc/warning-flags.c Index: test/Misc/warning-flags.c === --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (84): +CHECK: Warnings without flags (85): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -66,6 +66,7 @@ CHECK-NEXT: warn_fe_cc_log_diagnostics_failure CHECK-NEXT: warn_fe_cc_print_header_failure CHECK-NEXT: warn_fe_macro_contains_embedded_newline +CHECK-NEXT: warn_fe_unable_to_open_stats_file CHECK-NEXT: warn_file_asm_volatile CHECK-NEXT: warn_ignoring_ftabstop_value CHECK-NEXT: warn_implements_nscopying Index: test/Frontend/stats-file.c === --- /dev/null +++ test/Frontend/stats-file.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -emit-llvm -o /dev/null -stats-file=%t %s +// RUN: FileCheck -input-file=%t %s +// CHECK: { +// ... here come some json values ... +// CHECK: } + +// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%S/doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s +// OUTPUTFAIL: warning: unable to open statistic output file '{{.*}}{{[/\\]}}doesnotexist{{[/\\]}}bla': '{{[Nn]}}o such file or directory' Index: test/Driver/save-stats.c === --- /dev/null +++ test/Driver/save-stats.c @@ -0,0 +1,20 @@ +// RUN: %clang -target x86_64-apple-darwin -save-stats %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -save-stats=cwd %s -### 2>&1 | FileCheck %s +// CHECK: "-stats-file=save-stats.stats" +// CHECK: "{{.*}}save-stats.c" + +// RUN: %clang -target x86_64-apple-darwin -S %s -### 2>&1 | FileCheck %s -check-prefix=NO-STATS +// NO-STATS-NO: -stats-file +// NO-STATS: "{{.*}}save-stats.c" +// NO-STATS-NO: -stats-file + +// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ +// CHECK-OBJ: "-stats-file=obj/dir{{.}}save-stats.stats" +// CHECK-OBJ: "-o" "obj/dir{{.}}save-stats.o" + +// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ-NOO +// CHECK-OBJ-NOO: "-stats-file=save-stats.stats" +// CHECK-OBJ-NOO: "-o" "save-stats.o" + +// RUN: %clang -target x86_64-apple-darwin -save-stats=bla -c %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID +// CHECK-INVALID: invalid value 'bla' in '-save-stats=bla' Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -194,8 +194,10 @@ } ~AnalysisConsumer() override { -if (Opts->PrintStats) +if (Opts->PrintStats) { delete TUTotalTimer; + llvm::PrintStatistics(); +} } void DigestAnalyzerOptions() { Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -1252,6 +1252,7 @@ Opts.AuxTriple = llvm::Triple::normalize(Args.getLastArgValue(OPT_aux_triple)); Opts.FindPchSource = Args.getLastArgValue(OPT_find_pch_source_EQ); + Opts.StatsFile = Args.getLastArgValue(OPT_stats_file); if (const Arg *A = Args.getLastArg(OPT_arcmt_check, OPT_arcmt_modify, Index: lib/Frontend/CompilerInstance.cpp === --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -858,7 +858,7 @@ if (getFrontendOpts().ShowTimers) createFrontendTimer(); - if (getFrontendOpts().ShowStats) + if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty()) llvm::EnableStatistics(); for (const FrontendInputFile : getFrontendOpts().Inputs) { @@ -892,9 +892,24 @@ OS << " generated.\n"; } - if (getFrontendOpts().ShowStats && hasFileManager()) { -getFileManager().PrintStats(); -OS << "\n"; + if (getFrontendOpts().ShowStats) { +if
r282308 - Use llvm::to_string instead of std::to_string to fix bot
Author: tejohnson Date: Fri Sep 23 17:25:03 2016 New Revision: 282308 URL: http://llvm.org/viewvc/llvm-project?rev=282308=rev Log: Use llvm::to_string instead of std::to_string to fix bot This should fix the android build in this bot: http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-buildserver/builds/11143 Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=282308=282307=282308=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 23 17:25:03 2016 @@ -41,6 +41,7 @@ #include "llvm/Support/Process.h" #include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/TargetParser.h" #ifdef LLVM_ON_UNIX @@ -2045,7 +2046,7 @@ static void AddGoldPlugin(const ToolChai if (unsigned Parallelism = getLTOParallelism(Args, D)) CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + - std::to_string(Parallelism))); + llvm::to_string(Parallelism))); // If an explicit debugger tuning argument appeared, pass it along. if (Arg *A = Args.getLastArg(options::OPT_gTune_Group, @@ -8079,7 +8080,7 @@ void darwin::Linker::ConstructJob(Compil getLTOParallelism(Args, getToolChain().getDriver())) { CmdArgs.push_back("-mllvm"); CmdArgs.push_back( -Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism))); +Args.MakeArgString(Twine("-threads=") + llvm::to_string(Parallelism))); } if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
That's not a great long-term solution for obvious reasons, but I think it's a great quick fix. Sent from my iPhone > On Sep 23, 2016, at 5:53 PM, Hal Finkelwrote: > > We currently have logic in the test suite that sets -ffp-contract=off on > PowerPC (because the default for GCC and other compilers on PowerPC/Linux > systems is essentially -ffp-contract=fast). We might just want to do this now > for all platforms. > > -Hal > > - Original Message - >> From: "Steve Canon" >> To: reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org >> Cc: "a skolnik" , clatt...@apple.com, >> hfin...@anl.gov, "yaxun liu" , >> cfe-commits@lists.llvm.org >> Sent: Friday, September 23, 2016 4:47:32 PM >> Subject: Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default >> >> Without digging into them yet, these are almost caused by >> overly-sensitive tests that are erroneously expecting bit-exact >> results. >> >> - Steve >> >> Sent from my iPhone >> >>> On Sep 23, 2016, at 4:42 PM, Renato Golin >>> wrote: >>> >>> rengolin added a subscriber: rengolin. >>> rengolin added a comment. >>> >>> Folks, this commit has broken both AArch64 test-suite buildbots: >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 >>> >>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 >>> >>> I have reverted in r282289, let me know if you need help testing on >>> AArch64. >>> >>> >>> Repository: >>> rL LLVM >>> >>> https://reviews.llvm.org/D24481 >>> >>> >>> >> > > -- > Hal Finkel > Lead, Compiler Technology and Programming Languages > Leadership Computing Facility > Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19854: Define Contiki OS toolchain
mlemay-intel added a comment. In https://reviews.llvm.org/D19854#551260, @Eugene.Zelenko wrote: > Looks like patch was not committed. This patch is only useful in combination with https://reviews.llvm.org/D19852, so I was waiting for that one to be approved so these can be committed at the same time. I can go ahead and request that this one be committed now if you prefer, though. https://reviews.llvm.org/D19854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24821: [ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.
klimek accepted this revision. klimek added a comment. This revision is now accepted and ready to land. lg https://reviews.llvm.org/D24821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute
mgehre updated this revision to Diff 72366. mgehre added a comment. Include link to corresponding clang-tidy patch https://reviews.llvm.org/D24886 Files: include/clang/Basic/Attr.td lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaStmtAttr.cpp Index: lib/Sema/SemaStmtAttr.cpp === --- lib/Sema/SemaStmtAttr.cpp +++ lib/Sema/SemaStmtAttr.cpp @@ -53,6 +53,25 @@ return ::new (S.Context) auto(Attr); } +static Attr *handleSuppressAttr(Sema , Stmt *St, const AttributeList , +SourceRange Range) { + std::vector Rules; + + for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) { +StringRef RuleName; +SourceLocation LiteralLoc; + +if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, )) + return nullptr; + +Rules.push_back(RuleName); + } + + SuppressAttr Attr(A.getRange(), S.Context, Rules.data(), Rules.size(), +A.getAttributeSpellingListIndex()); + return ::new (S.Context) auto(Attr); +} + static Attr *handleLoopHintAttr(Sema , Stmt *St, const AttributeList , SourceRange) { IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0); @@ -283,6 +302,8 @@ return handleLoopHintAttr(S, St, A, Range); case AttributeList::AT_OpenCLUnrollHint: return handleOpenCLUnrollHint(S, St, A, Range); + case AttributeList::AT_Suppress: +return handleSuppressAttr(S, St, A, Range); default: // if we're here, then we parsed a known attribute, but didn't recognize // it as a statement attribute => it is declaration attribute Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3838,6 +3838,24 @@ } } +static void handleSuppressAttr(Sema , Decl *D, const AttributeList ) { + std::vector Rules; + + for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) { +StringRef RuleName; +SourceLocation LiteralLoc; + +if (!S.checkStringLiteralArgumentAttr(Attr, I, RuleName, )) + return; + +Rules.push_back(RuleName); + } + D->addAttr(::new (S.Context) SuppressAttr( + Attr.getRange(), S.Context, Rules.data(), Rules.size(), + Attr.getAttributeSpellingListIndex())); +} + + bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv , const FunctionDecl *FD) { if (attr.isInvalid()) @@ -5768,6 +5786,9 @@ case AttributeList::AT_PreserveAll: handleCallConvAttr(S, D, Attr); break; + case AttributeList::AT_Suppress: +handleSuppressAttr(S, D, Attr); +break; case AttributeList::AT_OpenCLKernel: handleSimpleAttribute(S, D, Attr); break; Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1451,6 +1451,12 @@ let Documentation = [SwiftIndirectResultDocs]; } +def Suppress : StmtAttr { + let Spellings = [CXX11<"clang", "suppress">]; + let Args = [VariadicStringArgument<"Rules">]; + let Documentation = [Undocumented]; +} + def SysVABI : InheritableAttr { let Spellings = [GCC<"sysv_abi">]; // let Subjects = [Function, ObjCMethod]; Index: lib/Sema/SemaStmtAttr.cpp === --- lib/Sema/SemaStmtAttr.cpp +++ lib/Sema/SemaStmtAttr.cpp @@ -53,6 +53,25 @@ return ::new (S.Context) auto(Attr); } +static Attr *handleSuppressAttr(Sema , Stmt *St, const AttributeList , +SourceRange Range) { + std::vector Rules; + + for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) { +StringRef RuleName; +SourceLocation LiteralLoc; + +if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, )) + return nullptr; + +Rules.push_back(RuleName); + } + + SuppressAttr Attr(A.getRange(), S.Context, Rules.data(), Rules.size(), +A.getAttributeSpellingListIndex()); + return ::new (S.Context) auto(Attr); +} + static Attr *handleLoopHintAttr(Sema , Stmt *St, const AttributeList , SourceRange) { IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0); @@ -283,6 +302,8 @@ return handleLoopHintAttr(S, St, A, Range); case AttributeList::AT_OpenCLUnrollHint: return handleOpenCLUnrollHint(S, St, A, Range); + case AttributeList::AT_Suppress: +return handleSuppressAttr(S, St, A, Range); default: // if we're here, then we parsed a known attribute, but didn't recognize // it as a statement attribute => it is declaration attribute Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3838,6 +3838,24 @@ } } +static void handleSuppressAttr(Sema , Decl *D, const AttributeList ) { + std::vector Rules; + + for (unsigned I = 0, E =
Re: [PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast
mgehre updated this revision to Diff 72365. mgehre added a comment. Minor fix https://reviews.llvm.org/D24888 Files: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp clang-tidy/cppcoreguidelines/Suppression.h docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp Index: test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp === --- test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp +++ test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp @@ -4,3 +4,14 @@ void *j; void f() { j = reinterpret_cast(i); } // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast] + +[[clang::suppress("cppcoreguidelines-pro-type-reinterpret-cast")]] +void suppress_f() { j = reinterpret_cast(i); } + +void suppress_f2() { +[[clang::suppress("type")]] j = reinterpret_cast(i); +[[clang::suppress("type.1")]] { +i = 1; +j = reinterpret_cast(i); +} +} Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst === --- docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst +++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst @@ -11,3 +11,7 @@ This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast. + +Warnings of this check can be suppressed by using the C++11 attribute +``[[clang::suppress("tag")]]`` with a tag of either "type", "type.1" or +"cppcoreguidelines-pro-type-reinterpret-cast". Index: clang-tidy/cppcoreguidelines/Suppression.h === --- /dev/null +++ clang-tidy/cppcoreguidelines/Suppression.h @@ -0,0 +1,67 @@ +//===--- Suppression.h - clang-tidy--*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SUPPRESSION_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SUPPRESSION_H + +namespace clang { +namespace tidy { +namespace cppcoreguidelines { + +const ast_matchers::internal::VariadicDynCastAllOfMatcher+attributedStmt; + +AST_MATCHER(Decl, hasAttrs) { return Node.hasAttrs(); } + +// If called on a Decl, assumes that hasAttrs() is true. +AST_POLYMORPHIC_MATCHER_P_OVERLOAD( +hasSuppressAttr, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, AttributedStmt), +std::vector, Rules, 0) { + llvm::outs() << "hasSuppressAttr called\n"; + if (const auto *Suppress = + getSpecificAttr(Node.getAttrs())) { +for (const auto : Rules) { + auto It = std::find_if(Suppress->rules_begin(), Suppress->rules_end(), + [Rule](const std::string ) { + llvm::outs() << "Rule " << R << "\n"; + return R == Rule; + }); + if (It != Suppress->rules_end()) +return true; +} + } + return false; +} + +// If called on a Decl, assumes that hasAttrs() is true. +AST_POLYMORPHIC_MATCHER_P_OVERLOAD( +hasSuppressAttr, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, AttributedStmt), +StringRef, Rule, 1) { + std::vector Rules(1, Rule); + return ast_matchers::internal::Matcher(hasSuppressAttr(Rules)) + .matches(Node, Finder, Builder); +} + +/// Checks if any ancestor has a [[clang::suppress(rule, ...)]] attribute with +/// one of the given Rules. +AST_POLYMORPHIC_MATCHER_P(isSuppressed, + AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt), + std::vector, Rules) { + using namespace clang::ast_matchers; + return ast_matchers::internal::Matcher( + anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))), + hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules) + .matches(Node, Finder, Builder); +} + +} // namespace cppcoreguidelines +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SUPPRESSION_H Index: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp === --- clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp +++ clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp @@ -8,6 +8,7 @@ //===--===// #include "ProTypeReinterpretCastCheck.h" +#include "Suppression.h" #include
[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast
mgehre created this revision. mgehre added reviewers: alexfh, aaron.ballman. mgehre added a subscriber: cfe-commits. Herald added a subscriber: nemanjai. This is a proof-of-concept how the [[clang::suppress(tags,...)]] attribute can work with suppressing clang-tidy warnings. The list of tags that can be used to suppress a specific warnings comes from [1]. It is the group that the cppcoreguidelines check belongs to ("type"), the name of the check there ("type.1") and the clang-tidy name ("cppcoreguidelines-pro-type-reinterpret-cast"). I envision to put this into all cppcoreguidelines checks. Alternatively, this could go into clang-tidy core, to have this automatically for all checks. I'm looking forward to your comments! Depends on: D24886 [1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement https://reviews.llvm.org/D24888 Files: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp clang-tidy/cppcoreguidelines/Suppression.h docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp Index: test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp === --- test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp +++ test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp @@ -4,3 +4,14 @@ void *j; void f() { j = reinterpret_cast(i); } // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast] + +[[clang::suppress("cppcoreguidelines-pro-type-reinterpret-cast")]] +void suppress_f() { j = reinterpret_cast(i); } + +void suppress_f2() { +[[clang::suppress("type")]] j = reinterpret_cast(i); +[[clang::suppress("type.1")]] { +i = 1; +j = reinterpret_cast(i); +} +} Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst === --- docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst +++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst @@ -11,3 +11,7 @@ This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast. + +Warnings of this check can be suppressed by using the C++11 attribute +``[[clang::suppress("tag")]]`` with a tag of either "type", "type.1" or +"cppcoreguidelines-pro-type-reinterpret-cast". Index: clang-tidy/cppcoreguidelines/Suppression.h === --- /dev/null +++ clang-tidy/cppcoreguidelines/Suppression.h @@ -0,0 +1,87 @@ +//===--- Suppression.h - clang-tidy--*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SUPPRESSION_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SUPPRESSION_H + +namespace clang { +namespace tidy { +namespace cppcoreguidelines { + +const ast_matchers::internal::VariadicDynCastAllOfMatcherattributedStmt; + +AST_MATCHER(Decl, hasAttrs) { + return Node.hasAttrs(); +} + +#if 0 +/// Returns true if the Node has a suppress attribute (like [[suppress(rule1,rule2)]]) +/// where the given rule appears in the rule list. +/// If called on a Decl, assumes that hasAttrs() is true! +AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasSuppressAttr, + AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, + AttributedStmt), + std::string, Rule, 0) { + if (const auto *Suppress = getSpecificAttr(Node.getAttrs())) { +auto It = std::find_if(Suppress->rules_begin(), + Suppress->rules_end(), + [this](const std::string ) { + return R == this->Rule; + }); +return It != Suppress->rules_end(); + } + return false; +} +#endif + +// If called on a Decl, assumes that hasAttrs() is true! +AST_POLYMORPHIC_MATCHER_P_OVERLOAD(hasSuppressAttr, + AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, + AttributedStmt), + std::vector, Rules, 0) { + llvm::outs() << "hasSuppressAttr called\n"; + if (const auto *Suppress = getSpecificAttr(Node.getAttrs())) { +for(const auto& Rule : Rules) { + auto It = std::find_if(Suppress->rules_begin(), + Suppress->rules_end(), +
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
We currently have logic in the test suite that sets -ffp-contract=off on PowerPC (because the default for GCC and other compilers on PowerPC/Linux systems is essentially -ffp-contract=fast). We might just want to do this now for all platforms. -Hal - Original Message - > From: "Steve Canon"> To: reviews+d24481+public+c0b8d50a92298...@reviews.llvm.org > Cc: "a skolnik" , clatt...@apple.com, hfin...@anl.gov, > "yaxun liu" , > cfe-commits@lists.llvm.org > Sent: Friday, September 23, 2016 4:47:32 PM > Subject: Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default > > Without digging into them yet, these are almost caused by > overly-sensitive tests that are erroneously expecting bit-exact > results. > > - Steve > > Sent from my iPhone > > > On Sep 23, 2016, at 4:42 PM, Renato Golin > > wrote: > > > > rengolin added a subscriber: rengolin. > > rengolin added a comment. > > > > Folks, this commit has broken both AArch64 test-suite buildbots: > > > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 > > > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 > > > > I have reverted in r282289, let me know if you need help testing on > > AArch64. > > > > > > Repository: > > rL LLVM > > > > https://reviews.llvm.org/D24481 > > > > > > > -- Hal Finkel Lead, Compiler Technology and Programming Languages Leadership Computing Facility Argonne National Laboratory ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282301 - Update clang for r282299.
Author: pcc Date: Fri Sep 23 16:43:51 2016 New Revision: 282301 URL: http://llvm.org/viewvc/llvm-project?rev=282301=rev Log: Update clang for r282299. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=282301=282300=282301=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 23 16:43:51 2016 @@ -714,20 +714,6 @@ void EmitAssemblyHelper::EmitAssembly(Ba } } -namespace { -// Wrapper prodiving a stream for the ThinLTO backend. -class ThinLTOOutputWrapper : public lto::NativeObjectOutput { - std::unique_ptr OS; - -public: - ThinLTOOutputWrapper(std::unique_ptr OS) - : OS(std::move(OS)) {} - std::unique_ptr getStream() override { -return std::move(OS); - } -}; -} - static void runThinLTOBackend(const CodeGenOptions , Module *M, std::unique_ptr OS) { // If we are performing a ThinLTO importing compile, load the function index @@ -769,12 +755,12 @@ static void runThinLTOBackend(const Code ModuleMap[I.first()] = (*MBOrErr)->getMemBufferRef(); OwnedImports.push_back(std::move(*MBOrErr)); } - auto AddOutput = [&](size_t Task) { -return llvm::make_unique(std::move(OS)); + auto AddStream = [&](size_t Task) { +return llvm::make_unique(std::move(OS)); }; lto::Config Conf; if (Error E = thinBackend( - Conf, 0, AddOutput, *M, *CombinedIndex, ImportList, + Conf, 0, AddStream, *M, *CombinedIndex, ImportList, ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) { handleAllErrors(std::move(E), [&](ErrorInfoBase ) { errs() << "Error running ThinLTO backend: " << EIB.message() << '\n'; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType
lukasza updated the summary for this revision. lukasza updated this revision to Diff 72350. lukasza marked an inline comment as done. lukasza added a comment. - Added test where both TemplateSpecializationType and TypedefType are present and both should match regardless of code order inside HasDeclarationMatcher::matchesSpecialized(const QualType ). Removed significance of order inside this matchesSpecialized method. - Tweaked test proposed in the previous patchset, so that it matches specific decls (rather than any decls) - Added support for matching hasDeclaration(elaboratedType(...)) + test (in the test from the previous patchset). https://reviews.llvm.org/D24361 Files: include/clang/ASTMatchers/ASTMatchers.h include/clang/ASTMatchers/ASTMatchersInternal.h unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp === --- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp @@ -2106,5 +2106,56 @@ functionDecl(hasName("bar")); } +TEST(HasDeclaration, ElaboratedTypeAndTemplateSpecializationType) { + std::string input = + "namespace Namespace {\n" + "template\n" + "class Template {\n" + " public:\n" + " void Method() {}\n" + "};\n" + "} // namespace Namespace\n" + "template \n" + "void Function(Namespace::Template param) {\n" + " param.Method();\n" + "};\n"; + + // Matcher for ::Namespace::Template template decl. + auto param_type_decl_matcher = classTemplateDecl( + hasName("Template"), + hasParent(namespaceDecl(hasName("Namespace"))), + has(templateTypeParmDecl(hasName("T"; + + // hasDeclaration / qualType-flavour. + EXPECT_TRUE(matches(input, parmVarDecl( + hasName("param"), + hasType(qualType(hasDeclaration(decl(param_type_decl_matcher))); + + // hasDeclaration / elaboratedType-flavour. + EXPECT_TRUE(matches(input, parmVarDecl( + hasName("param"), + hasType(elaboratedType(hasDeclaration(decl(param_type_decl_matcher))); +} + +TEST(HasDeclaration, TypedefTypeAndTemplateSpecializationTypeAreBothHere) { + std::string input = + "template\n" + "class Foo {};\n" + "using Bar = Foo;\n" + "Bar variable;\n"; + + // hasDeclaration should match typedefNameDecl. + EXPECT_TRUE(matches(input, varDecl( + hasName("variable"), + hasType(qualType(hasDeclaration(decl( + typeAliasDecl(hasName("Bar"); + + // hasDeclaration should match templateSpecializationType + EXPECT_TRUE(matches(input, varDecl( + hasName("variable"), + hasType(qualType(hasDeclaration(decl( + classTemplateSpecializationDecl(; +} + } // namespace ast_matchers } // namespace clang Index: include/clang/ASTMatchers/ASTMatchersInternal.h === --- include/clang/ASTMatchers/ASTMatchersInternal.h +++ include/clang/ASTMatchers/ASTMatchersInternal.h @@ -744,16 +744,29 @@ if (Node.isNull()) return false; -if (auto *TD = Node->getAsTagDecl()) - return matchesDecl(TD, Finder, Builder); -else if (auto *TT = Node->getAs()) - return matchesDecl(TT->getDecl(), Finder, Builder); // Do not use getAs instead of the direct dyn_cast. // Calling getAs will return the canonical type, but that type does not // store a TemplateTypeParmDecl. We *need* the uncanonical type, if it is // available, and using dyn_cast ensures that. -else if (auto *TTP = dyn_cast(Node.getTypePtr())) +if (auto *TTP = dyn_cast(Node.getTypePtr())) return matchesDecl(TTP->getDecl(), Finder, Builder); + +// Try if any of desugaring results match +// (these are not mutually exclusive). +if (auto *TST = Node->getAs()) { + if (matchesSpecialized(*TST, Finder, Builder)) +return true; +} +if (auto *TT = Node->getAs()) { + if (matchesDecl(TT->getDecl(), Finder, Builder)) +return true; +} + +// Try non-desugarable types. +if (auto *TD = Node->getAsTagDecl()) + return matchesDecl(TD, Finder, Builder); +else if (auto *ET = Node->getAs()) + return matchesSpecialized(*ET, Finder, Builder); else if (auto *OCIT = Node->getAs()) return matchesDecl(OCIT->getDecl(), Finder, Builder); else if (auto *UUT = Node->getAs()) @@ -760,9 +773,18 @@ return matchesDecl(UUT->getDecl(), Finder, Builder); else if (auto *ICNT = Node->getAs()) return matchesDecl(ICNT->getDecl(), Finder, Builder); + return false; } + /// \brief Gets the QualType from ElaboratedType + /// and returns whether the inner matches on it. + bool matchesSpecialized(const ElaboratedType , + ASTMatchFinder *Finder, + BoundNodesTreeBuilder *Builder)
Re: [PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType
lukasza added inline comments. Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:750 @@ +749,3 @@ +else if (auto *ET = Node->getAs()) + return matchesSpecialized(ET->getNamedType(), Finder, Builder); +else if (auto *TST = Node->getAs()) lukasza wrote: > There is also a question whether I should not only start supporting not only > qualType(hasDeclaration(...)) when qualType wraps an ElaboratedType node, but > also start supporting elaboratedType(hasDeclaration(...)). > > Snippets of a patch that could achieve this (but then again - I am not sure > if this is desirable and/or necessary): > > +++ include/clang/ASTMatchers/ASTMatchersInternal.h (working copy) > ... > + /// \brief Gets the QualType from ElaboratedType > + /// and returns whether the inner matches on it. > + bool matchesSpecialized(const ElaboratedType , > + ASTMatchFinder *Finder, > + BoundNodesTreeBuilder *Builder) const { > +return matchesSpecialized(Node.getNamedType(), Finder, Builder); > + } > + > ... > /// \brief All types that are supported by HasDeclarationMatcher above. > -typedef TypeList- InjectedClassNameType, LabelStmt, AddrLabelExpr, > MemberExpr, > - QualType, RecordType, TagType, > TemplateSpecializationType, > - TemplateTypeParmType, TypedefType, > +typedef TypeList ElaboratedType, > + EnumType, InjectedClassNameType, LabelStmt, > AddrLabelExpr, > + MemberExpr, QualType, RecordType, TagType, > + TemplateSpecializationType, TemplateTypeParmType, > TypedefType, > UnresolvedUsingType> HasDeclarationSupportedTypes; FWIW, I've added this support in the latest patchset. Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:752 @@ -749,1 +751,3 @@ +else if (auto *TST = Node->getAs()) + return matchesSpecialized(*TST, Finder, Builder); else if (auto *TT = Node->getAs()) rsmith wrote: > lukasza wrote: > > I am a little bit confused and concerned whether the order of the if > > statements here matters. In particular - I am not sure if the ordering of > > dyn_cast below and getAs calls here matters (and whether things would be > > safer / less fragile if the dyn_cast was moved all the way to the top?). > I don't think the position of the `TemplateTypeParmType` case matters; a > non-canonical TTPT always desugars to a canonical TTPT, so none of the other > cases can match. > > The relative order of the `getAs` cases can matter, though, and neither > ordering of `TypedefType` and `TemplateSpecializationType` will actually do > the right thing in general (you can have a typedef that desugars to a TST and > vice versa -- the TST would need to represent an alias template > specialization in the latter case). If you want to get this "right" you'll > need to do single-step desugaring until you hit a type you like the look of. > (See `getAsSugar` in lib/AST/Type.cpp for an example.) Thank you for the explanation and the hint to look at getAsSugar. I've added a test where both TypeSpecializationType and TypedefType could be used. One of the asserts (the one trying to match typeAliasDecl) was initially failing as expected / as explained by your comment above (i.e. HasDeclarationMatcher::matchesSpecialized(QualType...) was first looking at TypeSpecializationType and when that succeeded it would not consider TypedefType later on). The test covers alias-desugars-to-template-specialization-type case. Unfortunately, I was not able to come up with desugaring going in the other direction. I started with something like what I have below, but there is no typeAliasDecl here (I think) and I don't know how to insert one: template class Foo {}; template using Bar = Foo; Bar variable; I am not sure if I really need to do single-step desugaring (and consult hasDeclaration's innerMatcher for each step). Wouldn't it be sufficient that desugaring to TemplateSpecializationType does not latch onto TST code path, but that we will also consider TypedefType desugaring later? Code is probably better at explaining at what I mean here - please look at the latest patchset. The new test passes, so I think my changes really made ordering insignificant as desired (at least insignificant when it comes to ordering between the only types (TemplateSpecializationType and TypedefType) that are 1) used in HasDeclarationMatcher / QualType overload + 2) covered via getAsSugar helper). Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:2119 @@ +2118,3 @@ + "template \n" + "void
Re: [PATCH] D24472: [Sema] Support lax conversions for compound assignments
bruno added inline comments. Comment at: lib/Sema/SemaExpr.cpp:8090 @@ +8089,3 @@ + *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast); + return VecType; +} ahatanak wrote: > Sorry I wasn't clear, but I was asking whether you were planning to allow > the following conversions for compound statements. > > ``` > typedef short s4 __attribute__ ((vector_size(8))); > typedef int i2 __attribute__ ((vector_size(8))); > s4 a; > i2 b; > a = a + b; // clang accepts this. > a += b; // currently clang rejects this. > ``` > > Also, I feel clang is inconsistent in warning about incompatible types. In > the following example, it issues a warning for the first line, but is silent > about the second line: > > ``` > a = b + a; // incompatible vector types warning > a = a + b; // no warning > ``` > > I don't think we have to fix everything in this patch, but just wanted to > know what your thoughts were. You're right, the diagnostics are bad here, this patch adds some FIXMEs so we can later work on it. A PR would be nice though (we have an internal track for that as well, see rdar://problem/28067874). Given your example: a = a + b; // clang accepts this. a += b; // currently clang rejects this. IMO, clang should reject `a = a + b` too if not in OpenCL mode, which means whenever (a) `a` and `b` have same size but different num elt and (b) `a` and `b` are generic vectors (non ext-vectors). However, It looks like we have tests that rely on this behavior, we should probably find out why first and clean it up. I also think we should support splatting when one of the operands is a scalar and the other a non ext-vector (as of now we currently only do it for OpenCL). This is basically what GCC supports https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html. https://reviews.llvm.org/D24472 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
Without digging into them yet, these are almost caused by overly-sensitive tests that are erroneously expecting bit-exact results. - Steve Sent from my iPhone > On Sep 23, 2016, at 4:42 PM, Renato Golinwrote: > > rengolin added a subscriber: rengolin. > rengolin added a comment. > > Folks, this commit has broken both AArch64 test-suite buildbots: > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 > > I have reverted in r282289, let me know if you need help testing on AArch64. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D24481 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] r282300 - annotate more function visibility
Author: compnerd Date: Fri Sep 23 16:36:24 2016 New Revision: 282300 URL: http://llvm.org/viewvc/llvm-project?rev=282300=rev Log: annotate more function visibility These data and text symbols were missing annotations for building with hidden visibility. As we do not currently enable hidden visibility by default, this is a NFC for the buildbots. Modified: libcxxabi/trunk/src/cxa_handlers.hpp libcxxabi/trunk/src/private_typeinfo.cpp Modified: libcxxabi/trunk/src/cxa_handlers.hpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_handlers.hpp?rev=282300=282299=282300=diff == --- libcxxabi/trunk/src/cxa_handlers.hpp (original) +++ libcxxabi/trunk/src/cxa_handlers.hpp Fri Sep 23 16:36:24 2016 @@ -13,6 +13,8 @@ #ifndef _CXA_HANDLERS_H #define _CXA_HANDLERS_H +#include <__cxxabi_config.h> + #include namespace std @@ -31,9 +33,9 @@ __terminate(terminate_handler func) _NOE extern "C" { -extern void (*__cxa_terminate_handler)(); -extern void (*__cxa_unexpected_handler)(); -extern void (*__cxa_new_handler)(); +_LIBCXXABI_DATA_VIS extern void (*__cxa_terminate_handler)(); +_LIBCXXABI_DATA_VIS extern void (*__cxa_unexpected_handler)(); +_LIBCXXABI_DATA_VIS extern void (*__cxa_new_handler)(); /* Modified: libcxxabi/trunk/src/private_typeinfo.cpp URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=282300=282299=282300=diff == --- libcxxabi/trunk/src/private_typeinfo.cpp (original) +++ libcxxabi/trunk/src/private_typeinfo.cpp Fri Sep 23 16:36:24 2016 @@ -616,13 +616,11 @@ bool __pointer_to_member_type_info::can_ // If there is a public path from (dynamic_ptr, dynamic_type) to //(static_ptr, static_type), then return dynamic_ptr. // Else return nullptr. -extern "C" -void* -__dynamic_cast(const void* static_ptr, - const __class_type_info* static_type, - const __class_type_info* dst_type, - std::ptrdiff_t src2dst_offset) -{ + +extern "C" _LIBCXXABI_FUNC_VIS void * +__dynamic_cast(const void *static_ptr, const __class_type_info *static_type, + const __class_type_info *dst_type, + std::ptrdiff_t src2dst_offset) { // Possible future optimization: Take advantage of src2dst_offset // Currently clang always sets src2dst_offset to -1 (no hint). ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24886: Add [[clang::suppress(rule, ...)]] attribute
mgehre created this revision. mgehre added reviewers: alexfh, aaron.ballman, rsmith. mgehre added a subscriber: cfe-commits. This patch implements parsing of [[clang::suppress(rule, ...)]] attributes. C++ Core Guidelines depend heavily on tool support for rule enforcement. They also propose a way to suppress warnings [1] which is by annotating any ancestor in AST with the C++11 attribute [[suppress(rule1,...)]]. I understand that clang has a policy to put all non-standard attributes in clang namespace, thus here it is named [[clang::suppress(rule1, ...)]]. For example, to suppress the warning cppcoreguidelines-slicing, one could do ``` [[clang::suppress("cppcoreguidelines-slicing")]] void f() { ... code that does slicing ... } ``` or ``` void g() { Derived b; [[clang::suppress("cppcoreguidelines-slicing")]] Base a{b}; [[clang::suppress("cppcoreguidelines-slicing")]] { doSomething(); Base a2{b}; } } ``` This parsing can then be used by clang-tidy, which includes multiple C++ Core Guidelines rules, to suppress warnings (patch upcoming). For the exact naming of the rule in the attribute, there are different possibilities, which will be defined in the corresponding clang-tidy patch. Currently, clang-tidy supports suppressing of warnings through "// NOLINT" comments. There are some advantages that the attribute has: - Supressing specific warnings instead of all warnings - Suppressing warnings in a block (namespace, function, compound statement) - Code formatting may split a statement into multiple lines, thus a "// NOLINT" comment may be on the wrong line I could imagine to later extend this attribute further (if agreed) - for suppressing clang-tidy warnings in general - for suppressing clang warnings in general. I'm looking forward to your comments! [1] https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#inforce-enforcement https://reviews.llvm.org/D24886 Files: include/clang/Basic/Attr.td lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaStmtAttr.cpp Index: lib/Sema/SemaStmtAttr.cpp === --- lib/Sema/SemaStmtAttr.cpp +++ lib/Sema/SemaStmtAttr.cpp @@ -53,6 +53,25 @@ return ::new (S.Context) auto(Attr); } +static Attr *handleSuppressAttr(Sema , Stmt *St, const AttributeList , +SourceRange Range) { + std::vector Rules; + + for (unsigned I = 0, E = A.getNumArgs(); I != E; ++I) { +StringRef RuleName; +SourceLocation LiteralLoc; + +if (!S.checkStringLiteralArgumentAttr(A, I, RuleName, )) + return nullptr; + +Rules.push_back(RuleName); + } + + SuppressAttr Attr(A.getRange(), S.Context, Rules.data(), Rules.size(), +A.getAttributeSpellingListIndex()); + return ::new (S.Context) auto(Attr); +} + static Attr *handleLoopHintAttr(Sema , Stmt *St, const AttributeList , SourceRange) { IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0); @@ -283,6 +302,8 @@ return handleLoopHintAttr(S, St, A, Range); case AttributeList::AT_OpenCLUnrollHint: return handleOpenCLUnrollHint(S, St, A, Range); + case AttributeList::AT_Suppress: +return handleSuppressAttr(S, St, A, Range); default: // if we're here, then we parsed a known attribute, but didn't recognize // it as a statement attribute => it is declaration attribute Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -3838,6 +3838,24 @@ } } +static void handleSuppressAttr(Sema , Decl *D, const AttributeList ) { + std::vector Rules; + + for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) { +StringRef RuleName; +SourceLocation LiteralLoc; + +if (!S.checkStringLiteralArgumentAttr(Attr, I, RuleName, )) + return; + +Rules.push_back(RuleName); + } + D->addAttr(::new (S.Context) SuppressAttr( + Attr.getRange(), S.Context, Rules.data(), Rules.size(), + Attr.getAttributeSpellingListIndex())); +} + + bool Sema::CheckCallingConvAttr(const AttributeList , CallingConv , const FunctionDecl *FD) { if (attr.isInvalid()) @@ -5768,6 +5786,9 @@ case AttributeList::AT_PreserveAll: handleCallConvAttr(S, D, Attr); break; + case AttributeList::AT_Suppress: +handleSuppressAttr(S, D, Attr); +break; case AttributeList::AT_OpenCLKernel: handleSimpleAttribute(S, D, Attr); break; Index: include/clang/Basic/Attr.td === --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1451,6 +1451,12 @@ let Documentation = [SwiftIndirectResultDocs]; } +def Suppress : StmtAttr { + let Spellings = [CXX11<"clang", "suppress">]; + let Args = [VariadicStringArgument<"Rules">]; + let Documentation = [Undocumented]; +} + def SysVABI : InheritableAttr {
Re: [PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope
ahatanak updated this revision to Diff 72356. ahatanak added a comment. I agree that extending the logic of getTemplateInstantiationArgs seems like a better approach. I changed Sema::getTemplateInstantiationArgs to search for the template arguments twice, first for the initializer's template arguments and then for the VarTemplateSpecializationDecl. This should enable handling cases where a variable template is declared inside a class/struct. I wonder whether VarTemplateSpecializationDecl can be made a subclass of DeclContext and have it contain the lambda class of the initializer. I think that will simplify the logic of getTemplateInstantiationArgs. https://reviews.llvm.org/D23096 Files: include/clang/Sema/Sema.h lib/Sema/Sema.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplateInstantiate.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/vartemplate-lambda.cpp test/SemaTemplate/default-expr-arguments-3.cpp Index: test/SemaTemplate/default-expr-arguments-3.cpp === --- /dev/null +++ test/SemaTemplate/default-expr-arguments-3.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -std=c++14 -ast-dump %s 2>&1 | FileCheck %s + +namespace PR28795 { + // CHECK: FunctionDecl{{.*}}func 'void (void)' + // CHECK: LambdaExpr + // CHECK: CXXMethodDecl{{.*}}operator() 'enum foo (enum foo) const' inline + // CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit + // CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo' + + template + void func() { +enum class foo { a, b }; +auto bar = [](foo f = foo::a) { return f; }; +bar(); + } + + void foo() { +func(); + } +} + +// Template struct case: + +// CHECK: ClassTemplateSpecializationDecl{{.*}}struct class2 definition +// CHECK: LambdaExpr +// CHECK: CXXMethodDecl{{.*}}used operator() 'enum foo (enum foo) const' inline +// CHECK:ParmVarDecl{{.*}}f 'enum foo' cinit +// CHECK: DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo' + +template struct class2 { + void bar() { +enum class foo { a, b }; +[](foo f = foo::a) { return f; }(); + } +}; + +template struct class2; + +// CHECK: FunctionDecl{{.*}}f1 'void (void)' +// CHECK: CXXMethodDecl{{.*}}g1 'int (enum foo)' +// CHECK: ParmVarDecl{{.*}}n 'enum foo' cinit +// CHECK:DeclRefExpr{{.*}}'enum foo' EnumConstant{{.*}}'a' 'enum foo' + +template +void f1() { + enum class foo { a, b }; + struct S { +int g1(foo n = foo::a); + }; +} + +template void f1(); Index: test/SemaCXX/vartemplate-lambda.cpp === --- test/SemaCXX/vartemplate-lambda.cpp +++ test/SemaCXX/vartemplate-lambda.cpp @@ -1,15 +1,22 @@ // RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s -// expected-no-diagnostics template auto fn0 = [] {}; template void foo0() { fn0(); } template auto fn1 = [](auto a) { return a + T(1); }; +template auto v1 = [](int a = T(1)) { return a; }(); + +struct S { + template + static constexpr T t = [](int f = T(7)){return f;}(); // expected-error{{constexpr variable 't' must be initialized by a constant expression}} expected-error{{a lambda expression may not appear inside of a constant expression}} expected-note{{cannot be used in a constant expression}} +}; template int foo2() { X a = 0x61; fn1(a); + (void)v1; + (void)S::t; // expected-note{{in instantiation of static data member 'S::t' requested here}} return 0; } Index: lib/Sema/SemaTemplateInstantiateDecl.cpp === --- lib/Sema/SemaTemplateInstantiateDecl.cpp +++ lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3932,6 +3932,7 @@ { ContextRAII SwitchContext(*this, Var->getDeclContext()); + VarTemplateSpecializationRAII V(*this, Var); Init = SubstInitializer(OldVar->getInit(), TemplateArgs, OldVar->getInitStyle() == VarDecl::CallInit); } Index: lib/Sema/SemaTemplateInstantiate.cpp === --- lib/Sema/SemaTemplateInstantiate.cpp +++ lib/Sema/SemaTemplateInstantiate.cpp @@ -33,34 +33,10 @@ // Template Instantiation Support //===--===/ -/// \brief Retrieve the template argument list(s) that should be used to -/// instantiate the definition of the given declaration. -/// -/// \param D the declaration for which we are computing template instantiation -/// arguments. -/// -/// \param Innermost if non-NULL, the innermost template argument list. -/// -/// \param RelativeToPrimary true if we should get the template -/// arguments relative to the primary template, even when we're -/// dealing with a specialization. This is only relevant for function -/// template specializations. -/// -/// \param Pattern If non-NULL, indicates the pattern from which we will be -/// instantiating the definition
Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables
ahatanak added a comment. In https://reviews.llvm.org/D24693#551050, @vitalybuka wrote: > I can see how to insert starts, e.g. on every label which bypass declaration, > but I am not sure where to put ends. > Probably it's possible, but patch will be significantly more complicated. > I'd prefer to do so only when needed. > This is infrequent usecase, so it's probably not worth of additional > complexity. I think the right long term solution is to have IRGen emit tighter lifetime ranges, but I don't have a solution that I know would always work correctly. That might require rethinking the design of lifetime intrinsics. https://reviews.llvm.org/D24693 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24820: Add -stats-file option
bruno added a comment. Maybe add some docs to explain the new flags? Comment at: lib/Driver/Tools.cpp:6102 @@ +6101,3 @@ +StatsFile.assign(Output.getFilename()); +llvm::sys::path::remove_filename(StatsFile); + } MatzeB wrote: > bruno wrote: > > Why removing StatsFile here? IIUC, at this point StatsFile is still the > > same as the output (if it's a file). > a) It behaves like -save-temps=obj (`clang -save-temps=obj foo.c -o bar` will > give you foo.i, foo.o, ...; > b) This makes sense when you have multiple (`clang -save-stats=obj foo.c > bar.c -o baz`) inputs for which you need multiple .stats filenames but you > only have 1 output name > c) It magically works for `-o -` as well > Ok, I see now, I misread `remove_filename` as `remove` Comment at: test/Driver/save-stats.c:1 @@ +1,2 @@ +// RUN: %clang -target x86_64-apple-darwin -save-stats %s -### 2>&1 | FileCheck %s +// RUN: %clang -target x86_64-apple-darwin -save-stats=cwd %s -### 2>&1 | FileCheck %s Is -save-stats == -save-stats=cwd? It doesn't seem so by looking at lib/Driver/Tools.cpp. Need test for the diag::err_drv_invalid_value as well. Comment at: test/Driver/save-stats.c:12 @@ +11,3 @@ +// RUN: %clang -target x86_64-apple-darwin -save-stats=obj -c -o obj/dir/save-stats.o %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OBJ +// CHECK-OBJ: "-stats-file=obj/dir{{/|}}save-stats.stats" +// CHECK-OBJ: "-o" "obj/dir{{/|}}save-stats.o" aprantl wrote: > This is up to taste, but just accepting {{.}} as the path separator would be > sufficient IMO and might be more readable. +1 to Adrian's suggestion Repository: rL LLVM https://reviews.llvm.org/D24820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19854: Define Contiki OS toolchain
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko added a comment. Looks like patch was not committed. https://reviews.llvm.org/D19854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction
This revision was automatically updated to reflect the committed changes. Closed by commit rL282293: [analyzer] Fix crash in RetainCountChecker::checkEndFunction (authored by alexshap). Changed prior to commit: https://reviews.llvm.org/D24792?vs=72206=72354#toc Repository: rL LLVM https://reviews.llvm.org/D24792 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp cfe/trunk/test/Analysis/NSString.m Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -652,15 +652,19 @@ if (Mode == AM_None) return; + // Clear the AnalysisManager of old AnalysisDeclContexts. + Mgr->ClearContexts(); + // Ignore autosynthesized code. + if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized()) +return; + DisplayFunction(D, Mode, IMode); CFG *DeclCFG = Mgr->getCFG(D); if (DeclCFG) { unsigned CFGSize = DeclCFG->size(); MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize; } - // Clear the AnalysisManager of old AnalysisDeclContexts. - Mgr->ClearContexts(); BugReporter BR(*Mgr); if (Mode & AM_Syntax) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -3863,7 +3863,7 @@ // Don't process anything within synthesized bodies. const LocationContext *LCtx = Pred->getLocationContext(); if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) { -assert(LCtx->getParent()); +assert(!LCtx->inTopFrame()); return; } Index: cfe/trunk/test/Analysis/NSString.m === --- cfe/trunk/test/Analysis/NSString.m +++ cfe/trunk/test/Analysis/NSString.m @@ -289,7 +289,11 @@ _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) { return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue); } - +// Test that the analyzer doesn't crash when the farm model is used. +// The analyzer ignores the autosynthesized code. +_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) { + return 0; +} extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation); extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) { return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); @@ -441,4 +445,4 @@ - (void)callValue { [self _value]; } -@end \ No newline at end of file +@end Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp === --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -652,15 +652,19 @@ if (Mode == AM_None) return; + // Clear the AnalysisManager of old AnalysisDeclContexts. + Mgr->ClearContexts(); + // Ignore autosynthesized code. + if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized()) +return; + DisplayFunction(D, Mode, IMode); CFG *DeclCFG = Mgr->getCFG(D); if (DeclCFG) { unsigned CFGSize = DeclCFG->size(); MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize; } - // Clear the AnalysisManager of old AnalysisDeclContexts. - Mgr->ClearContexts(); BugReporter BR(*Mgr); if (Mode & AM_Syntax) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -3863,7 +3863,7 @@ // Don't process anything within synthesized bodies. const LocationContext *LCtx = Pred->getLocationContext(); if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) { -assert(LCtx->getParent()); +assert(!LCtx->inTopFrame()); return; } Index: cfe/trunk/test/Analysis/NSString.m === --- cfe/trunk/test/Analysis/NSString.m +++ cfe/trunk/test/Analysis/NSString.m @@ -289,7 +289,11 @@ _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) { return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue); } - +// Test that the analyzer doesn't crash when the farm model is used. +// The analyzer ignores the autosynthesized code. +_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile
r282293 - [analyzer] Fix crash in RetainCountChecker::checkEndFunction
Author: alexshap Date: Fri Sep 23 15:49:01 2016 New Revision: 282293 URL: http://llvm.org/viewvc/llvm-project?rev=282293=rev Log: [analyzer] Fix crash in RetainCountChecker::checkEndFunction The class BodyFarm creates bodies for OSAtomicCompareAndSwap*, objc_atomicCompareAndSwap*, dispatch_sync*, dispatch_once* and for them the flag isBodyAutosynthesized is set to true. This diff 1. makes AnalysisConsumer::HandleCode skip the autosynthesized code 2. replaces assert(LCtx->getParent()) in RetainCountChecker::checkEndFunction by assert(!LCtx->inTopFrame()) (minor cleanup) Test plan: make -j8 check-clang-analysis Differential revision: https://reviews.llvm.org/D24792 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp cfe/trunk/test/Analysis/NSString.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=282293=282292=282293=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri Sep 23 15:49:01 2016 @@ -3863,7 +3863,7 @@ void RetainCountChecker::checkEndFunctio // Don't process anything within synthesized bodies. const LocationContext *LCtx = Pred->getLocationContext(); if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) { -assert(LCtx->getParent()); +assert(!LCtx->inTopFrame()); return; } Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=282293=282292=282293=diff == --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Fri Sep 23 15:49:01 2016 @@ -652,6 +652,12 @@ void AnalysisConsumer::HandleCode(Decl * if (Mode == AM_None) return; + // Clear the AnalysisManager of old AnalysisDeclContexts. + Mgr->ClearContexts(); + // Ignore autosynthesized code. + if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized()) +return; + DisplayFunction(D, Mode, IMode); CFG *DeclCFG = Mgr->getCFG(D); if (DeclCFG) { @@ -659,8 +665,6 @@ void AnalysisConsumer::HandleCode(Decl * MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize; } - // Clear the AnalysisManager of old AnalysisDeclContexts. - Mgr->ClearContexts(); BugReporter BR(*Mgr); if (Mode & AM_Syntax) Modified: cfe/trunk/test/Analysis/NSString.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=282293=282292=282293=diff == --- cfe/trunk/test/Analysis/NSString.m (original) +++ cfe/trunk/test/Analysis/NSString.m Fri Sep 23 15:49:01 2016 @@ -289,7 +289,11 @@ _Bool opaque_OSAtomicCompareAndSwapPtr( _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) { return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue); } - +// Test that the analyzer doesn't crash when the farm model is used. +// The analyzer ignores the autosynthesized code. +_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) { + return 0; +} extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation); extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) { return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); @@ -441,4 +445,4 @@ void testOSCompareAndSwapXXBarrier_param - (void)callValue { [self _value]; } -@end \ No newline at end of file +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23752: cmake: Supporting overriding runtime libdir via CLANG_LIBDIR_SUFFIX
beanz added a reviewer: rnk. beanz added a comment. This looks reasonable to me, but I'm not super familiar with multi-lib conventions. I think @chandlerc is more familiar with how that stuff works. https://reviews.llvm.org/D23752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24884: Fix PR30274
arphaman created this revision. arphaman added a reviewer: rsmith. arphaman added a subscriber: cfe-commits. arphaman set the repository for this revision to rL LLVM. This fixes PR 30274 by making sure that we skip the 'Using' and 'ConstructorUsingShadowDecl' declarations when evaluating the '__has_nothrow_constructor' trait for a C++ type. Repository: rL LLVM https://reviews.llvm.org/D24884 Files: lib/Sema/SemaExprCXX.cpp test/SemaCXX/PR30274-inherited-constructor-has-nothrow.cpp Index: test/SemaCXX/PR30274-inherited-constructor-has-nothrow.cpp === --- /dev/null +++ test/SemaCXX/PR30274-inherited-constructor-has-nothrow.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// expected-no-diagnostics + +struct Base { +Base(int a) : i(a) {} +int i; +}; + +struct Derived : Base { +using Base::Base; +}; + +int foo() { + return __has_nothrow_constructor(Derived); +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -4258,7 +4258,10 @@ bool FoundConstructor = false; for (const auto *ND : Self.LookupConstructors(RD)) { // FIXME: In C++0x, a constructor template can be a default constructor. -if (isa(ND)) +// Skip the inherited constructors as we are only interested in default +// constructors which can't be inherited. +if (isa(ND) || isa(ND) || +isa(ND)) continue; const CXXConstructorDecl *Constructor = cast(ND); if (Constructor->isDefaultConstructor()) { Index: test/SemaCXX/PR30274-inherited-constructor-has-nothrow.cpp === --- /dev/null +++ test/SemaCXX/PR30274-inherited-constructor-has-nothrow.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// expected-no-diagnostics + +struct Base { +Base(int a) : i(a) {} +int i; +}; + +struct Derived : Base { +using Base::Base; +}; + +int foo() { + return __has_nothrow_constructor(Derived); +} Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -4258,7 +4258,10 @@ bool FoundConstructor = false; for (const auto *ND : Self.LookupConstructors(RD)) { // FIXME: In C++0x, a constructor template can be a default constructor. -if (isa(ND)) +// Skip the inherited constructors as we are only interested in default +// constructors which can't be inherited. +if (isa(ND) || isa(ND) || +isa(ND)) continue; const CXXConstructorDecl *Constructor = cast(ND); if (Constructor->isDefaultConstructor()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Broken bot
Funny, git-svnrevert is buggy, I had to do it by hand, but now it's done: r282289. Let me know if you need help testing it. --renato On 23 September 2016 at 21:28, Renato Golinwrote: > Now has broken the other: > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 > > But when I try to revert, git get entangled with another commit and > brings a lot of unrelated changes to it. > > I'll continue trying to revert, but if you can do it faster, I'd appreciate. > > thanks! > --renato > > On 23 September 2016 at 20:04, Renato Golin wrote: >> Hi Sebastian, >> >> This commit: >> >> http://llvm.org/viewvc/llvm-project?revision=282259=revision >> >> Has broken our AArch64 bot: >> >> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 >> >> But the cfe part seems odd, and I can't revert. Can you please have a look? >> >> cheers, >> --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
This revision was automatically updated to reflect the committed changes. Closed by commit rL282291: [LTO] Add -flto-jobs=N to control backend parallelism (authored by tejohnson). Changed prior to commit: https://reviews.llvm.org/D24826?vs=72317=72349#toc Repository: rL LLVM https://reviews.llvm.org/D24826 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/test/Driver/lto-jobs.c Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -812,6 +812,11 @@ HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, HelpText<"Disable LTO mode (default)">; +def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, + Flags<[CC1Option]>, Group, + HelpText<"Controls the backend parallelism of -flto=thin (default " + "of 0 means the number of threads will be derived from " + "the number of CPUs detected)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, Flags<[CC1Option]>, Group, HelpText<"Perform ThinLTO importing using provided function summary index">; Index: cfe/trunk/test/Driver/lto-jobs.c === --- cfe/trunk/test/Driver/lto-jobs.c +++ cfe/trunk/test/Driver/lto-jobs.c @@ -0,0 +1,11 @@ +// Confirm that -flto-jobs=N is passed to linker + +// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5" + +// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5" Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -1998,8 +1998,19 @@ } } +static unsigned getLTOParallelism(const ArgList , const Driver ) { + unsigned Parallelism = 0; + Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ); + if (LtoJobsArg && + StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism)) +D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args) +<< LtoJobsArg->getValue(); + return Parallelism; +} + static void AddGoldPlugin(const ToolChain , const ArgList , - ArgStringList , bool IsThinLTO) { + ArgStringList , bool IsThinLTO, + const Driver ) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs // as gold requires -plugin to come before any -plugin-opt that -Wl might // forward. @@ -2032,6 +2043,10 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + if (unsigned Parallelism = getLTOParallelism(Args, D)) +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + + std::to_string(Parallelism))); + // If an explicit debugger tuning argument appeared, pass it along. if (Arg *A = Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { @@ -7639,7 +7654,7 @@ options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -8060,6 +8075,13 @@ getMachOToolChain().addProfileRTLibs(Args, CmdArgs); + if (unsigned Parallelism = + getLTOParallelism(Args, getToolChain().getDriver())) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back( +Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism))); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { if (getToolChain().getDriver().CCCIsCXX()) getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); @@ -8790,7 +8812,7 @@ Args.AddAllArgs(CmdArgs, options::OPT_r); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -9623,7 +9645,7 @@ ToolChain.AddFilePathLibArgs(Args, CmdArgs); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
r282291 - [LTO] Add -flto-jobs=N to control backend parallelism
Author: tejohnson Date: Fri Sep 23 15:38:09 2016 New Revision: 282291 URL: http://llvm.org/viewvc/llvm-project?rev=282291=rev Log: [LTO] Add -flto-jobs=N to control backend parallelism Summary: Currently, a linker option must be used to control the backend parallelism of ThinLTO. The linker option varies depending on the linker (e.g. gold vs ld64). Add a new clang option -flto-jobs=N to control this. I've added in the wiring to pass this to the gold plugin. I also added in the logic to pass this down in the form I understand that ld64 uses on MacOS, for the darwin target. Reviewers: mehdi_amini, dexonsmith Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D24826 Added: cfe/trunk/test/Driver/lto-jobs.c Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=282291=282290=282291=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Fri Sep 23 15:38:09 2016 @@ -812,6 +812,11 @@ def flto : Flag<["-"], "flto">, Flags<[C HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, HelpText<"Disable LTO mode (default)">; +def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, + Flags<[CC1Option]>, Group, + HelpText<"Controls the backend parallelism of -flto=thin (default " + "of 0 means the number of threads will be derived from " + "the number of CPUs detected)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, Flags<[CC1Option]>, Group, HelpText<"Perform ThinLTO importing using provided function summary index">; Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=282291=282290=282291=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 23 15:38:09 2016 @@ -1998,8 +1998,19 @@ static std::string getCPUName(const ArgL } } +static unsigned getLTOParallelism(const ArgList , const Driver ) { + unsigned Parallelism = 0; + Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ); + if (LtoJobsArg && + StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism)) +D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args) +<< LtoJobsArg->getValue(); + return Parallelism; +} + static void AddGoldPlugin(const ToolChain , const ArgList , - ArgStringList , bool IsThinLTO) { + ArgStringList , bool IsThinLTO, + const Driver ) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs // as gold requires -plugin to come before any -plugin-opt that -Wl might // forward. @@ -2032,6 +2043,10 @@ static void AddGoldPlugin(const ToolChai if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + if (unsigned Parallelism = getLTOParallelism(Args, D)) +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + + std::to_string(Parallelism))); + // If an explicit debugger tuning argument appeared, pass it along. if (Arg *A = Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { @@ -7639,7 +7654,7 @@ void cloudabi::Linker::ConstructJob(Comp options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -8060,6 +8075,13 @@ void darwin::Linker::ConstructJob(Compil getMachOToolChain().addProfileRTLibs(Args, CmdArgs); + if (unsigned Parallelism = + getLTOParallelism(Args, getToolChain().getDriver())) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back( +Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism))); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { if (getToolChain().getDriver().CCCIsCXX()) getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); @@ -8790,7 +8812,7 @@ void freebsd::Linker::ConstructJob(Compi Args.AddAllArgs(CmdArgs, options::OPT_r); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -9623,7 +9645,7 @@ void
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
rengolin added a subscriber: rengolin. rengolin added a comment. Folks, this commit has broken both AArch64 test-suite buildbots: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 I have reverted in r282289, let me know if you need help testing on AArch64. Repository: rL LLVM https://reviews.llvm.org/D24481 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22270: [ASTImporter] Properly report the locations of anonymous structs declared as part of named fields
Eugene.Zelenko added a subscriber: Eugene.Zelenko. Eugene.Zelenko closed this revision. Eugene.Zelenko added a comment. Committed in r275460. Repository: rL LLVM https://reviews.llvm.org/D22270 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24881: [clang-tidy] Cleaning up language options.
xazax.hun created this revision. xazax.hun added reviewers: hokein, alexfh. xazax.hun added a subscriber: cfe-commits. xazax.hun set the repository for this revision to rL LLVM. xazax.hun added a project: clang-tools-extra. Herald added a subscriber: nemanjai. In some cases do not register the matcher when the check method of a checker should not run anyways. Refactor some checks to use a shorter way to get language options. Repository: rL LLVM https://reviews.llvm.org/D24881 Files: clang-tidy/cert/StrToNumCheck.cpp clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp clang-tidy/google/AvoidCStyleCastsCheck.cpp clang-tidy/google/ExplicitConstructorCheck.cpp clang-tidy/llvm/TwineLocalCheck.cpp clang-tidy/misc/AssertSideEffectCheck.cpp clang-tidy/misc/InaccurateEraseCheck.cpp clang-tidy/misc/InefficientAlgorithmCheck.cpp clang-tidy/misc/StringIntegerAssignmentCheck.cpp clang-tidy/misc/SuspiciousStringCompareCheck.cpp clang-tidy/misc/UniqueptrResetReleaseCheck.cpp clang-tidy/misc/UnusedAliasDeclsCheck.cpp clang-tidy/misc/UnusedRAIICheck.cpp clang-tidy/misc/UnusedUsingDeclsCheck.cpp clang-tidy/modernize/PassByValueCheck.cpp clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tidy/modernize/ShrinkToFitCheck.cpp clang-tidy/modernize/UseOverrideCheck.cpp clang-tidy/mpi/TypeMismatchCheck.cpp clang-tidy/readability/AvoidConstParamsInDecls.cpp clang-tidy/readability/ContainerSizeEmptyCheck.cpp clang-tidy/readability/NamespaceCommentCheck.cpp clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tidy/readability/RedundantSmartptrGetCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Index: clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp === --- clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp +++ clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp @@ -53,7 +53,7 @@ SourceLocation AfterPtr = Lexer::getLocForEndOfToken(PtrExpr->getLocEnd(), 0, *Result.SourceManager, - Result.Context->getLangOpts()); + getLangOpts()); diag(DeleteExpr->getLocStart(), "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> " Index: clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp === --- clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp +++ clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp @@ -54,11 +54,11 @@ SourceLocation Loc = Def->getSourceRange().getBegin(); while (Loc < Def->getSourceRange().getEnd() && !Lexer::getRawToken(Loc, Tok, *Result.SourceManager, - Result.Context->getLangOpts(), true)) { + getLangOpts(), true)) { SourceRange TokenRange(Tok.getLocation(), Tok.getEndLoc()); StringRef SourceText = Lexer::getSourceText( CharSourceRange::getTokenRange(TokenRange), -*Result.SourceManager, Result.Context->getLangOpts()); +*Result.SourceManager, getLangOpts()); if (SourceText == "static") { Diag << FixItHint::CreateRemoval(TokenRange); break; Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp === --- clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -561,7 +561,7 @@ StringRef Replacement) { CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(ReplacementRange), *Result.SourceManager, - Result.Context->getLangOpts()); + getLangOpts()); DiagnosticBuilder Diag = diag(Loc, Description); if (!containsDiscardedTokens(Result, CharRange)) Index: clang-tidy/readability/RedundantSmartptrGetCheck.cpp === --- clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -119,7 +119,7 @@ StringRef SmartptrText = Lexer::getSourceText( CharSourceRange::getTokenRange(Smartptr->getSourceRange()), - *Result.SourceManager, Result.Context->getLangOpts()); + *Result.SourceManager, getLangOpts()); // Replace foo->get() with *foo, and foo.get() with foo. std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str(); diag(GetCall->getLocStart(), "redundant get() call on smart pointer") Index: clang-tidy/readability/RedundantControlFlowCheck.cpp === --- clang-tidy/readability/RedundantControlFlowCheck.cpp +++ clang-tidy/readability/RedundantControlFlowCheck.cpp @@ -81,14
Re: Broken bot
Now has broken the other: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/3162 But when I try to revert, git get entangled with another commit and brings a lot of unrelated changes to it. I'll continue trying to revert, but if you can do it faster, I'd appreciate. thanks! --renato On 23 September 2016 at 20:04, Renato Golinwrote: > Hi Sebastian, > > This commit: > > http://llvm.org/viewvc/llvm-project?revision=282259=revision > > Has broken our AArch64 bot: > > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/10449 > > But the cfe part seems odd, and I can't revert. Can you please have a look? > > cheers, > --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24878: ASTImporter: expressions, pt.2
khazem added a comment. This diff is a continuation of https://reviews.llvm.org/D14326, which was accepted for inclusion but has not been merged in for the past couple of months. I added a small patch so that it rebases cleanly onto master: --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2309,16 +2309,9 @@ bool ASTNodeImporter::ImportDefinition(EnumDecl *From, EnumDecl *To, TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList( TemplateParameterList *Params) { - SmallVector ToParams; - ToParams.reserve(Params->size()); - for (TemplateParameterList::iterator P = Params->begin(), -PEnd = Params->end(); - P != PEnd; ++P) { -Decl *To = Importer.Import(*P); -if (!To) - return nullptr; -ToParams.push_back(cast(To)); - } + SmallVector ToParams(Params->size()); + if (ImportContainerChecked(*Params, ToParams)) +return nullptr; Expr *ToRequiresClause; if (Expr *const R = Params->getRequiresClause()) { One of the tests is currently failing with this patch. Specifically, there is a segfault at line 130 of test/ASTMerge/Inputs/exprs3.cpp. I'm working on getting this fixed now. https://reviews.llvm.org/D24878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
mehdi_amini accepted this revision. mehdi_amini added a comment. This revision is now accepted and ready to land. LGTM, Thanks! https://reviews.llvm.org/D24826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24879: [libc++] Remove math_win32.h
smeenai created this revision. smeenai added reviewers: compnerd, EricWF, mclow.lists. smeenai added a subscriber: cfe-commits. Visual Studio 2013 and onward have all the required functions in their CRT headers, and we don't support older versions anymore. https://reviews.llvm.org/D24879 Files: include/math.h include/support/win32/math_win32.h Index: include/support/win32/math_win32.h === --- include/support/win32/math_win32.h +++ /dev/null @@ -1,117 +0,0 @@ -// -*- C++ -*- -//===-- support/win32/math_win32.h ===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===--===// - -#ifndef _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H -#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H - -#if !defined(_LIBCPP_MSVCRT) -#error "This header complements Microsoft's C Runtime library, and should not be included otherwise." -#else - -#include -#include // _FPCLASS_PN etc. -#include - -#if ((_VC_CRT_MAJOR_VERSION-0) < 12) -// Necessary? -typedef float float_t; -typedef double double_t; - -_LIBCPP_ALWAYS_INLINE bool isfinite( double num ) -{ -return _finite(num) != 0; -} -_LIBCPP_ALWAYS_INLINE bool isinf( double num ) -{ -return !isfinite(num) && !_isnan(num); -} -_LIBCPP_ALWAYS_INLINE bool isnan( double num ) -{ -return _isnan(num) != 0; -} -_LIBCPP_ALWAYS_INLINE bool isnormal( double num ) -{ -int class_ = _fpclass(num); -return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN; -} - -_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y ) -{ -if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; -else return x > y; -} - -_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y ) -{ -if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; -else return x >= y; -} - -_LIBCPP_ALWAYS_INLINE bool isless( double x, double y ) -{ -if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false; -else return x < y; -} - -_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y ) -{ -if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false; -else return x <= y; -} - -_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y ) -{ -if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false; -else return x < y || x > y; -} - -_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y ) -{ -return isnan(x) || isnan(y); -} -_LIBCPP_ALWAYS_INLINE bool signbit( double num ) -{ -switch(_fpclass(num)) -{ -case _FPCLASS_SNAN: -case _FPCLASS_QNAN: -case _FPCLASS_NINF: -case _FPCLASS_NN: -case _FPCLASS_ND: -case _FPCLASS_NZ: -return true; -case _FPCLASS_PZ: -case _FPCLASS_PD: -case _FPCLASS_PN: -case _FPCLASS_PINF: -return false; -} -return false; -} -_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y ) -{ -return (signbit (x) != signbit (y) ? - x : x); -} -_LIBCPP_ALWAYS_INLINE double copysign( double x, double y ) -{ -return ::_copysign(x,y); -} -_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y ) -{ -return ::_copysignl(x,y); -} -_LIBCPP_ALWAYS_INLINE int fpclassify( double num ) -{ -return _fpclass(num); -} -#endif -#endif // _LIBCPP_MSVCRT - -#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H Index: include/math.h === --- include/math.h +++ include/math.h @@ -308,10 +308,6 @@ #include -#ifdef _LIBCPP_MSVCRT -#include "support/win32/math_win32.h" -#endif - // signbit #ifdef signbit ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24878: ASTImporter: expressions, pt.2
khazem created this revision. khazem added reviewers: spyffe, sepavloff. khazem added subscribers: phosek, khazem, NoQ, xazax.hun, cfe-commits. This patch implements some expression-related AST node import (patch #2). - Some code cleanup - Add tests not present in http://reviews.llvm.org/D14286 - Integrate a test suite from Serge Pavlov (http://reviews.llvm.org/D14224) - Implement import of some nodes: ArrayTypeTraitExpr ExpressionTraitExpr OpaqueValueExpr ArraySubscriptExpr ExplicitCastExpr ImplicitValueInitExpr OffsetOfExpr CXXThisExpr CXXThrowExpr CXXNoexceptExpr CXXDefaultArgExpr CXXScalarValueInitExpr CXXBindTemporaryExpr CXXTemporaryObjectExpr MaterializeTemporaryExpr ExprWithCleanups StaticAssertDecl FriendDecl DecayedType https://reviews.llvm.org/D24878 Files: include/clang/AST/ASTImporter.h include/clang/AST/DeclFriend.h lib/AST/ASTImporter.cpp test/ASTMerge/Inputs/class3.cpp test/ASTMerge/Inputs/exprs3.cpp test/ASTMerge/class2.cpp test/ASTMerge/exprs.cpp unittests/AST/ASTImporterTest.cpp Index: unittests/AST/ASTImporterTest.cpp === --- unittests/AST/ASTImporterTest.cpp +++ unittests/AST/ASTImporterTest.cpp @@ -456,5 +456,24 @@ } +const internal::VariadicDynCastAllOfMatchervaArgExpr; + +TEST(ImportExpr, ImportVAArgExpr) { + MatchVerifier Verifier; + EXPECT_TRUE( +testImport( + "void declToImport(__builtin_va_list list, ...) {" + " (void)__builtin_va_arg(list, int); }", + Lang_CXX, "", Lang_CXX, Verifier, + functionDecl( +hasBody( + compoundStmt( +has( + cStyleCastExpr( +hasSourceExpression( + vaArgExpr(); +} + + } // end namespace ast_matchers } // end namespace clang Index: test/ASTMerge/exprs.cpp === --- /dev/null +++ test/ASTMerge/exprs.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -emit-pch -o %t.1.ast %S/Inputs/exprs3.cpp +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -fcxx-exceptions -ast-merge %t.1.ast -fsyntax-only -verify %s +// expected-no-diagnostics + +static_assert(Ch1 == 'a'); +static_assert(Ch2 == 'b'); +static_assert(Ch3 == 'c'); + +static_assert(Ch4 == L'd'); +static_assert(Ch5 == L'e'); +static_assert(Ch6 == L'f'); + +static_assert(C1 == 12); +static_assert(C2 == 13); + +static_assert(C3 == 12); +static_assert(C4 == 13); + +static_assert(C5 == 22L); +static_assert(C6 == 23L); + +static_assert(C7 == 66LL); +static_assert(C8 == 67ULL); + +static_assert(bval1 == true); +static_assert(bval2 == false); + +static_assert(ExpressionTrait == false); + +static_assert(ArrayRank == 2); +static_assert(ArrayExtent == 20); + +void testImport(int *x, const S1 , S1 ) { + testNewThrowDelete(); + testArrayElement(nullptr, 12); + testTernaryOp(0, 1, 2); + testConstCast(cs1); + testStaticCast(s1); + testReinterpretCast(s1); + testDynamicCast(s1); + testScalarInit(42); + testOffsetOf(); + testDefaultArg(12); + useTemplateType(); +} Index: test/ASTMerge/class2.cpp === --- /dev/null +++ test/ASTMerge/class2.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -emit-pch -o %t.1.ast %S/Inputs/class3.cpp +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z -ast-merge %t.1.ast -fsyntax-only -verify %s +// expected-no-diagnostics + +class C3 { + int method_1(C2 *x) { +return x->x; + } +}; Index: test/ASTMerge/Inputs/exprs3.cpp === --- /dev/null +++ test/ASTMerge/Inputs/exprs3.cpp @@ -0,0 +1,131 @@ +// Integer literals +const char Ch1 = 'a'; +const signed char Ch2 = 'b'; +const unsigned char Ch3 = 'c'; + +const wchar_t Ch4 = L'd'; +const signed wchar_t Ch5 = L'e'; +const unsigned wchar_t Ch6 = L'f'; + +const short C1 = 12; +const unsigned short C2 = 13; + +const int C3 = 12; +const unsigned int C4 = 13; + +const long C5 = 22; +const unsigned long C6 = 23; + +const long long C7 = 66; +const unsigned long long C8 = 67; + + +// String literals +const char str1[] = "ABCD"; +const char str2[] = "ABCD" "0123"; + +const wchar_t wstr1[] = L"DEF"; +const wchar_t wstr2[] = L"DEF" L"123"; + + +// Boolean literals +const bool bval1 = true; +const bool bval2 = false; + +// Floating Literals +const float F1 = 12.2F; +const double F2 = 1E4; +const long double F3 = 1.2E-3L; + + +// nullptr literal +const void *vptr = nullptr; + + +int glb_1[4] = { 10, 20, 30, 40 }; + +struct S1 { + int a; + int b[3]; +}; + +struct S2 { + int c; + S1 d; +}; + +S2 glb_2 = { 22, .d.a = 44, .d.b[0] = 55, .d.b[1] = 66 }; + +void testNewThrowDelete() { + throw; + char *p = new char[10]; + delete[] p; +} + +int testArrayElement(int *x, int n) { + return x[n]; +} + +int
[PATCH] D24877: [libc++] Default to DLL semantics on Windows
smeenai created this revision. smeenai added reviewers: compnerd, EricWF, mclow.lists. smeenai added a subscriber: cfe-commits. On Windows builds, we currently require `_LIBCPP_DLL` to be specified in order for dllexport/dllimport annotations to be generated. I believe it's better to do the opposite, i.e. require a macro to be present in order to *not* include the annotations, since building libc++ shared is more common. The problem with having the DLL annotations be opt-in is that any project using the libc++ headers and linking against a libc++ DLL must specify `_LIBCPP_DLL` in its build system, otherwise the libc++ headers will not be annotated with dllimport. This lack of annotation will then cause inefficient code generation, since the linker will generate import thunks. No compile-time errors will be reported (except in the case of data symbols, for which import thunks are not possible) about this inefficient code generation. In contrast, having the DLL annotations be opt-out means that any project using the libc++ headers and linking against a static libc++ will fail to link with missing import table entries if the project forgets to specify the macro to suppress DLL annotations. Link errors seem far preferable to silent inefficient code generation. https://reviews.llvm.org/D24877 Files: include/__config Index: include/__config === --- include/__config +++ include/__config @@ -548,15 +548,16 @@ #ifdef _WIN32 -// only really useful for a DLL. _LIBCPP_DLL should be a compiler builtin define ideally... -#if defined(_LIBCPP_DLL) && defined(cxx_EXPORTS) +#if !defined(_LIBCPP_STATIC_BUILD) +#if defined(cxx_EXPORTS) # define _LIBCPP_DLL_VIS __declspec(dllexport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS -#elif defined(_LIBCPP_DLL) +#else # define _LIBCPP_DLL_VIS __declspec(dllimport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS +#endif #else # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS Index: include/__config === --- include/__config +++ include/__config @@ -548,15 +548,16 @@ #ifdef _WIN32 -// only really useful for a DLL. _LIBCPP_DLL should be a compiler builtin define ideally... -#if defined(_LIBCPP_DLL) && defined(cxx_EXPORTS) +#if !defined(_LIBCPP_STATIC_BUILD) +#if defined(cxx_EXPORTS) # define _LIBCPP_DLL_VIS __declspec(dllexport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS -#elif defined(_LIBCPP_DLL) +#else # define _LIBCPP_DLL_VIS __declspec(dllimport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS +#endif #else # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14326: ASTImporter: expressions, pt.2
khazem added a comment. I'm updating this patch so that it rebases cleanly onto master, as this patch hasn't been updated for a couple of months... At the time of writing, one of Clang's tests is failing with this patch. Specifically, there is a segfault at line 130 of test/ASTMerge/Inputs/exprs3.cpp. I'm working on getting this fixed now. https://reviews.llvm.org/D14326 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables
vitalybuka added a comment. In https://reviews.llvm.org/D24693#550119, @ahatanak wrote: > Thank you for the great example! I can now see this patch does fix > mis-compiles. > > There are probably other lifetime bugs you'll see when the code being > compiled includes gotos that jump past variable declarations, including the > one here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html. Do > you think you can extend the approach taken in this patch to prevent > mis-compiles for those too? This probably can be extended to this case, but I'd prefer to do this in separate patch later. > Also, rather than removing the intrinsics altogether, have you considered > making changes to IRGen to insert them to different locations or insert extra > lifetime.starts? I can see how to insert starts, e.g. on every label which bypass declaration, but I am not sure where to put ends. Probably it's possible, but patch will be significantly more complicated. I'd prefer to do so only when needed. This is infrequent usecase, so it's probably not worth of additional complexity. https://reviews.llvm.org/D24693 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21066: Pass MCSubtargetInfo instead of CPU and Triple to createMCAsmBackend
aturetsk abandoned this revision. aturetsk added a comment. New version in https://reviews.llvm.org/D21374 https://reviews.llvm.org/D21066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators
Do you have some data on the true/false positive rate for this warning? On Fri, Sep 23, 2016 at 6:12 AM Daniel Marjamäki < daniel.marjam...@evidente.se> wrote: > danielmarjamaki created this revision. > danielmarjamaki added reviewers: dblaikie, rtrieu. > danielmarjamaki added a subscriber: cfe-commits. > danielmarjamaki set the repository for this revision to rL LLVM. > > This patch makes Clang warn about following code: > > a = (b * c >> 2); > > It might be a good idea to use parentheses to clarify the operator > precedence. > > > Repository: > rL LLVM > > https://reviews.llvm.org/D24861 > > Files: > lib/Sema/SemaExpr.cpp > test/Sema/parentheses.cpp > > Index: test/Sema/parentheses.cpp > === > --- test/Sema/parentheses.cpp > +++ test/Sema/parentheses.cpp > @@ -95,6 +95,21 @@ >// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"(" >// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")" > > + (void)(a >> b * c); // expected-warning {{operator '>>' has lower > precedence than '*'; '*' will be evaluated first}} \ > + expected-note {{place parentheses around the '*' > expression to silence this warning}} > + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"(" > + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")" > + > + (void)(a / b << c); // expected-warning {{operator '<<' has lower > precedence than '/'; '/' will be evaluated first}} \ > + expected-note {{place parentheses around the '/' > expression to silence this warning}} > + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"(" > + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")" > + > + (void)(a % b << c); // expected-warning {{operator '<<' has lower > precedence than '%'; '%' will be evaluated first}} \ > + expected-note {{place parentheses around the '%' > expression to silence this warning}} > + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"(" > + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")" > + >Stream() << b + c; >Stream() >> b + c; // expected-warning {{operator '>>' has lower > precedence than '+'; '+' will be evaluated first}} \ > expected-note {{place parentheses around the '+' > expression to silence this warning}} > Index: lib/Sema/SemaExpr.cpp > === > --- lib/Sema/SemaExpr.cpp > +++ lib/Sema/SemaExpr.cpp > @@ -11246,10 +11246,10 @@ >} > } > > -static void DiagnoseAdditionInShift(Sema , SourceLocation OpLoc, > +static void DiagnoseAddOrMulInShift(Sema , SourceLocation OpLoc, > Expr *SubExpr, StringRef Shift) { >if (BinaryOperator *Bop = dyn_cast(SubExpr)) { > -if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) { > +if (Bop->isAdditiveOp() || Bop->isMultiplicativeOp()) { >StringRef Op = Bop->getOpcodeStr(); >S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift) ><< Bop->getSourceRange() << OpLoc << Shift << Op; > @@ -11313,8 +11313,8 @@ >if ((Opc == BO_Shl && > LHSExpr->getType()->isIntegralType(Self.getASTContext())) >|| Opc == BO_Shr) { > StringRef Shift = BinaryOperator::getOpcodeStr(Opc); > -DiagnoseAdditionInShift(Self, OpLoc, LHSExpr, Shift); > -DiagnoseAdditionInShift(Self, OpLoc, RHSExpr, Shift); > +DiagnoseAddOrMulInShift(Self, OpLoc, LHSExpr, Shift); > +DiagnoseAddOrMulInShift(Self, OpLoc, RHSExpr, Shift); >} > >// Warn on overloaded shift operators and comparisons, such as: > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
tejohnson updated this revision to Diff 72317. tejohnson added a comment. Update option help message per Mehdi's suggestion https://reviews.llvm.org/D24826 Files: include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/lto-jobs.c Index: test/Driver/lto-jobs.c === --- /dev/null +++ test/Driver/lto-jobs.c @@ -0,0 +1,11 @@ +// Confirm that -flto-jobs=N is passed to linker + +// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5" + +// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1998,8 +1998,19 @@ } } +static unsigned getLTOParallelism(const ArgList , const Driver ) { + unsigned Parallelism = 0; + Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ); + if (LtoJobsArg && + StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism)) +D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args) +<< LtoJobsArg->getValue(); + return Parallelism; +} + static void AddGoldPlugin(const ToolChain , const ArgList , - ArgStringList , bool IsThinLTO) { + ArgStringList , bool IsThinLTO, + const Driver ) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs // as gold requires -plugin to come before any -plugin-opt that -Wl might // forward. @@ -2032,6 +2043,10 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + if (unsigned Parallelism = getLTOParallelism(Args, D)) +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + + std::to_string(Parallelism))); + // If an explicit debugger tuning argument appeared, pass it along. if (Arg *A = Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { @@ -7639,7 +7654,7 @@ options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -8060,6 +8075,13 @@ getMachOToolChain().addProfileRTLibs(Args, CmdArgs); + if (unsigned Parallelism = + getLTOParallelism(Args, getToolChain().getDriver())) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back( +Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism))); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { if (getToolChain().getDriver().CCCIsCXX()) getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); @@ -8790,7 +8812,7 @@ Args.AddAllArgs(CmdArgs, options::OPT_r); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -9623,7 +9645,7 @@ ToolChain.AddFilePathLibArgs(Args, CmdArgs); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) CmdArgs.push_back("--no-demangle"); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -812,6 +812,11 @@ HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, HelpText<"Disable LTO mode (default)">; +def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, + Flags<[CC1Option]>, Group, + HelpText<"Controls the backend parallelism of -flto=thin (default " + "of 0 means the number of threads will be derived from " + "the number of CPUs detected)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, Flags<[CC1Option]>, Group, HelpText<"Perform ThinLTO importing using provided function summary index">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24820: Add -stats-file option
MatzeB added inline comments. Comment at: lib/Driver/Tools.cpp:6102 @@ +6101,3 @@ +StatsFile.assign(Output.getFilename()); +llvm::sys::path::remove_filename(StatsFile); + } bruno wrote: > Why removing StatsFile here? IIUC, at this point StatsFile is still the same > as the output (if it's a file). a) It behaves like -save-temps=obj (`clang -save-temps=obj foo.c -o bar` will give you foo.i, foo.o, ...; b) This makes sense when you have multiple (`clang -save-stats=obj foo.c bar.c -o baz`) inputs for which you need multiple .stats filenames but you only have 1 output name c) It magically works for `-o -` as well Repository: rL LLVM https://reviews.llvm.org/D24820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed
rSerge updated this revision to Diff 72312. rSerge added a comment. Herald added a subscriber: rampitec. Added a test. Changed the error message to: > clang++.exe: error: the clang compiler does not support '-fxray-instrument on > armv6kz--linux-gnueabihf' https://reviews.llvm.org/D24799 Files: lib/Driver/Tools.cpp test/Driver/xray-instrument.c Index: test/Driver/xray-instrument.c === --- test/Driver/xray-instrument.c +++ test/Driver/xray-instrument.c @@ -0,0 +1,2 @@ +// RUN: %clang -fxray-instrument %s +// XFAIL: armeb,aarch64,aarch64_be,avr,bpfel,bpfeb,hexagon,mips,mipsel,mips64,mips64el,msp430,ppc,ppc64,ppc64le,r600,amdgcn,sparc,sparcv9,sparcel,systemz,tce,thumb,thumbeb,x86,xcore,nvptx,nvptx64,le32,le64,amdil,amdil64,hsail,hsail64,spir,spir64,kalimba,shave,lanai,wasm32,wasm64,renderscript32,renderscript64 Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4767,7 +4767,20 @@ if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { -CmdArgs.push_back("-fxray-instrument"); +const char* const XRayInstrumentOption = "-fxray-instrument"; +switch(getToolChain().getArch()) { +case llvm::Triple::arm: +case llvm::Triple::x86_64: + break; +default: +{ + std::string Feature(XRayInstrumentOption); + Feature += " on "; + Feature += Triple.getArchName().data(); + D.Diag(diag::err_drv_clang_unsupported) << Feature; + break; +} } +CmdArgs.push_back(XRayInstrumentOption); if (const Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_, options::OPT_fxray_instruction_threshold_EQ)) { Index: test/Driver/xray-instrument.c === --- test/Driver/xray-instrument.c +++ test/Driver/xray-instrument.c @@ -0,0 +1,2 @@ +// RUN: %clang -fxray-instrument %s +// XFAIL: armeb,aarch64,aarch64_be,avr,bpfel,bpfeb,hexagon,mips,mipsel,mips64,mips64el,msp430,ppc,ppc64,ppc64le,r600,amdgcn,sparc,sparcv9,sparcel,systemz,tce,thumb,thumbeb,x86,xcore,nvptx,nvptx64,le32,le64,amdil,amdil64,hsail,hsail64,spir,spir64,kalimba,shave,lanai,wasm32,wasm64,renderscript32,renderscript64 Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4767,7 +4767,20 @@ if (Args.hasFlag(options::OPT_fxray_instrument, options::OPT_fnoxray_instrument, false)) { -CmdArgs.push_back("-fxray-instrument"); +const char* const XRayInstrumentOption = "-fxray-instrument"; +switch(getToolChain().getArch()) { +case llvm::Triple::arm: +case llvm::Triple::x86_64: + break; +default: +{ + std::string Feature(XRayInstrumentOption); + Feature += " on "; + Feature += Triple.getArchName().data(); + D.Diag(diag::err_drv_clang_unsupported) << Feature; + break; +} } +CmdArgs.push_back(XRayInstrumentOption); if (const Arg *A = Args.getLastArg(options::OPT_fxray_instruction_threshold_, options::OPT_fxray_instruction_threshold_EQ)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24820: Add -stats-file option
bruno added inline comments. Comment at: lib/Driver/Tools.cpp:6102 @@ +6101,3 @@ +StatsFile.assign(Output.getFilename()); +llvm::sys::path::remove_filename(StatsFile); + } Why removing StatsFile here? IIUC, at this point StatsFile is still the same as the output (if it's a file). Repository: rL LLVM https://reviews.llvm.org/D24820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
mehdi_amini added inline comments. Comment at: include/clang/Driver/Options.td:818 @@ -815,1 +817,3 @@ + HelpText<"Controls the backend parallelism of -flto=thin (default " + "of 0 means use std::thread::hardware_concurrency)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, `std::thread::hardware_concurrency` is a bit implementation specific, can we find a better formulation? Something like `(default of 0 means the number of thread will be derived from the number of CPUs detected)`? https://reviews.llvm.org/D24826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r282255 - Fix for r280064 that added options for fp denormals and exceptions.
On 23 September 2016 at 17:12, Sjoerd Meijerwrote: > I don't think I am committing at will: I thought it was okay to commit > directly because it is a simple fix (or should be) for my own previous > half-working patch, but I don't mind going through phab. A review would have caught many issues with this patch, for example, the no default issue, and the fact that it has no tests at all. As a rule of thumb, wait until you get several no-comments-LGTM reviews in a row in the same area to start committing small patches before review in that area. Just a few changes isn't enough. > I am indeed suspecting it is missing default case (probably got confused > because e.g. ThreadModel also doesn't have one, at least not there). Please, also do a build on ARM, and at least try to run check-all, as that will catch most bugs. And don't forget to add tests. cheers, --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24874: Fully implement the matcher for CXXCtorInitializer
aaron.ballman created this revision. aaron.ballman added reviewers: klimek, sbenza. aaron.ballman added a subscriber: cfe-commits. Herald added a subscriber: klimek. It turns out that our support for the `cxxCtorInitializer()` matcher was incomplete in that it could not be used as a top-level matcher because it was not derived from one of the blessed base class types. This patch completes the support for this AST matcher. https://reviews.llvm.org/D24874 Files: include/clang/ASTMatchers/ASTMatchFinder.h include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/ASTMatchFinder.cpp unittests/ASTMatchers/ASTMatchersNodeTest.cpp Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -528,6 +528,11 @@ EXPECT_TRUE(matches("class X {}; void x(int) { X x; }", Constructor)); } +TEST(Match, ConstructorInitializers) { + EXPECT_TRUE(matches("class C { int i; public: C(int ii) : i(ii) {} };", + cxxCtorInitializer(forField(hasName("i"); +} + TEST(Matcher, ThisExpr) { EXPECT_TRUE( matches("struct X { int a; int f () { return a; } };", cxxThisExpr())); Index: lib/ASTMatchers/ASTMatchFinder.cpp === --- lib/ASTMatchers/ASTMatchFinder.cpp +++ lib/ASTMatchers/ASTMatchFinder.cpp @@ -126,6 +126,8 @@ traverse(*Q); else if (const TypeLoc *T = DynNode.get()) traverse(*T); +else if (const auto *C = DynNode.get()) + traverse(*C); // FIXME: Add other base types after adding tests. // It's OK to always overwrite the bound nodes, as if there was @@ -194,6 +196,12 @@ return false; return traverse(NNS); } + bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit) { +if (!CtorInit) + return true; +ScopedIncrement ScopedDepth(); +return traverse(*CtorInit); + } bool shouldVisitTemplateInstantiations() const { return true; } bool shouldVisitImplicitCode() const { return true; } @@ -235,6 +243,10 @@ bool baseTraverse(NestedNameSpecifierLoc NNS) { return VisitorBase::TraverseNestedNameSpecifierLoc(NNS); } + bool baseTraverse(const CXXCtorInitializer ) { +return VisitorBase::TraverseConstructorInitializer( +const_cast()); + } // Sets 'Matched' to true if 'Matcher' matches 'Node' and: // 0 < CurrentDepth <= MaxDepth. @@ -371,6 +383,7 @@ bool TraverseTypeLoc(TypeLoc TypeNode); bool TraverseNestedNameSpecifier(NestedNameSpecifier *NNS); bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS); + bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit); // Matches children or descendants of 'Node' with 'BaseMatcher'. bool memoizedMatchesRecursively(const ast_type_traits::DynTypedNode , @@ -472,6 +485,8 @@ match(*N); } else if (auto *N = Node.get()) { match(*N); +} else if (auto *N = Node.get()) { + match(*N); } } @@ -593,6 +608,9 @@ void matchDispatch(const NestedNameSpecifierLoc *Node) { matchWithoutFilter(*Node, Matchers->NestedNameSpecifierLoc); } + void matchDispatch(const CXXCtorInitializer *Node) { +matchWithoutFilter(*Node, Matchers->CtorInit); + } void matchDispatch(const void *) { /* Do nothing. */ } /// @} @@ -864,6 +882,17 @@ RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(NNS); } +bool MatchASTVisitor::TraverseConstructorInitializer( +CXXCtorInitializer *CtorInit) { + if (!CtorInit) +return true; + + match(*CtorInit); + + return RecursiveASTVisitor::TraverseConstructorInitializer( + CtorInit); +} + class MatchASTConsumer : public ASTConsumer { public: MatchASTConsumer(MatchFinder *Finder, @@ -934,6 +963,12 @@ Matchers.AllCallbacks.insert(Action); } +void MatchFinder::addMatcher(const CXXCtorInitializerMatcher , + MatchCallback *Action) { + Matchers.CtorInit.emplace_back(NodeMatch, Action); + Matchers.AllCallbacks.insert(Action); +} + bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher , MatchCallback *Action) { if (NodeMatch.canConvertTo()) { @@ -954,6 +989,9 @@ } else if (NodeMatch.canConvertTo()) { addMatcher(NodeMatch.convertTo(), Action); return true; + } else if (NodeMatch.canConvertTo()) { +addMatcher(NodeMatch.convertTo(), Action); +return true; } return false; } Index: include/clang/ASTMatchers/ASTMatchFinder.h === --- include/clang/ASTMatchers/ASTMatchFinder.h +++ include/clang/ASTMatchers/ASTMatchFinder.h @@ -158,6 +158,8 @@ MatchCallback *Action); void addMatcher(const TypeLocMatcher , MatchCallback *Action); + void addMatcher(const CXXCtorInitializerMatcher , +
Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction
alexshap added a comment. Thanks, Chris has recently granted me commit access, i will rebase, rerun all the tests and then commit. Repository: rL LLVM https://reviews.llvm.org/D24792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24792: [analyzer] Fix crash in RetainCountChecker::checkEndFunction
zaks.anna added a comment. Thanks! @alexshap, Do yon have commit access or should we commit on your behalf? Repository: rL LLVM https://reviews.llvm.org/D24792 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
tejohnson added a comment. > > I do see other uses of -mllvm in lib/Driver/Tools.cpp, but are you talking > > about something else? > > I think this is okay, since clang is talking to the same version of > libLTO.dylib. I feel like there might be another case where > clang talks to libLTO.dylib through ld64 using -mllvm... perhaps, -O0? > > Let's ask around though to be sure. Ok, let me know what you find out. > > Ok good point. I can change this to -fthinlto_jobs. However, while the two > > parallel settings are separate in the LTO API, currently the gold-plugin > > jobs option controls both, so I will need to do a preparatory gold-plugin > > patch to split this into thinlto_jobs and lto_jobs. On the libLTO/ld64 > > path, looks like the current -mllvm -threads only affects ThinLTO so there > > is no work to do there. > > I actually like -flto-jobs=N better for this. I expect "jobs" not to affect > output at all. > > I think the current parallel FullLTO CodeGen (where it *does* affect output) > should have a special name that calls this out, perhaps -flto-partitions=N? > -flto-slices=N? -flto-random-partitions=N? Is it urgent to add that flag > now though? > > Note that I imagine someone will parallelizing FullLTO the hard way in the > future, which won't affect output. That implementation should use > -flto-jobs=N. Ok, sure that seems reasonable. I changed the option documentation to note that this is currently just for ThinLTO. See also https://reviews.llvm.org/D24873 where I split the gold-plugin options. https://reviews.llvm.org/D24826 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24826: [LTO] Add -flto-jobs=N to control backend parallelism
tejohnson updated this revision to Diff 72301. tejohnson added a comment. Update option description as per decision to split from parallel code gen. https://reviews.llvm.org/D24826 Files: include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/lto-jobs.c Index: test/Driver/lto-jobs.c === --- /dev/null +++ test/Driver/lto-jobs.c @@ -0,0 +1,11 @@ +// Confirm that -flto-jobs=N is passed to linker + +// RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS-ACTION: "-plugin-opt=jobs=5" + +// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin -flto-jobs=5 2> %t +// RUN: FileCheck -check-prefix=CHECK-LINK-THIN-JOBS2-ACTION < %t %s +// +// CHECK-LINK-THIN-JOBS2-ACTION: "-mllvm" "-threads=5" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1998,8 +1998,19 @@ } } +static unsigned getLTOParallelism(const ArgList , const Driver ) { + unsigned Parallelism = 0; + Arg *LtoJobsArg = Args.getLastArg(options::OPT_flto_jobs_EQ); + if (LtoJobsArg && + StringRef(LtoJobsArg->getValue()).getAsInteger(10, Parallelism)) +D.Diag(diag::err_drv_invalid_int_value) << LtoJobsArg->getAsString(Args) +<< LtoJobsArg->getValue(); + return Parallelism; +} + static void AddGoldPlugin(const ToolChain , const ArgList , - ArgStringList , bool IsThinLTO) { + ArgStringList , bool IsThinLTO, + const Driver ) { // Tell the linker to load the plugin. This has to come before AddLinkerInputs // as gold requires -plugin to come before any -plugin-opt that -Wl might // forward. @@ -2032,6 +2043,10 @@ if (IsThinLTO) CmdArgs.push_back("-plugin-opt=thinlto"); + if (unsigned Parallelism = getLTOParallelism(Args, D)) +CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=jobs=") + + std::to_string(Parallelism))); + // If an explicit debugger tuning argument appeared, pass it along. if (Arg *A = Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { @@ -7639,7 +7654,7 @@ options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -8060,6 +8075,13 @@ getMachOToolChain().addProfileRTLibs(Args, CmdArgs); + if (unsigned Parallelism = + getLTOParallelism(Args, getToolChain().getDriver())) { +CmdArgs.push_back("-mllvm"); +CmdArgs.push_back( +Args.MakeArgString(Twine("-threads=") + std::to_string(Parallelism))); + } + if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { if (getToolChain().getDriver().CCCIsCXX()) getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs); @@ -8790,7 +8812,7 @@ Args.AddAllArgs(CmdArgs, options::OPT_r); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); @@ -9623,7 +9645,7 @@ ToolChain.AddFilePathLibArgs(Args, CmdArgs); if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); +AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) CmdArgs.push_back("--no-demangle"); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -812,6 +812,10 @@ HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, HelpText<"Disable LTO mode (default)">; +def flto_jobs_EQ : Joined<["-"], "flto-jobs=">, + Flags<[CC1Option]>, Group, + HelpText<"Controls the backend parallelism of -flto=thin (default " + "of 0 means use std::thread::hardware_concurrency)">; def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">, Flags<[CC1Option]>, Group, HelpText<"Perform ThinLTO importing using provided function summary index">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24867: Request init/fini array on FreeBSD 12 and later
dim accepted this revision. dim added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D24867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r282255 - Fix for r280064 that added options for fp denormals and exceptions.
On 23 September 2016 at 16:21, Sjoerd Meijer via cfe-commitswrote: > Author: sjoerdmeijer > Date: Fri Sep 23 10:21:33 2016 > New Revision: 282255 > > URL: http://llvm.org/viewvc/llvm-project?rev=282255=rev > Log: > Fix for r280064 that added options for fp denormals and exceptions. > These options were forgotten to be copied in setCommandLineOpts. This broke: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12164 > + Options.FPDenormalType = > + > llvm::StringSwitch(CodeGenOpts.FPDenormalMode) > + .Case("ieee", llvm::FPDenormal::IEEE) > + .Case("preserve-sign", llvm::FPDenormal::PreserveSign) > + .Case("positive-zero", llvm::FPDenormal::PositiveZero); No Default case? > + Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath; This is not the same as the one above. Are you sure this patch is correct? Has this been reviewed at all? Please, don't commit patches at will when nothing is breaking, and put the patch for review next time. thanks, --renato ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24481: make “#pragma STDC FP_CONTRACT” on by default
This revision was automatically updated to reflect the committed changes. Closed by commit rL282259: set the underlying value of “#pragma STDC FP_CONTRACT” on by default (authored by spop). Changed prior to commit: https://reviews.llvm.org/D24481?vs=72186=72299#toc Repository: rL LLVM https://reviews.llvm.org/D24481 Files: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/aarch64-neon-fma.c cfe/trunk/test/CodeGen/aarch64-scalar-fma.c cfe/trunk/test/CodeGen/fp-contract-pragma.cpp cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c cfe/trunk/test/Driver/clang_f_opts.c Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -2445,6 +2445,12 @@ if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) { Res.getDiagnosticOpts().Warnings.push_back("spir-compat"); } + + if ((LangOpts.C11 || LangOpts.C99 || LangOpts.CPlusPlus) && + (CodeGenOptions::FPC_On == Res.getCodeGenOpts().getFPContractMode()) && + !LangOpts.CUDA) +LangOpts.DefaultFPContract = 1; + return Success; } Index: cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c === --- cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c +++ cfe/trunk/test/CodeGen/fp-contract-pragma___on-by-default.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple aarch64 -O0 -S -o - %s | FileCheck %s --check-prefix ALL_BUILDS +// RUN: %clang_cc1 -triple aarch64 -O1 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O2 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 +// RUN: %clang_cc1 -triple aarch64 -O3 -S -o - %s | FileCheck %s --check-prefixes ALL_BUILDS,NON_O0 + +// REQUIRES: aarch64-registered-target + +// ALL_BUILDS-LABEL: fmadd_double: +// ALL_BUILDS: fmadd d0, d{{[0-7]}}, d{{[0-7]}}, d{{[0-7]}} +// NON_O0-NEXT: ret +double fmadd_double(double a, double b, double c) { + return a*b+c; +} + +// ALL_BUILDS: fmadd_single: +// ALL_BUILDS: fmadd s0, s{{[0-7]}}, s{{[0-7]}}, s{{[0-7]}} +// NON_O0-NEXT: ret +float fmadd_single(float a, float b, float c) { + return a*b+c; +} + Index: cfe/trunk/test/CodeGen/aarch64-neon-fma.c === --- cfe/trunk/test/CodeGen/aarch64-neon-fma.c +++ cfe/trunk/test/CodeGen/aarch64-neon-fma.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s +// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -ffp-contract=off -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s // Test new aarch64 intrinsics and types Index: cfe/trunk/test/CodeGen/aarch64-scalar-fma.c === --- cfe/trunk/test/CodeGen/aarch64-scalar-fma.c +++ cfe/trunk/test/CodeGen/aarch64-scalar-fma.c @@ -0,0 +1,177 @@ +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=fast -S -o - %s | FileCheck -check-prefix=CHECK-FAST -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=on -S -o - %s | FileCheck -check-prefix=CHECK-ON -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -ffp-contract=off -S -o - %s | FileCheck -check-prefix=CHECK-OFF -check-prefix=CHECK-ALL %s +// RUN: %clang_cc1 -triple=aarch64-unknown -Os -S -o - %s | FileCheck -check-prefix=CHECK-ON -check-prefix=CHECK-ALL %s +// REQUIRES: aarch64-registered-target + +float test1(float x, float y, float z) { + return x*y + z; + // CHECK-ALL-LABEL: test1: + // CHECK-FAST: fmadd + // CHECK-ON: fmadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test2(double x, double y, double z) { + z -= x*y; + return z; + // CHECK-ALL-LABEL: test2: + // CHECK-FAST: fmsub + // CHECK-ON: fmsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +float test3(float x, float y, float z) { + float tmp = x*y; + return tmp + z; + // CHECK-ALL-LABEL: test3: + // CHECK-FAST: fmadd + // CHECK-ON: fmul + // CHECK-ON-NEXT: fadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test4(double x, double y, double z) { + double tmp = x*y; + return tmp - z; + // CHECK-ALL-LABEL: test4: + // CHECK-FAST: fnmsub + // CHECK-ON: fmul + // CHECK-ON-NEXT: fsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +#pragma STDC FP_CONTRACT ON + +float test5(float x, float y, float z) { + return x*y + z; + // CHECK-ALL-LABEL: test5: + // CHECK-FAST: fmadd + // CHECK-ON: fmadd + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fadd +} + +double test6(double x, double y, double z) { + z -= x*y; + return z; + // CHECK-ALL-LABEL: test6: + // CHECK-FAST: fmsub + // CHECK-ON: fmsub + // CHECK-OFF: fmul + // CHECK-OFF-NEXT: fsub +} + +float
RE: r282255 - Fix for r280064 that added options for fp denormals and exceptions.
Nothing was breaking, but it wasn't working either (because those options were not copied). I've reverted the patch directly after the first buildbot failure. I don't think I am committing at will: I thought it was okay to commit directly because it is a simple fix (or should be) for my own previous half-working patch, but I don't mind going through phab. I am indeed suspecting it is missing default case (probably got confused because e.g. ThreadModel also doesn't have one, at least not there). Cheers, Sjoerd. -Original Message- From: Renato Golin [mailto:renato.go...@linaro.org] Sent: 23 September 2016 17:00 To: Sjoerd Meijer Cc: Clang Commits Subject: Re: r282255 - Fix for r280064 that added options for fp denormals and exceptions. On 23 September 2016 at 16:21, Sjoerd Meijer via cfe-commitswrote: > Author: sjoerdmeijer > Date: Fri Sep 23 10:21:33 2016 > New Revision: 282255 > > URL: http://llvm.org/viewvc/llvm-project?rev=282255=rev > Log: > Fix for r280064 that added options for fp denormals and exceptions. > These options were forgotten to be copied in setCommandLineOpts. This broke: http://lab.llvm.org:8011/builders/clang-cmake-aarch64-42vma/builds/12164 > + Options.FPDenormalType = > + > llvm::StringSwitch(CodeGenOpts.FPDenormalMode) > + .Case("ieee", llvm::FPDenormal::IEEE) > + .Case("preserve-sign", llvm::FPDenormal::PreserveSign) > + .Case("positive-zero", llvm::FPDenormal::PositiveZero); No Default case? > + Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath; This is not the same as the one above. Are you sure this patch is correct? Has this been reviewed at all? Please, don't commit patches at will when nothing is breaking, and put the patch for review next time. thanks, --renato IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282257 - Revert of r282255 because of "Fell off the end of a string-switch" buildbot
Author: sjoerdmeijer Date: Fri Sep 23 10:37:17 2016 New Revision: 282257 URL: http://llvm.org/viewvc/llvm-project?rev=282257=rev Log: Revert of r282255 because of "Fell off the end of a string-switch" buildbot failures. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=282257=282256=282257=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 23 10:37:17 2016 @@ -537,12 +537,6 @@ void EmitAssemblyHelper::CreateTargetMac .Case("posix", llvm::ThreadModel::POSIX) .Case("single", llvm::ThreadModel::Single); - Options.FPDenormalType = - llvm::StringSwitch(CodeGenOpts.FPDenormalMode) - .Case("ieee", llvm::FPDenormal::IEEE) - .Case("preserve-sign", llvm::FPDenormal::PreserveSign) - .Case("positive-zero", llvm::FPDenormal::PositiveZero); - // Set float ABI type. assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" || CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) && @@ -585,7 +579,6 @@ void EmitAssemblyHelper::CreateTargetMac Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD; Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath; Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath; - Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath; Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS; Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath; Options.StackAlignmentOverride = CodeGenOpts.StackAlignment; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds
mgorny added a comment. For the record: I've tested the patch with and without zlib installed, using in-tree and stand-alone builds. https://reviews.llvm.org/D24869 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds
mgorny created this revision. mgorny added reviewers: rsmith, beanz, samsonov. mgorny added a subscriber: cfe-commits. Herald added subscribers: mgorny, beanz. Fix the test run to declare missing HAVE_LIBZ value in stand-alone builds, using the LLVM_ENABLE_ZLIB that is exported in LLVMConfig.cmake. When using in-tree builds, HAVE_LIBZ is declared in cmake/config-ix.cmake as a result of LLVM's CMake checks. When building stand-alone, this value is not available and as a result caused clang to wrongly assume that LLVM was built without zlib support. To fix it, set it to the value of LLVM_ENABLE_ZLIB. While this variable is originally used to control the user preference, LLVM updates its value to 0 if zlib checks fail. Therefore, we can use it to reliably determine whether LLVM was built with zlib support or not. https://reviews.llvm.org/D24869 Files: test/CMakeLists.txt Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -9,6 +9,15 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +if(CLANG_BUILT_STANDALONE) + # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This + # value is forced to 0 if zlib was not found, so it is fine to use it + # instead of HAVE_LIBZ (not recorded). + if(LLVM_ENABLE_ZLIB) +set(HAVE_LIBZ 1) + endif() +endif() + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg Index: test/CMakeLists.txt === --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -9,6 +9,15 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) +if(CLANG_BUILT_STANDALONE) + # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This + # value is forced to 0 if zlib was not found, so it is fine to use it + # instead of HAVE_LIBZ (not recorded). + if(LLVM_ENABLE_ZLIB) +set(HAVE_LIBZ 1) + endif() +endif() + configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282255 - Fix for r280064 that added options for fp denormals and exceptions.
Author: sjoerdmeijer Date: Fri Sep 23 10:21:33 2016 New Revision: 282255 URL: http://llvm.org/viewvc/llvm-project?rev=282255=rev Log: Fix for r280064 that added options for fp denormals and exceptions. These options were forgotten to be copied in setCommandLineOpts. Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=282255=282254=282255=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 23 10:21:33 2016 @@ -537,6 +537,12 @@ void EmitAssemblyHelper::CreateTargetMac .Case("posix", llvm::ThreadModel::POSIX) .Case("single", llvm::ThreadModel::Single); + Options.FPDenormalType = + llvm::StringSwitch(CodeGenOpts.FPDenormalMode) + .Case("ieee", llvm::FPDenormal::IEEE) + .Case("preserve-sign", llvm::FPDenormal::PreserveSign) + .Case("positive-zero", llvm::FPDenormal::PositiveZero); + // Set float ABI type. assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" || CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) && @@ -579,6 +585,7 @@ void EmitAssemblyHelper::CreateTargetMac Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD; Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath; Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath; + Options.NoTrappingFPMath = CodeGenOpts.NoTrappingMath; Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS; Options.UnsafeFPMath = CodeGenOpts.UnsafeFPMath; Options.StackAlignmentOverride = CodeGenOpts.StackAlignment; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282253 - [clang-format] support header deletion in cleanupAroundReplacemnts.
Author: ioeric Date: Fri Sep 23 10:10:56 2016 New Revision: 282253 URL: http://llvm.org/viewvc/llvm-project?rev=282253=rev Log: [clang-format] support header deletion in cleanupAroundReplacemnts. Summary: - If a replacement has offset UINT_MAX, length 0, and a replacement text that is an #include directive, this will insert the #include into the correct block in the \p Code. - If a replacement has offset UINT_MAX, length 1, and a replacement text that is the name of the header to be removed, the header will be removed from \p Code if it exists. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24829 Modified: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=282253=282252=282253=diff == --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Fri Sep 23 10:10:56 2016 @@ -783,8 +783,13 @@ formatReplacements(StringRef Code, const /// \brief Returns the replacements corresponding to applying \p Replaces and /// cleaning up the code after that on success; otherwise, return an llvm::Error /// carrying llvm::StringError. -/// This also inserts a C++ #include directive into the correct block if the -/// replacement corresponding to the header insertion has offset UINT_MAX. +/// This also supports inserting/deleting C++ #include directives: +/// - If a replacement has offset UINT_MAX, length 0, and a replacement text +/// that is an #include directive, this will insert the #include into the +/// correct block in the \p Code. +/// - If a replacement has offset UINT_MAX, length 1, and a replacement text +/// that is the name of the header to be removed, the header will be removed +/// from \p Code if it exists. llvm::Expected cleanupAroundReplacements(StringRef Code, const tooling::Replacements , const FormatStyle ); Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=282253=282252=282253=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Fri Sep 23 10:10:56 2016 @@ -1504,10 +1504,14 @@ formatReplacements(StringRef Code, const namespace { inline bool isHeaderInsertion(const tooling::Replacement ) { - return Replace.getOffset() == UINT_MAX && + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 0 && llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText()); } +inline bool isHeaderDeletion(const tooling::Replacement ) { + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; +} + void skipComments(Lexer , Token ) { while (Tok.is(tok::comment)) if (Lex.LexFromRawLexer(Tok)) @@ -1548,6 +1552,12 @@ unsigned getOffsetAfterHeaderGuardsAndCo return AfterComments; } +bool isDeletedHeader(llvm::StringRef HeaderName, + const std::set HeadersToDelete) { + return HeadersToDelete.find(HeaderName) != HeadersToDelete.end() || + HeadersToDelete.find(HeaderName.trim("\"<>")) != HeadersToDelete.end(); +} + // FIXME: we also need to insert a '\n' at the end of the code if we have an // insertion with offset Code.size(), and there is no '\n' at the end of the // code. @@ -1561,12 +1571,15 @@ fixCppIncludeInsertions(StringRef Code, return Replaces; tooling::Replacements HeaderInsertions; + std::set HeadersToDelete; tooling::Replacements Result; for (const auto : Replaces) { if (isHeaderInsertion(R)) { // Replacements from \p Replaces must be conflict-free already, so we can // simply consume the error. llvm::consumeError(HeaderInsertions.add(R)); +} else if (isHeaderDeletion(R)) { + HeadersToDelete.insert(R.getReplacementText()); } else if (R.getOffset() == UINT_MAX) { llvm::errs() << "Insertions other than header #include insertion are " "not supported! " @@ -1575,7 +1588,7 @@ fixCppIncludeInsertions(StringRef Code, llvm::consumeError(Result.add(R)); } } - if (HeaderInsertions.empty()) + if (HeaderInsertions.empty() && HeadersToDelete.empty()) return Replaces; llvm::Regex IncludeRegex(IncludeRegexPattern); @@ -1605,6 +1618,7 @@ fixCppIncludeInsertions(StringRef Code, for (auto Line : Lines) { NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1); if (IncludeRegex.match(Line, )) { + // The header name with quotes or angle brackets. StringRef IncludeName = Matches[2]; ExistingIncludes.insert(IncludeName); int Category = Categories.getIncludePriority( @@
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
ioeric updated this revision to Diff 72284. ioeric marked 3 inline comments as done. ioeric added a comment. - Addressed review comments. https://reviews.llvm.org/D24862 Files: change-namespace/ChangeNamespace.cpp unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -229,8 +229,23 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, DoNotCrashWithLambdaAsParameter) { + std::string Code = + "#include \n" + "void f(std::functionfunc, int param) { func(param); } " + "void g() { f([](int x) {}, 1); }"; + + std::string Expected = + "#include \n" + "void f(std::function func, int param) { func(param); } " + "void g() { f([](int x) {}, 1); }"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + TEST_F(ChangeNamespaceTest, FixUsingShadowDecl) { - std::string Code = "namespace na {\n" + std::string Code = "class GLOB {};\n" + "using BLOG = GLOB;\n" + "namespace na {\n" "namespace nc {\n" "class SAME {};\n" "}\n" @@ -245,7 +260,9 @@ "} // namespace nb\n" "} // namespace na\n"; - std::string Expected = "namespace na {\n" + std::string Expected = "class GLOB {};\n" + "using BLOG = GLOB;\n" + "namespace na {\n" "namespace nc {\n" "class SAME {};\n" "}\n" @@ -265,6 +282,85 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "namespace na {\n" + "namespace nb {\n" + "void f() {\n" + " using glob::Glob;\n" + " Glob g;\n" + "}\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is UsingShadowDecl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() {\n" + " using ::glob::Glob;\n" + " glob::Glob g;\n" + "}\n" + "} // namespace y\n" + "} // namespace x\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using glob::Glob;\n" + "namespace na {\n" + "namespace nb {\n" + "void f() { Glob g; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is UsingShadowDecl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using glob::Glob;\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() { glob::Glob g; }\n" + "} // namespace y\n" + "} // namespace x\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, UsingNamespace) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using namespace glob;\n" + "namespace na {\n" + "namespace nb {\n" + "void f() { Glob g; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is "using namespace" decl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using namespace glob;\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() { glob::Glob g; }\n" + "} // namespace y\n" + "}
Re: [PATCH] D24829: [clang-format] support header deletion in cleanupAroundReplacemnts.
This revision was automatically updated to reflect the committed changes. Closed by commit rL282253: [clang-format] support header deletion in cleanupAroundReplacemnts. (authored by ioeric). Changed prior to commit: https://reviews.llvm.org/D24829?vs=72285=72286#toc Repository: rL LLVM https://reviews.llvm.org/D24829 Files: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Index: cfe/trunk/lib/Format/Format.cpp === --- cfe/trunk/lib/Format/Format.cpp +++ cfe/trunk/lib/Format/Format.cpp @@ -1504,10 +1504,14 @@ namespace { inline bool isHeaderInsertion(const tooling::Replacement ) { - return Replace.getOffset() == UINT_MAX && + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 0 && llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText()); } +inline bool isHeaderDeletion(const tooling::Replacement ) { + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; +} + void skipComments(Lexer , Token ) { while (Tok.is(tok::comment)) if (Lex.LexFromRawLexer(Tok)) @@ -1548,6 +1552,12 @@ return AfterComments; } +bool isDeletedHeader(llvm::StringRef HeaderName, + const std::set HeadersToDelete) { + return HeadersToDelete.find(HeaderName) != HeadersToDelete.end() || + HeadersToDelete.find(HeaderName.trim("\"<>")) != HeadersToDelete.end(); +} + // FIXME: we also need to insert a '\n' at the end of the code if we have an // insertion with offset Code.size(), and there is no '\n' at the end of the // code. @@ -1561,21 +1571,24 @@ return Replaces; tooling::Replacements HeaderInsertions; + std::set HeadersToDelete; tooling::Replacements Result; for (const auto : Replaces) { if (isHeaderInsertion(R)) { // Replacements from \p Replaces must be conflict-free already, so we can // simply consume the error. llvm::consumeError(HeaderInsertions.add(R)); +} else if (isHeaderDeletion(R)) { + HeadersToDelete.insert(R.getReplacementText()); } else if (R.getOffset() == UINT_MAX) { llvm::errs() << "Insertions other than header #include insertion are " "not supported! " << R.getReplacementText() << "\n"; } else { llvm::consumeError(Result.add(R)); } } - if (HeaderInsertions.empty()) + if (HeaderInsertions.empty() && HeadersToDelete.empty()) return Replaces; llvm::Regex IncludeRegex(IncludeRegexPattern); @@ -1605,13 +1618,27 @@ for (auto Line : Lines) { NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1); if (IncludeRegex.match(Line, )) { + // The header name with quotes or angle brackets. StringRef IncludeName = Matches[2]; ExistingIncludes.insert(IncludeName); int Category = Categories.getIncludePriority( IncludeName, /*CheckMainHeader=*/FirstIncludeOffset < 0); CategoryEndOffsets[Category] = NextLineOffset; if (FirstIncludeOffset < 0) FirstIncludeOffset = Offset; + if (isDeletedHeader(IncludeName, HeadersToDelete)) { +// If this is the last line without trailing newline, we need to make +// sure we don't delete across the file boundary. +unsigned Length = std::min(Line.size() + 1, Code.size() - Offset); +llvm::Error Err = +Result.add(tooling::Replacement(FileName, Offset, Length, "")); +if (Err) { + // Ignore the deletion on conflict. + llvm::errs() << "Failed to add header deletion replacement for " + << IncludeName << ": " << llvm::toString(std::move(Err)) + << "\n"; +} + } } Offset = NextLineOffset; } Index: cfe/trunk/unittests/Format/CleanupTest.cpp === --- cfe/trunk/unittests/Format/CleanupTest.cpp +++ cfe/trunk/unittests/Format/CleanupTest.cpp @@ -247,8 +247,12 @@ return tooling::Replacement(FileName, Offset, Length, Text); } - tooling::Replacement createInsertion(StringRef HeaderName) { -return createReplacement(UINT_MAX, 0, HeaderName); + tooling::Replacement createInsertion(StringRef IncludeDirective) { +return createReplacement(UINT_MAX, 0, IncludeDirective); + } + + tooling::Replacement createDeletion(StringRef HeaderName) { +return createReplacement(UINT_MAX, 1, HeaderName); } inline std::string apply(StringRef Code, @@ -740,6 +744,57 @@ EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, SimpleDeleteIncludes) { + std::string Code = "#include \"abc.h\"\n" + "#include \"xyz.h\" // comment\n" + "#include \"xyz\"\n" + "int x;\n"; + std::string Expected = "#include \"xyz\"\n" + "int x;\n"; +
Re: [PATCH] D24829: [clang-format] support header deletion in cleanupAroundReplacemnts.
ioeric updated this revision to Diff 72285. ioeric marked 2 inline comments as done. ioeric added a comment. - Addressed comments. https://reviews.llvm.org/D24829 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -247,8 +247,12 @@ return tooling::Replacement(FileName, Offset, Length, Text); } - tooling::Replacement createInsertion(StringRef HeaderName) { -return createReplacement(UINT_MAX, 0, HeaderName); + tooling::Replacement createInsertion(StringRef IncludeDirective) { +return createReplacement(UINT_MAX, 0, IncludeDirective); + } + + tooling::Replacement createDeletion(StringRef HeaderName) { +return createReplacement(UINT_MAX, 1, HeaderName); } inline std::string apply(StringRef Code, @@ -740,6 +744,57 @@ EXPECT_EQ(Expected, apply(Code, Replaces)); } +TEST_F(CleanUpReplacementsTest, SimpleDeleteIncludes) { + std::string Code = "#include \"abc.h\"\n" + "#include \"xyz.h\" // comment\n" + "#include \"xyz\"\n" + "int x;\n"; + std::string Expected = "#include \"xyz\"\n" + "int x;\n"; + tooling::Replacements Replaces = + toReplacements({createDeletion("abc.h"), createDeletion("xyz.h")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, DeleteAllCode) { + std::string Code = "#include \"xyz.h\"\n" + "#include "; + std::string Expected = ""; + tooling::Replacements Replaces = toReplacements({createDeletion("xyz.h")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, DeleteAllIncludesWithSameNameIfNoType) { + std::string Code = "#include \"xyz.h\"\n" + "#include \"xyz\"\n" + "#include \n"; + std::string Expected = "#include \"xyz\"\n"; + tooling::Replacements Replaces = toReplacements({createDeletion("xyz.h")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, OnlyDeleteHeaderWithType) { + std::string Code = "#include \"xyz.h\"\n" + "#include \"xyz\"\n" + "#include "; + std::string Expected = "#include \"xyz.h\"\n" + "#include \"xyz\"\n"; + tooling::Replacements Replaces = toReplacements({createDeletion("")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertionAndDeleteHeader) { + std::string Code = "#include \"a.h\"\n" + "\n" + "#include \n"; + std::string Expected = "#include \"a.h\"\n" + "\n" + "#include \n"; + tooling::Replacements Replaces = toReplacements( + {createDeletion(""), createInsertion("#include ")}); + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1504,10 +1504,14 @@ namespace { inline bool isHeaderInsertion(const tooling::Replacement ) { - return Replace.getOffset() == UINT_MAX && + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 0 && llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText()); } +inline bool isHeaderDeletion(const tooling::Replacement ) { + return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1; +} + void skipComments(Lexer , Token ) { while (Tok.is(tok::comment)) if (Lex.LexFromRawLexer(Tok)) @@ -1548,6 +1552,12 @@ return AfterComments; } +bool isDeletedHeader(llvm::StringRef HeaderName, + const std::set HeadersToDelete) { + return HeadersToDelete.find(HeaderName) != HeadersToDelete.end() || + HeadersToDelete.find(HeaderName.trim("\"<>")) != HeadersToDelete.end(); +} + // FIXME: we also need to insert a '\n' at the end of the code if we have an // insertion with offset Code.size(), and there is no '\n' at the end of the // code. @@ -1561,21 +1571,24 @@ return Replaces; tooling::Replacements HeaderInsertions; + std::set HeadersToDelete; tooling::Replacements Result; for (const auto : Replaces) { if (isHeaderInsertion(R)) { // Replacements from \p Replaces must be conflict-free already, so we can // simply consume the error. llvm::consumeError(HeaderInsertions.add(R)); +} else if (isHeaderDeletion(R)) { + HeadersToDelete.insert(R.getReplacementText()); } else if (R.getOffset() == UINT_MAX) { llvm::errs() << "Insertions other than header #include insertion are " "not supported! " << R.getReplacementText()
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
ioeric added a comment. Thanks for the comments! Comment at: change-namespace/ChangeNamespace.cpp:279 @@ -276,2 +278,3 @@ Finder->addMatcher( - usingDecl(hasAnyUsingShadowDecl(IsInMovedNs)).bind("using_decl"), this); + usingDecl(IsInMovedNs, hasAnyUsingShadowDecl(decl())).bind("using_decl"), + this); aaron.ballman wrote: > Why is this change an improvement even after the underlying bug is fixed? I think `IsInMovedNs` makes more sense to be a filter for using decl, and it is also more restrictive than `hasAnyUsingShadowDecl`, which would make the failure matching stop earlier IMO. Comment at: change-namespace/ChangeNamespace.cpp:296 @@ -291,5 +295,3 @@ // definitions, so we need to exclude them in the callback handler. - auto FuncMatcher = functionDecl( - hasParent(namespaceDecl()), - unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous())), - hasAncestor(cxxRecordDecl(); + // NOTE: ASTMatcher crash when `FunctionDecl` is a lambda defined in parameter + // list, in which case it has no parent map. Workaround by filtering out aaron.ballman wrote: > Comment is fine, but it should be reworded once the underlying bug is fixed, > which makes me wonder if the comment is really adding value. Might make more > sense to not talk in terms of the crash, but just why you need to filter this > way. Fair enough. I think I'll just get rid of the comment regarding crash and let the unittest handle it. Comment at: change-namespace/tool/ClangChangeNamespace.cpp:73 @@ -71,2 +72,3 @@ int main(int argc, const char **argv) { + sys::PrintStackTraceOnErrorSignal(argv[0]); tooling::CommonOptionsParser OptionsParser(argc, argv, aaron.ballman wrote: > I don't think these changes are necessary as part of this patch. Removed. https://reviews.llvm.org/D24862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24867: Request init/fini array on FreeBSD 12 and later
emaste created this revision. emaste added reviewers: dim, brooks. emaste added a subscriber: cfe-commits. Herald added a subscriber: emaste. It seems a bad idea to change the default in the middle of a release branch due to possible changes in global ctor / dtor ordering between .ctors and .init_array. With FreeBSD 11.0's release imminent lets change the default now for FreeBSD 12 (the current development stream) and later. FreeBSD rtld has supported .init_array / .fini_array for many years. As of Jan 1 2017 all supported FreeBSD releases and branches will have support. https://reviews.llvm.org/D24867 Files: lib/Driver/ToolChains.cpp test/Driver/constructors.c Index: test/Driver/constructors.c === --- test/Driver/constructors.c +++ test/Driver/constructors.c @@ -74,3 +74,11 @@ // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ // RUN: -target arm64-none-none-eabi \ // RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-freebsd11 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-freebsd12 \ +// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -2829,6 +2829,8 @@ bool UseInitArrayDefault = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be || + (getTriple().getOS() == llvm::Triple::FreeBSD && + getTriple().getOSMajorVersion() >= 12) || (getTriple().getOS() == llvm::Triple::Linux && (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) || getTriple().getOS() == llvm::Triple::NaCl || Index: test/Driver/constructors.c === --- test/Driver/constructors.c +++ test/Driver/constructors.c @@ -74,3 +74,11 @@ // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ // RUN: -target arm64-none-none-eabi \ // RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-freebsd11 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-freebsd12 \ +// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s Index: lib/Driver/ToolChains.cpp === --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -2829,6 +2829,8 @@ bool UseInitArrayDefault = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be || + (getTriple().getOS() == llvm::Triple::FreeBSD && + getTriple().getOSMajorVersion() >= 12) || (getTriple().getOS() == llvm::Triple::Linux && (!V.isOlderThan(4, 7, 0) || getTriple().isAndroid())) || getTriple().getOS() == llvm::Triple::NaCl || ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
aaron.ballman added a comment. In https://reviews.llvm.org/D24862#550665, @ioeric wrote: > Sorry for the confusion. I guess I should've been clearer in the comments and > patch summary... The changes would've been what we wanted even without the > underlying bugs and would not be reverted after the bugs are fixed. Ah, thank you for clarifying! Now it makes more sense to me. :-) Actual review comments are inline. Comment at: change-namespace/ChangeNamespace.cpp:279 @@ -276,2 +278,3 @@ Finder->addMatcher( - usingDecl(hasAnyUsingShadowDecl(IsInMovedNs)).bind("using_decl"), this); + usingDecl(IsInMovedNs, hasAnyUsingShadowDecl(decl())).bind("using_decl"), + this); Why is this change an improvement even after the underlying bug is fixed? Comment at: change-namespace/ChangeNamespace.cpp:296 @@ -291,5 +295,3 @@ // definitions, so we need to exclude them in the callback handler. - auto FuncMatcher = functionDecl( - hasParent(namespaceDecl()), - unless(anyOf(IsInMovedNs, hasAncestor(namespaceDecl(isAnonymous())), - hasAncestor(cxxRecordDecl(); + // NOTE: ASTMatcher crash when `FunctionDecl` is a lambda defined in parameter + // list, in which case it has no parent map. Workaround by filtering out Comment is fine, but it should be reworded once the underlying bug is fixed, which makes me wonder if the comment is really adding value. Might make more sense to not talk in terms of the crash, but just why you need to filter this way. Comment at: change-namespace/tool/ClangChangeNamespace.cpp:73 @@ -71,2 +72,3 @@ int main(int argc, const char **argv) { + sys::PrintStackTraceOnErrorSignal(argv[0]); tooling::CommonOptionsParser OptionsParser(argc, argv, I don't think these changes are necessary as part of this patch. Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:325 @@ +324,3 @@ + + // FIXME: don't add namespace qualifier when there is UsingShadowDecl. + std::string Expected = "namespace glob {\n" May want to duplicate this FIXME to where we are generating the change? Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:350 @@ +349,3 @@ + + // FIXME: don't add namespace qualifier when there is "using namespace" decl. + std::string Expected = "namespace glob {\n" Same here as above. https://reviews.llvm.org/D24862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
ioeric added a comment. In https://reviews.llvm.org/D24862#550654, @aaron.ballman wrote: > In https://reviews.llvm.org/D24862#550646, @ioeric wrote: > > > Acked, and I totally agree with you :) It's just that the change in this > > patch would still be valid after the underlying bugs are fixed, so I > > thought it was fine to fix those bugs after this. > > > I might be confused then (this happens from time to time) -- are the changes > in this patch still necessary after the underlying bugs are fixed? Sorry for the confusion. I guess I should've been clearer in the comments and patch summary... The changes would've been what we wanted even without the underlying bugs and would not be reverted after the bugs are fixed. https://reviews.llvm.org/D24862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
This revision was automatically updated to reflect the committed changes. Closed by commit rL282252: [OpenCL] Augment pipe built-ins with pipe packet size and alignment. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23992?vs=70366=72276#toc Repository: rL LLVM https://reviews.llvm.org/D23992 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -4,59 +4,59 @@ // CHECK: %opencl.reserve_id_t = type opaque void test1(read_only pipe int p, global int *ptr) { - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_read_pipe(p, 2); - // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_read_pipe(p, rid); } void test2(write_only pipe int p, global int *ptr) { - // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_write_pipe(p, 2); - // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_write_pipe(p, rid); } void test3(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_read_pipe(p, 2); - // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_read_pipe(p, rid); } void test4(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_write_pipe(p, 2); - // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_write_pipe(p, rid); } void test5(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = sub_group_reserve_read_pipe(p, 2); - // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) sub_group_commit_read_pipe(p, rid); } void test6(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t*
r282252 - [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
Author: bader Date: Fri Sep 23 09:20:00 2016 New Revision: 282252 URL: http://llvm.org/viewvc/llvm-project?rev=282252=rev Log: [OpenCL] Augment pipe built-ins with pipe packet size and alignment. Reviewers: Anastasia, vpykhtin Subscribers: dmitry, cfe-commits Differential Revision: https://reviews.llvm.org/D23992 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=282252=282251=282252=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 23 09:20:00 2016 @@ -14,6 +14,7 @@ #include "CodeGenFunction.h" #include "CGCXXABI.h" #include "CGObjCRuntime.h" +#include "CGOpenCLRuntime.h" #include "CodeGenModule.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" @@ -2139,6 +2140,9 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BIwrite_pipe: { Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); +CGOpenCLRuntime OpenCLRT(CGM); +Value *PacketSize = OpenCLRT.getPipeElemSize(E->getArg(0)); +Value *PacketAlign = OpenCLRT.getPipeElemAlign(E->getArg(0)); // Type of the generic packet parameter. unsigned GenericAS = @@ -2152,19 +2156,21 @@ RValue CodeGenFunction::EmitBuiltinExpr( : "__write_pipe_2"; // Creating a generic function type to be able to call with any builtin or // user defined type. - llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy}; + llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( Int32Ty, llvm::ArrayRef(ArgTys), false); Value *BCast = Builder.CreatePointerCast(Arg1, I8PTy); - return RValue::get(Builder.CreateCall( - CGM.CreateRuntimeFunction(FTy, Name), {Arg0, BCast})); + return RValue::get( + Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, BCast, PacketSize, PacketAlign})); } else { assert(4 == E->getNumArgs() && "Illegal number of parameters to pipe function"); const char *Name = (BuiltinID == Builtin::BIread_pipe) ? "__read_pipe_4" : "__write_pipe_4"; - llvm::Type *ArgTys[] = {Arg0->getType(), Arg1->getType(), Int32Ty, I8PTy}; + llvm::Type *ArgTys[] = {Arg0->getType(), Arg1->getType(), Int32Ty, I8PTy, + Int32Ty, Int32Ty}; Value *Arg2 = EmitScalarExpr(E->getArg(2)), *Arg3 = EmitScalarExpr(E->getArg(3)); llvm::FunctionType *FTy = llvm::FunctionType::get( @@ -2175,7 +2181,8 @@ RValue CodeGenFunction::EmitBuiltinExpr( if (Arg2->getType() != Int32Ty) Arg2 = Builder.CreateZExtOrTrunc(Arg2, Int32Ty); return RValue::get(Builder.CreateCall( - CGM.CreateRuntimeFunction(FTy, Name), {Arg0, Arg1, Arg2, BCast})); + CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, Arg1, Arg2, BCast, PacketSize, PacketAlign})); } } // OpenCL v2.0 s6.13.16 ,s9.17.3.5 - Built-in pipe reserve read and write @@ -2204,9 +2211,12 @@ RValue CodeGenFunction::EmitBuiltinExpr( Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); llvm::Type *ReservedIDTy = ConvertType(getContext().OCLReserveIDTy); +CGOpenCLRuntime OpenCLRT(CGM); +Value *PacketSize = OpenCLRT.getPipeElemSize(E->getArg(0)); +Value *PacketAlign = OpenCLRT.getPipeElemAlign(E->getArg(0)); // Building the generic function prototype. -llvm::Type *ArgTys[] = {Arg0->getType(), Int32Ty}; +llvm::Type *ArgTys[] = {Arg0->getType(), Int32Ty, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( ReservedIDTy, llvm::ArrayRef(ArgTys), false); // We know the second argument is an integer type, but we may need to cast @@ -2214,7 +2224,8 @@ RValue CodeGenFunction::EmitBuiltinExpr( if (Arg1->getType() != Int32Ty) Arg1 = Builder.CreateZExtOrTrunc(Arg1, Int32Ty); return RValue::get( -Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), {Arg0, Arg1})); +Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, Arg1, PacketSize, PacketAlign})); } // OpenCL v2.0 s6.13.16, s9.17.3.5 - Built-in pipe commit read and write // functions @@ -2240,15 +2251,19 @@ RValue CodeGenFunction::EmitBuiltinExpr( Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); +
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
ioeric updated this revision to Diff 72275. ioeric added a comment. - Update comment. https://reviews.llvm.org/D24862 Files: change-namespace/ChangeNamespace.cpp change-namespace/tool/ClangChangeNamespace.cpp unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -229,8 +229,23 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, DoNotCrashWithLambdaAsParameter) { + std::string Code = + "#include \n" + "void f(std::functionfunc, int param) { func(param); } " + "void g() { f([](int x) {}, 1); }"; + + std::string Expected = + "#include \n" + "void f(std::function func, int param) { func(param); } " + "void g() { f([](int x) {}, 1); }"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + TEST_F(ChangeNamespaceTest, FixUsingShadowDecl) { - std::string Code = "namespace na {\n" + std::string Code = "class GLOB {};\n" + "using BLOG = GLOB;\n" + "namespace na {\n" "namespace nc {\n" "class SAME {};\n" "}\n" @@ -245,7 +260,9 @@ "} // namespace nb\n" "} // namespace na\n"; - std::string Expected = "namespace na {\n" + std::string Expected = "class GLOB {};\n" + "using BLOG = GLOB;\n" + "namespace na {\n" "namespace nc {\n" "class SAME {};\n" "}\n" @@ -265,6 +282,85 @@ EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } +TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "namespace na {\n" + "namespace nb {\n" + "void f() {\n" + " using glob::Glob;\n" + " Glob g;\n" + "}\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is UsingShadowDecl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() {\n" + " using ::glob::Glob;\n" + " glob::Glob g;\n" + "}\n" + "} // namespace y\n" + "} // namespace x\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using glob::Glob;\n" + "namespace na {\n" + "namespace nb {\n" + "void f() { Glob g; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is UsingShadowDecl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using glob::Glob;\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() { glob::Glob g; }\n" + "} // namespace y\n" + "} // namespace x\n"; + EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); +} + +TEST_F(ChangeNamespaceTest, UsingNamespace) { + std::string Code = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using namespace glob;\n" + "namespace na {\n" + "namespace nb {\n" + "void f() { Glob g; }\n" + "} // namespace nb\n" + "} // namespace na\n"; + + // FIXME: don't add namespace qualifier when there is "using namespace" decl. + std::string Expected = "namespace glob {\n" + "class Glob {};\n" + "}\n" + "using namespace glob;\n" + "\n" + "namespace x {\n" + "namespace y {\n" + "void f() { glob::Glob g; }\n" + "} // namespace y\n" + "} //
[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API
rmaprath created this revision. rmaprath added reviewers: EricWF, mclow.lists, jroelofs, compnerd. rmaprath added a subscriber: cfe-commits. This is simply a cleanup of D18482 (patch taken with permission) while adapting it to match what we have already implemented for libcxx. Note that I haven't included the external-threading stuff yet, this is only refactoring pthread usage of libcxxabi. A follow-up patch will add the external-threading support. https://reviews.llvm.org/D24864 Files: include/__cxxabi_config.h src/config.h src/cxa_exception.cpp src/cxa_exception_storage.cpp src/cxa_guard.cpp src/fallback_malloc.ipp src/threading_support.h test/test_fallback_malloc.pass.cpp Index: test/test_fallback_malloc.pass.cpp === --- test/test_fallback_malloc.pass.cpp +++ test/test_fallback_malloc.pass.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include "../src/threading_support.h" typedef std::deque container; Index: src/threading_support.h === --- /dev/null +++ src/threading_support.h @@ -0,0 +1,82 @@ +//=== threading_support.h -===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +#ifndef _LIBCXXABI_THREADING_SUPPORT_H +#define _LIBCXXABI_THREADING_SUPPORT_H + +#include "__cxxabi_config.h" +#include "config.h" + +#ifndef _LIBCXXABI_HAS_NO_THREADS + +#if defined(_LIBCXXABI_HAS_THREAD_API_PTHREAD) +#include + +#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY + +// Mutex +typedef pthread_mutex_t __libcxxabi_mutex_t; +#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) { + return pthread_mutex_lock(mutex); +} + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) { + return pthread_mutex_unlock(mutex); +} + +// Condition variable +typedef pthread_cond_t __libcxxabi_condvar_t; +#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv, + __libcxxabi_mutex_t *mutex) { + return pthread_cond_wait(cv, mutex); +} + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) { + return pthread_cond_broadcast(cv); +} + +// Execute once +typedef pthread_once_t __libcxxabi_exec_once_flag; +#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag, + void (*init_routine)(void)) { + return pthread_once(flag, init_routine); +} + +// TLS +typedef pthread_key_t __libcxxabi_tls_key; + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_tls_create(__libcxxabi_tls_key *key, + void (*destructor)(void *)) { + return pthread_key_create(key, destructor); +} + +_LIBCXXABI_THREAD_ABI_VISIBILITY +void *__libcxxabi_tls_get(__libcxxabi_tls_key key) { + return pthread_getspecific(key); +} + +_LIBCXXABI_THREAD_ABI_VISIBILITY +int __libcxxabi_tls_set(__libcxxabi_tls_key key, void *value) { + return pthread_setspecific(key, value); +} +#endif // _LIBCXXABI_HAS_THREAD_API_PTHREAD +#endif // !_LIBCXXABI_HAS_NO_THREADS +#endif // _LIBCXXABI_THREADING_SUPPORT_H Index: src/fallback_malloc.ipp === --- src/fallback_malloc.ipp +++ src/fallback_malloc.ipp @@ -27,25 +27,25 @@ // When POSIX threads are not available, make the mutex operations a nop #ifndef _LIBCXXABI_HAS_NO_THREADS -static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER; +static __libcxxabi_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER; #else static void * heap_mutex = 0; #endif class mutexor { public: #ifndef _LIBCXXABI_HAS_NO_THREADS -mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); } -~mutexor () { pthread_mutex_unlock ( mtx_ ); } +mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); } +~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); } #else mutexor ( void * ) {} ~mutexor () {} #endif private: mutexor ( const mutexor ); mutexor & operator = ( const mutexor ); #ifndef _LIBCXXABI_HAS_NO_THREADS -pthread_mutex_t *mtx_; +__libcxxabi_mutex_t *mtx_; #endif }; Index: src/cxa_guard.cpp === --- src/cxa_guard.cpp +++ src/cxa_guard.cpp @@ -11,20 +11,18 @@ #include "abort_message.h" #include "config.h"
Re: [PATCH] D24759: [RFC][StaticAnalyser] fix unreachable code false positives when block numbers mismatch
dcoughlin requested changes to this revision. dcoughlin added a reviewer: dcoughlin. This revision now requires changes to proceed. Comment at: lib/Analysis/CFG.cpp:2986 @@ -2985,3 +2985,1 @@ -if (!KnownVal.isFalse()) { - // Add an intermediate block between the BodyBlock and the You need to keep this check so that the optimized CFG still removes edges that are trivially known to be false. Comment at: lib/Analysis/CFG.cpp:2994 @@ -2993,3 @@ - Succ = BodyBlock; - CFGBlock *LoopBackBlock = createBlock(); - LoopBackBlock->setLoopTarget(D); To keep the unoptimized and optimized blocks in sync, this block creation needs to be done regardless of whether the branch condition is known to be false. My advice would be to hoist the creation (and the FIXME comments) to above the check for whether KnownVal is false. https://reviews.llvm.org/D24759 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24862: Workaround ASTMatcher crashes. Added some more test cases.
aaron.ballman added a comment. In https://reviews.llvm.org/D24862#550646, @ioeric wrote: > Acked, and I totally agree with you :) It's just that the change in this > patch would still be valid after the underlying bugs are fixed, so I thought > it was fine to fix those bugs after this. I might be confused then (this happens from time to time) -- are the changes in this patch still necessary after the underlying bugs are fixed? https://reviews.llvm.org/D24862 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits