[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target
AndreiGrischenko added a comment. In https://reviews.llvm.org/D32543#738595, @ahatanak wrote: > Do you need a front-end test? Since the changes are in the backend, I think > it's better to add the test to the backend (using llc). Yes, changes are in the backend, but they fix interface between frontend and backend, that's why I need to check option -fuse-init-array using front-end. Using llc I cannot check these changes. https://reviews.llvm.org/D32543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32410: change the way the expr evaluator handles objcboxedexpr
rsmith added inline comments. Comment at: lib/AST/ExprConstant.cpp:4469-4470 { return StmtVisitorTy::Visit(E->getSubExpr()); } + bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E) +{ return StmtVisitorTy::Visit(E->getSubExpr()); } bool VisitChooseExpr(const ChooseExpr *E) I believe this is unreachable: an `ObjCBoxedExpr` will always have pointer (or dependent) type; the former will be handled below and the latter should never be evaluated at all. (We might want a mode to recurse into non-dependent subexpressions of value-dependent expressions, but that should probably be a separate visitor.) Comment at: lib/AST/ExprConstant.cpp:5487 + } + +case EvalInfo::EM_ConstantExpression: Add `LLVM_FALLTHROUGH;` here, please. Comment at: lib/AST/ExprConstant.cpp:5492 +case EvalInfo::EM_OffsetFold: + return Success(E); +} As far as I can see, this (from the pre-existing code) is very wrong: the evaluation semantics of `ObjCBoxedExpr` are to evaluate the subexpression and then pass that to a certain Objective-C method to box the result. We can't just skip evaluating the subexpression! We miscompile this, for instance: ``` @interface NSNumber + (id)numberWithInt:(int)n; @end int n; int m = (@(n++), 0); ``` ... completely losing the increment of `n` because we incorrectly return `Success` here without evaluating the subexpression. Plus returning `Success` here seems like it's never likely to be useful, since CGExprConstant can't actually emit an `APValue` of this form. As a minimal fix that would still let us perform this weird evaluation, we could unconditionally call `EvaluateIgnoredValue` here prior to returning `Success(E)`. https://reviews.llvm.org/D32410 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32405: Expr evaluator may want to continue into ArraySubscriptExpr if evaluation mode indicates
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D32405 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301520 - In the expression evaluator, descend into both the true and false expressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we shou
Author: nicholas Date: Thu Apr 27 02:11:09 2017 New Revision: 301520 URL: http://llvm.org/viewvc/llvm-project?rev=301520&view=rev Log: In the expression evaluator, descend into both the true and false expressions of a ConditionalOperator when the condition can't be evaluated and we're in an evaluation mode that says we should continue evaluating. Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/Sema/integer-overflow.c Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=301520&r1=301519&r2=301520&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr 27 02:11:09 2017 @@ -4418,8 +4418,14 @@ private: bool HandleConditionalOperator(const ConditionalOperator *E) { bool BoolResult; if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info)) { - if (Info.checkingPotentialConstantExpression() && Info.noteFailure()) + if (Info.checkingPotentialConstantExpression() && Info.noteFailure()) { CheckPotentialConstantConditional(E); +return false; + } + if (Info.noteFailure()) { +StmtVisitorTy::Visit(E->getTrueExpr()); +StmtVisitorTy::Visit(E->getFalseExpr()); + } return false; } Modified: cfe/trunk/test/Sema/integer-overflow.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=301520&r1=301519&r2=301520&view=diff == --- cfe/trunk/test/Sema/integer-overflow.c (original) +++ cfe/trunk/test/Sema/integer-overflow.c Thu Apr 27 02:11:09 2017 @@ -148,6 +148,9 @@ uint64_t check_integer_overflows(int i) a[4608 * 1024 * 1024] = 1i; // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} + (void)((i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024)) + 1); + +// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32566: Revert rL301328 and add tests for the regressions introduced.
rsmith added a comment. I'm OK with this from a mechanical perspective. But there's also a libclang design question here: what should the libclang methods to query template arguments for a type cursor representing an alias template specialization actually do? Should there be some way for a libclang user to choose what result they get? One way we could make the behavior fully consistent (and more backwards-compatible with pre-clang-4.0) would be to revert both this and https://reviews.llvm.org/D26663, and provide the information that https://reviews.llvm.org/D26663 wanted to expose by another set of interface functions. What do other people with an interest in the libclang interface think? Repository: rL LLVM https://reviews.llvm.org/D32566 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301522 - In the expression evaluator, visit the index of an ArraySubscriptExpr even if we can't evaluate the base, if the evaluation mode tells us to continue evaluation.
Author: nicholas Date: Thu Apr 27 02:27:36 2017 New Revision: 301522 URL: http://llvm.org/viewvc/llvm-project?rev=301522&view=rev Log: In the expression evaluator, visit the index of an ArraySubscriptExpr even if we can't evaluate the base, if the evaluation mode tells us to continue evaluation. Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/Sema/integer-overflow.c Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=301522&r1=301521&r2=301522&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Apr 27 02:27:36 2017 @@ -5246,14 +5246,19 @@ bool LValueExprEvaluator::VisitArraySubs if (E->getBase()->getType()->isVectorType()) return Error(E); - if (!evaluatePointer(E->getBase(), Result)) -return false; + bool Success = true; + if (!evaluatePointer(E->getBase(), Result)) { +if (!Info.noteFailure()) + return false; +Success = false; + } APSInt Index; if (!EvaluateInteger(E->getIdx(), Index, Info)) return false; - return HandleLValueArrayAdjustment(Info, E, Result, E->getType(), Index); + return Success && + HandleLValueArrayAdjustment(Info, E, Result, E->getType(), Index); } bool LValueExprEvaluator::VisitUnaryDeref(const UnaryOperator *E) { Modified: cfe/trunk/test/Sema/integer-overflow.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=301522&r1=301521&r2=301522&view=diff == --- cfe/trunk/test/Sema/integer-overflow.c (original) +++ cfe/trunk/test/Sema/integer-overflow.c Thu Apr 27 02:27:36 2017 @@ -147,6 +147,10 @@ uint64_t check_integer_overflows(int i) uint64_t a[10]; a[4608 * 1024 * 1024] = 1i; +// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}} + uint64_t *b; + uint64_t b2 = b[4608 * 1024 * 1024] + 1; + // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} (void)((i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024)) + 1); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301525 - Don't hard-code "modules-cache-path" in the test.
Author: hokein Date: Thu Apr 27 04:20:46 2017 New Revision: 301525 URL: http://llvm.org/viewvc/llvm-project?rev=301525&view=rev Log: Don't hard-code "modules-cache-path" in the test. Modified: cfe/trunk/test/Modules/malformed-overload.m Modified: cfe/trunk/test/Modules/malformed-overload.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/malformed-overload.m?rev=301525&r1=301524&r2=301525&view=diff == --- cfe/trunk/test/Modules/malformed-overload.m (original) +++ cfe/trunk/test/Modules/malformed-overload.m Thu Apr 27 04:20:46 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules -fimplicit-module-maps -fmodules-cache-path=tmp -verify %s +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify %s NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}} #import "X.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301526 - Constify SourceManager input to MacroInfo::getDefinitionLengthSlow, NFC.
Author: yrnkrn Date: Thu Apr 27 04:56:39 2017 New Revision: 301526 URL: http://llvm.org/viewvc/llvm-project?rev=301526&view=rev Log: Constify SourceManager input to MacroInfo::getDefinitionLengthSlow, NFC. Modified: cfe/trunk/include/clang/Lex/MacroInfo.h cfe/trunk/lib/Lex/MacroInfo.cpp Modified: cfe/trunk/include/clang/Lex/MacroInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=301526&r1=301525&r2=301526&view=diff == --- cfe/trunk/include/clang/Lex/MacroInfo.h (original) +++ cfe/trunk/include/clang/Lex/MacroInfo.h Thu Apr 27 04:56:39 2017 @@ -126,7 +126,7 @@ public: SourceLocation getDefinitionEndLoc() const { return EndLocation; } /// \brief Get length in characters of the macro definition. - unsigned getDefinitionLength(SourceManager &SM) const { + unsigned getDefinitionLength(const SourceManager &SM) const { if (IsDefinitionLengthCached) return DefinitionLength; return getDefinitionLengthSlow(SM); @@ -285,7 +285,7 @@ public: void dump() const; private: - unsigned getDefinitionLengthSlow(SourceManager &SM) const; + unsigned getDefinitionLengthSlow(const SourceManager &SM) const; void setOwningModuleID(unsigned ID) { assert(isFromASTFile()); Modified: cfe/trunk/lib/Lex/MacroInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroInfo.cpp?rev=301526&r1=301525&r2=301526&view=diff == --- cfe/trunk/lib/Lex/MacroInfo.cpp (original) +++ cfe/trunk/lib/Lex/MacroInfo.cpp Thu Apr 27 04:56:39 2017 @@ -33,7 +33,7 @@ MacroInfo::MacroInfo(SourceLocation DefL UsedForHeaderGuard(false) { } -unsigned MacroInfo::getDefinitionLengthSlow(SourceManager &SM) const { +unsigned MacroInfo::getDefinitionLengthSlow(const SourceManager &SM) const { assert(!IsDefinitionLengthCached); IsDefinitionLengthCached = true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32486: Cleanup pragma handlers after DoPrintPreprocessedInput
yaron.keren added a comment. Raphael , do you have commit access? should I commit this? https://reviews.llvm.org/D32486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301532 - [ObjC] Disallow vector parameters and return values in Objective-C methods
Author: arphaman Date: Thu Apr 27 05:43:48 2017 New Revision: 301532 URL: http://llvm.org/viewvc/llvm-project?rev=301532&view=rev Log: [ObjC] Disallow vector parameters and return values in Objective-C methods for iOS < 9 and OS X < 10.11 X86 targets This commit adds a new error that disallows methods that have parameters/return values with a vector type for some older X86 targets. This diagnostic is needed because objc_msgSend doesn't support SIMD vector registers/return values on X86 in iOS < 9 and OS X < 10.11. Note that we don't necessarily know if the vector argument/return value will use a SIMD register, so instead we chose to be conservative and prohibit all vector types. rdar://21662309 Differential Revision: https://reviews.llvm.org/D28670 Added: cfe/trunk/test/SemaObjC/x86-method-vector-values.m Modified: cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/AST/DeclBase.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/include/clang/AST/DeclBase.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=301532&r1=301531&r2=301532&view=diff == --- cfe/trunk/include/clang/AST/DeclBase.h (original) +++ cfe/trunk/include/clang/AST/DeclBase.h Thu Apr 27 05:43:48 2017 @@ -616,6 +616,14 @@ public: getAvailability(std::string *Message = nullptr, VersionTuple EnclosingVersion = VersionTuple()) const; + /// \brief Retrieve the version of the target platform in which this + /// declaration was introduced. + /// + /// \returns An empty version tuple if this declaration has no 'introduced' + /// availability attributes, or the version tuple that's specified in the + /// attribute otherwise. + VersionTuple getVersionIntroduced() const; + /// \brief Determine whether this declaration is marked 'deprecated'. /// /// \param Message If non-NULL and the declaration is deprecated, Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=301532&r1=301531&r2=301532&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 27 05:43:48 2017 @@ -1180,6 +1180,10 @@ def err_objc_kindof_nonobject : Error< def err_objc_kindof_wrong_position : Error< "'__kindof' type specifier must precede the declarator">; +def err_objc_method_unsupported_param_ret_type : Error< + "%0 %select{parameter|return}1 type is unsupported; " + "support for vector types for this target is introduced in %2">; + // C++ declarations def err_static_assert_expression_is_not_constant : Error< "static_assert expression is not an integral constant expression">; Modified: cfe/trunk/lib/AST/DeclBase.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=301532&r1=301531&r2=301532&view=diff == --- cfe/trunk/lib/AST/DeclBase.cpp (original) +++ cfe/trunk/lib/AST/DeclBase.cpp Thu Apr 27 05:43:48 2017 @@ -415,6 +415,19 @@ const Attr *Decl::getDefiningAttr() cons return nullptr; } +StringRef getRealizedPlatform(const AvailabilityAttr *A, + const ASTContext &Context) { + // Check if this is an App Extension "platform", and if so chop off + // the suffix for matching with the actual platform. + StringRef RealizedPlatform = A->getPlatform()->getName(); + if (!Context.getLangOpts().AppExt) +return RealizedPlatform; + size_t suffix = RealizedPlatform.rfind("_app_extension"); + if (suffix != StringRef::npos) +return RealizedPlatform.slice(0, suffix); + return RealizedPlatform; +} + /// \brief Determine the availability of the given declaration based on /// the target platform. /// @@ -434,20 +447,11 @@ static AvailabilityResult CheckAvailabil if (EnclosingVersion.empty()) return AR_Available; - // Check if this is an App Extension "platform", and if so chop off - // the suffix for matching with the actual platform. StringRef ActualPlatform = A->getPlatform()->getName(); - StringRef RealizedPlatform = ActualPlatform; - if (Context.getLangOpts().AppExt) { -size_t suffix = RealizedPlatform.rfind("_app_extension"); -if (suffix != StringRef::npos) - RealizedPlatform = RealizedPlatform.slice(0, suffix); - } - StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); // Match the platform name. - if (RealizedPlatform != TargetPlatform) + if (getRealizedPlatform(A, Context) != TargetPlatform) return AR_Available; StringRef PrettyPlatformName @@ -567,6 +571,20 @@ AvailabilityResult Decl::getAvailability return Result; } +VersionTuple Decl::getVersionInt
[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets
This revision was automatically updated to reflect the committed changes. Closed by commit rL301532: [ObjC] Disallow vector parameters and return values in Objective-C methods (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D28670?vs=95099&id=96892#toc Repository: rL LLVM https://reviews.llvm.org/D28670 Files: cfe/trunk/include/clang/AST/DeclBase.h cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/AST/DeclBase.cpp cfe/trunk/lib/Sema/SemaDeclObjC.cpp cfe/trunk/test/SemaObjC/x86-method-vector-values.m Index: cfe/trunk/lib/Sema/SemaDeclObjC.cpp === --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp @@ -4313,6 +4313,51 @@ } } +/// Verify that the method parameters/return value have types that are supported +/// by the x86 target. +static void checkObjCMethodX86VectorTypes(Sema &SemaRef, + const ObjCMethodDecl *Method) { + assert(SemaRef.getASTContext().getTargetInfo().getTriple().getArch() == + llvm::Triple::x86 && + "x86-specific check invoked for a different target"); + SourceLocation Loc; + QualType T; + for (const ParmVarDecl *P : Method->parameters()) { +if (P->getType()->isVectorType()) { + Loc = P->getLocStart(); + T = P->getType(); + break; +} + } + if (Loc.isInvalid()) { +if (Method->getReturnType()->isVectorType()) { + Loc = Method->getReturnTypeSourceRange().getBegin(); + T = Method->getReturnType(); +} else + return; + } + + // Vector parameters/return values are not supported by objc_msgSend on x86 in + // iOS < 9 and macOS < 10.11. + const auto &Triple = SemaRef.getASTContext().getTargetInfo().getTriple(); + VersionTuple AcceptedInVersion; + if (Triple.getOS() == llvm::Triple::IOS) +AcceptedInVersion = VersionTuple(/*Major=*/9); + else if (Triple.isMacOSX()) +AcceptedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/11); + else +return; + VersionTuple MethodVersion = Method->getVersionIntroduced(); + if (SemaRef.getASTContext().getTargetInfo().getPlatformMinVersion() >= + AcceptedInVersion && + (MethodVersion.empty() || MethodVersion >= AcceptedInVersion)) +return; + SemaRef.Diag(Loc, diag::err_objc_method_unsupported_param_ret_type) + << T << (Method->getReturnType()->isVectorType() ? /*return value*/ 1 + : /*parameter*/ 0) + << (Triple.isMacOSX() ? "macOS 10.11" : "iOS 9"); +} + Decl *Sema::ActOnMethodDeclaration( Scope *S, SourceLocation MethodLoc, SourceLocation EndLoc, @@ -4534,6 +4579,10 @@ ObjCMethod->SetRelatedResultType(); } + if (MethodDefinition && + Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) +checkObjCMethodX86VectorTypes(*this, ObjCMethod); + ActOnDocumentableDecl(ObjCMethod); return ObjCMethod; Index: cfe/trunk/lib/AST/DeclBase.cpp === --- cfe/trunk/lib/AST/DeclBase.cpp +++ cfe/trunk/lib/AST/DeclBase.cpp @@ -415,6 +415,19 @@ return nullptr; } +StringRef getRealizedPlatform(const AvailabilityAttr *A, + const ASTContext &Context) { + // Check if this is an App Extension "platform", and if so chop off + // the suffix for matching with the actual platform. + StringRef RealizedPlatform = A->getPlatform()->getName(); + if (!Context.getLangOpts().AppExt) +return RealizedPlatform; + size_t suffix = RealizedPlatform.rfind("_app_extension"); + if (suffix != StringRef::npos) +return RealizedPlatform.slice(0, suffix); + return RealizedPlatform; +} + /// \brief Determine the availability of the given declaration based on /// the target platform. /// @@ -434,20 +447,11 @@ if (EnclosingVersion.empty()) return AR_Available; - // Check if this is an App Extension "platform", and if so chop off - // the suffix for matching with the actual platform. StringRef ActualPlatform = A->getPlatform()->getName(); - StringRef RealizedPlatform = ActualPlatform; - if (Context.getLangOpts().AppExt) { -size_t suffix = RealizedPlatform.rfind("_app_extension"); -if (suffix != StringRef::npos) - RealizedPlatform = RealizedPlatform.slice(0, suffix); - } - StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); // Match the platform name. - if (RealizedPlatform != TargetPlatform) + if (getRealizedPlatform(A, Context) != TargetPlatform) return AR_Available; StringRef PrettyPlatformName @@ -567,6 +571,20 @@ return Result; } +VersionTuple Decl::getVersionIntroduced() const { + const ASTContext &Context = getASTContext(); + StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); + for (const auto *A : attrs()) { +if (const auto *Availability = dyn_cast(A)) { + if (getRealizedPl
[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0
Prazek added a comment. In https://reviews.llvm.org/D32401#738513, @rjmccall wrote: > In https://reviews.llvm.org/D32401#735127, @Prazek wrote: > > > In https://reviews.llvm.org/D32401#734921, @rjmccall wrote: > > > > > I continue to be really uncomfortable with the entire design of this > > > optimization, which appears to miscompile code by default, but as long as > > > nobody's suggesting that we actually turn it on by default, I guess it > > > can be your little research-compiler playground. It might be better to > > > downgrade it to a -cc1 option, though. > > > > > > This specific change is fine by me. > > > > > > Can you tell me a little more about what part of the design you dislike? Is > > it about missing optimizations by introducing the barriers, cost of > > inserting the barriers or the fact that we have to be cautious to not break > > anything? > > > The latter. The optimization design seems to rely on anticipating every case > that should disable the optimization, hence this patch adding special-case > logic to the frontend, and the 3 other patches you've got out for review > adding special-case logic to different parts of the frontend, all on top of a > ton of special-case logic in yet more parts of the frontend from when you > implemented the optimization in the first place. There is an additive > problem here where suddenly the design of this specific optimizaton becomes > an affirmative burden to basically all the code in the frontend and, > presumably, the middle-end and beyond, as opposed to just defaulting to > correct behavior. There is zero chance that this latest collection of > changes is actually fixing all of the problems; it's just papering over the > next round of testing. > > I'm very sympathetic, because I know this is an important optimization, but > it's not clear to me that it's actually reasonable to implement in LLVM. > > John. We will probably not gonna make it in the first time, but the issues I am solving are known almost from the beginning - we knew that there is an issue with comparing pointers, and the idea of putting barriers for comparision was showed on last summer. Adding barriers for pointer casts is the consequence of that - either we will add barriers for comparisions of all pointers , or only to the ones having any vptrs + add barriers when we loose the dynamic information. The issues with linking is also known, I just solve some small details that we missed :) I hope I will be able to show some statistics soon on how devirtualization is doing to show that it is worth the cost :) https://reviews.llvm.org/D32401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32395: [clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls
kuhar added a comment. I run clang-tidy with this version of modernize-use-emplace on the whole llvm + clang + clang tools extra tree and it emitted ~500 fixits, ~100 of them were make_pair ones. The whole codebase compiled fine and there were no new test failures with check-all. https://reviews.llvm.org/D32395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32486: Cleanup pragma handlers after DoPrintPreprocessedInput
v.g.vassilev added a comment. Yaron, I can take care of this. Thanks for asking. Raphael and I are working together. https://reviews.llvm.org/D32486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32486: Cleanup pragma handlers after DoPrintPreprocessedInput
yaron.keren added a comment. OK https://reviews.llvm.org/D32486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301535 - [X86] Support of no_caller_saved_registers attribute
Author: orenb Date: Thu Apr 27 07:01:00 2017 New Revision: 301535 URL: http://llvm.org/viewvc/llvm-project?rev=301535&view=rev Log: [X86] Support of no_caller_saved_registers attribute Implements the Clang part for no_caller_saved_registers attribute as appears here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be. Differential Revision: https://reviews.llvm.org/D31871 Added: cfe/trunk/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp cfe/trunk/test/SemaCXX/attr-non-x86-no_caller_saved_registers.cpp cfe/trunk/test/SemaCXX/attr-x86-no_caller_saved_registers.cpp Modified: cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/TypePrinter.cpp cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=301535&r1=301534&r2=301535&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu Apr 27 07:01:00 2017 @@ -1396,7 +1396,7 @@ protected: /// Extra information which affects how the function is called, like /// regparm and the calling convention. -unsigned ExtInfo : 10; +unsigned ExtInfo : 11; /// Used only by FunctionProtoType, put here to pack with the /// other bitfields. @@ -2941,19 +2941,23 @@ class FunctionType : public Type { // * AST read and write // * Codegen class ExtInfo { -// Feel free to rearrange or add bits, but if you go over 10, +// Feel free to rearrange or add bits, but if you go over 11, // you'll need to adjust both the Bits field below and // Type::FunctionTypeBitfields. -// | CC |noreturn|produces|regparm| -// |0 .. 4| 5|6 | 7 .. 9| +// | CC |noreturn|produces|nocallersavedregs|regparm| +// |0 .. 4| 5|6 | 7 |8 .. 10| // // regparm is either 0 (no regparm attribute) or the regparm value+1. enum { CallConvMask = 0x1F }; enum { NoReturnMask = 0x20 }; enum { ProducesResultMask = 0x40 }; -enum { RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask), - RegParmOffset = 7 }; // Assumed to be the last field +enum { NoCallerSavedRegsMask = 0x80 }; +enum { + RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask | + NoCallerSavedRegsMask), + RegParmOffset = 8 +}; // Assumed to be the last field uint16_t Bits; @@ -2964,13 +2968,13 @@ class FunctionType : public Type { public: // Constructor with no defaults. Use this when you know that you // have all the elements (when reading an AST file for example). -ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc, -bool producesResult) { - assert((!hasRegParm || regParm < 7) && "Invalid regparm value"); - Bits = ((unsigned) cc) | - (noReturn ? NoReturnMask : 0) | - (producesResult ? ProducesResultMask : 0) | - (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0); + ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc, + bool producesResult, bool noCallerSavedRegs) { + assert((!hasRegParm || regParm < 7) && "Invalid regparm value"); + Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) | + (producesResult ? ProducesResultMask : 0) | + (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) | + (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0); } // Constructor with all defaults. Use when for example creating a @@ -2983,6 +2987,7 @@ class FunctionType : public Type { bool getNoReturn() const { return Bits & NoReturnMask; } bool getProducesResult() const { return Bits & ProducesResultMask; } +bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; } bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; } unsigned getRegParm() const { unsigned RegParm = Bits >> RegParmOffset; @@ -3016,6 +3021,13 @@ class FunctionType : public Type { return ExtInfo(Bits & ~ProducesResultMask); } +ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const { + if (noCallerSavedRegs) +return ExtInfo(Bits | NoCallerSavedRegsMask); + else +return ExtInfo(Bits & ~NoCallerSavedRegsMask); +} +
[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width
danielmarjamaki added inline comments. Comment at: lib/StaticAnalyzer/Core/CheckerHelpers.cpp:116 +return false; + ConstraintManager &CM = State->getConstraintManager(); + ProgramStateRef StTrue, StFalse; xazax.hun wrote: > Any reason why do you get the constraint manager and not using > ProgramState::assume? Mostly that it's just 1 call instead of 2. assumeDual() has some extra logic (early return , assertion). are there some special reason to use assume()? Repository: rL LLVM https://reviews.llvm.org/D30295 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301536 - Fix asan failures on OpenMP.
Author: hokein Date: Thu Apr 27 07:22:33 2017 New Revision: 301536 URL: http://llvm.org/viewvc/llvm-project?rev=301536&view=rev Log: Fix asan failures on OpenMP. Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301536&r1=301535&r2=301536&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 27 07:22:33 2017 @@ -833,6 +833,8 @@ DSAStackTy::hasDSA(ValueDecl *D, auto I = std::prev(StartI); do { ++I; +if (I == EndI) + break; if (!DPred(I->Directive) && !isParallelOrTaskRegion(I->Directive)) continue; DSAVarData DVar = getDSA(I, D); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r301410 - [OPENMP] Move handling of threadprivate vars from the stack, NFC.
Hi Ahmed, thanks for the info. Will fix it ASAP. Best regards, Alexey Bataev 26 апр. 2017 г., в 22:00, Ahmed Bougacha mailto:ahmed.bouga...@gmail.com>> написал(а): Hey Alexey, This is causing asan errors, e.g.: ==4735==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61f00e70 at pc 0x00010a8a7f4a bp 0x7fff5c57a390 sp 0x7fff5c57a388 READ of size 4 at 0x61f00e70 thread T0 #0 0x10a8a7f49 in (anonymous namespace)::DSAStackTy::hasDSA(clang::ValueDecl*, llvm::function_ref const&, llvm::function_ref const&, bool) SemaOpenMP.cpp:836 #1 0x10a8a4560 in clang::Sema::IsOpenMPCapturedDecl(clang::ValueDecl*) SemaOpenMP.cpp:1107 #2 0x10a575739 in clang::Sema::tryCaptureVariable(clang::VarDecl*, clang::SourceLocation, clang::Sema::TryCaptureKind, clang::SourceLocation, bool, clang::QualType&, clang::QualType&, unsigned int const*) SemaExpr.cpp:14005 ... 0x61f00e70 is located 16 bytes to the left of 3440-byte region [0x61f00e80,0x61f01bf0) allocated by thread T0 here: #0 0x116f036d2 in wrap__Znwm (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x656d2) #1 0x10a8a1642 in clang::Sema::InitDataSharingAttributesStack() SemaOpenMP.cpp:914 #2 0x109fc8585 in clang::Sema::Sema(clang::Preprocessor&, clang::ASTContext&, clang::ASTConsumer&, clang::TranslationUnitKind, clang::CodeCompleteConsumer*) Sema.cpp:125 ... SUMMARY: AddressSanitizer: heap-buffer-overflow SemaOpenMP.cpp:836 in (anonymous namespace)::DSAStackTy::hasDSA(clang::ValueDecl*, llvm::function_ref const&, llvm::function_ref const&, bool) http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_check/3344/testReport/junit/Clang/OpenMP/atomic_codegen_cpp/ Can you have a look? Thanks! -Ahmed On Wed, Apr 26, 2017 at 7:24 AM, Alexey Bataev via cfe-commits mailto:cfe-commits@lists.llvm.org>> wrote: > Author: abataev > Date: Wed Apr 26 09:24:21 2017 > New Revision: 301410 > > URL: http://llvm.org/viewvc/llvm-project?rev=301410&view=rev > Log: > [OPENMP] Move handling of threadprivate vars from the stack, NFC. > > Threadprivate variables do no need to be handled in the Stack of all > directives, moving it out for better performance and memory. > > Modified: > cfe/trunk/lib/Sema/SemaOpenMP.cpp > > Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301410&r1=301409&r2=301410&view=diff > == > --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) > +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 26 09:24:21 2017 > @@ -118,6 +118,7 @@ private: >typedef SmallVector StackTy; > >/// \brief Stack of used declaration and their data-sharing attributes. > + DeclSAMapTy Threadprivates; >StackTy Stack; >/// \brief true, if check for DSA must be from parent directive, false, if >/// from current directive. > @@ -134,7 +135,7 @@ private: >bool isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter); > > public: > - explicit DSAStackTy(Sema &S) : Stack(1), SemaRef(S) {} > + explicit DSAStackTy(Sema &S) : SemaRef(S) {} > >bool isClauseParsingMode() const { return ClauseKindMode != OMPC_unknown; } >void setClauseParsingMode(OpenMPClauseKind K) { ClauseKindMode = K; } > @@ -149,7 +150,7 @@ public: >} > >void pop() { > -assert(Stack.size() > 1 && "Data-sharing attributes stack is empty!"); > +assert(!Stack.empty() && "Data-sharing attributes stack is empty!"); > Stack.pop_back(); >} > > @@ -229,11 +230,11 @@ public: > >/// \brief Returns currently analyzed directive. >OpenMPDirectiveKind getCurrentDirective() const { > -return Stack.back().Directive; > +return Stack.empty() ? OMPD_unknown : Stack.back().Directive; >} >/// \brief Returns parent directive. >OpenMPDirectiveKind getParentDirective() const { > -if (Stack.size() > 2) > +if (Stack.size() > 1) >return Stack[Stack.size() - 2].Directive; > return OMPD_unknown; >} > @@ -250,10 +251,10 @@ public: >} > >DefaultDataSharingAttributes getDefaultDSA() const { > -return Stack.back().DefaultAttr; > +return Stack.empty() ? DSA_unspecified : Stack.back().DefaultAttr; >} >SourceLocation getDefaultDSALocation() const { > -return Stack.back().DefaultAttrLoc; > +return Stack.empty() ? SourceLocation() : Stack.back().DefaultAttrLoc; >} > >/// \brief Checks if the specified variable is a threadprivate. > @@ -270,13 +271,13 @@ public: >/// \brief Returns true, if parent region is ordered (has associated >/// 'ordered' clause), false - otherwise. >bool isParentOrderedRegion() const { > -if (Stack.size() > 2) > +if (Stack.size() > 1) >return Stack[Stack.size() - 2].OrderedRegion.getInt(); > return false; >} >/// \brief Returns optional parameter for the ordered region. >Expr *getParentOrderedRegionParam() const { > -if (Stack.s
[PATCH] D32590: clang-format: [JS] parse async function declarations.
mprobst created this revision. Herald added a subscriber: klimek. Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrapped line for async functions, causing subsequent functions to run into the function: async function f() { x(); } function g() { ... With this change, async functions get parsed as top level function declarations and get their own unwrapped line context. https://reviews.llvm.org/D32590 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); verifyFormat("export async function f() {\n" " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is( + Keywords.kw_async { tryToParseJSFunction(); break; } Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); verifyFormat("export async function f() {\n" " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Sty
[PATCH] D32590: clang-format: [JS] parse async function declarations.
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good. Comment at: lib/Format/UnwrappedLineParser.cpp:1043 - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. function Nit: I'd start this and the next sentence upper case. https://reviews.llvm.org/D32590 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32590: clang-format: [JS] parse async function declarations.
mprobst updated this revision to Diff 96908. mprobst added a comment. - capitalization https://reviews.llvm.org/D32590 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); verifyFormat("export async function f() {\n" " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // Function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. Function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is( + Keywords.kw_async { tryToParseJSFunction(); break; } Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); verifyFormat("export async function f() {\n" " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // Function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. Function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().T
r301538 - clang-format: [JS] parse async function declarations.
Author: mprobst Date: Thu Apr 27 08:07:24 2017 New Revision: 301538 URL: http://llvm.org/viewvc/llvm-project?rev=301538&view=rev Log: clang-format: [JS] parse async function declarations. Summary: Previously, clang-format would accidentally parse an async function declaration as a function expression, and thus not insert an unwrapped line for async functions, causing subsequent functions to run into the function: async function f() { x(); } function g() { ... With this change, async functions get parsed as top level function declarations and get their own unwrapped line context. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32590 Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=301538&r1=301537&r2=301538&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Apr 27 08:07:24 2017 @@ -1040,13 +1040,15 @@ void UnwrappedLineParser::parseStructura return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // Function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. Function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is( + Keywords.kw_async { tryToParseJSFunction(); break; } Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=301538&r1=301537&r2=301538&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Apr 27 08:07:24 2017 @@ -485,6 +485,20 @@ TEST_F(FormatTestJS, AsyncFunctions) { " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); @@ -492,6 +506,9 @@ TEST_F(FormatTestJS, AsyncFunctions) { " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32590: clang-format: [JS] parse async function declarations.
This revision was automatically updated to reflect the committed changes. Closed by commit rL301538: clang-format: [JS] parse async function declarations. (authored by mprobst). Changed prior to commit: https://reviews.llvm.org/D32590?vs=96908&id=96909#toc Repository: rL LLVM https://reviews.llvm.org/D32590 Files: cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // Function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. Function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is( + Keywords.kw_async { tryToParseJSFunction(); break; } Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" + "} \n"); verifyFormat("async function* f() {\n" " yield fetch(x);\n" "}"); verifyFormat("export async function f() {\n" " return fetch(x);\n" "}"); verifyFormat("let x = async () => f();"); + verifyFormat("let x = async function() {\n" + " f();\n" + "};"); verifyFormat("let x = async();"); verifyFormat("class X {\n" " async asyncMethod() {\n" Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp === --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp @@ -1040,13 +1040,15 @@ return; } - // Parse function literal unless 'function' is the first token in a line - // in which case this should be treated as a free-standing function. + // Function declarations (as opposed to function expressions) are parsed + // on their own unwrapped line by continuing this loop. Function + // expressions (functions that are not on their own line) must not create + // a new unwrapped line, so they are special cased below. + size_t TokenCount = Line->Tokens.size(); if (Style.Language == FormatStyle::LK_JavaScript && - (FormatTok->is(Keywords.kw_function) || - FormatTok->startsSequence(Keywords.kw_async, - Keywords.kw_function)) && - Line->Tokens.size() > 0) { + FormatTok->is(Keywords.kw_function) && + (TokenCount > 1 || (TokenCount == 1 && !Line->Tokens.front().Tok->is( + Keywords.kw_async { tryToParseJSFunction(); break; } Index: cfe/trunk/unittests/Format/FormatTestJS.cpp === --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -485,13 +485,30 @@ " let x = 1;\n" " return fetch(x);\n" "}"); + verifyFormat("async function f() {\n" + " return 1;\n" + "}\n" + "\n" + "function a() {\n" + " return 1;\n" + "}\n", + " async function f() {\n" + " return 1;\n" + "}\n" + "\n" + " function a() {\n" + " return 1;\n" +
r301539 - clang/test/Modules/malformed-overload.m: Make sure module cache is clean.
Author: chapuni Date: Thu Apr 27 08:08:48 2017 New Revision: 301539 URL: http://llvm.org/viewvc/llvm-project?rev=301539&view=rev Log: clang/test/Modules/malformed-overload.m: Make sure module cache is clean. Modified: cfe/trunk/test/Modules/malformed-overload.m Modified: cfe/trunk/test/Modules/malformed-overload.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/malformed-overload.m?rev=301539&r1=301538&r2=301539&view=diff == --- cfe/trunk/test/Modules/malformed-overload.m (original) +++ cfe/trunk/test/Modules/malformed-overload.m Thu Apr 27 08:08:48 2017 @@ -1,3 +1,4 @@ +// RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify %s NSLog(@"%@", path); // expected-error {{expected parameter declarator}} expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-warning {{incompatible redeclaration}} expected-note {{to match this '('}} expected-note {{'NSLog' is a builtin with type}} #import "X.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32566: Revert rL301328 and add tests for the regressions introduced.
emilio added a comment. I'm personally fine with this behavior in particular, given you can check the cursor you're querying to know if it's a typedef or alias specialization. Of course I'm not the only one using libclang, though, so I'd be interested in hearing other people's opinion. I think that we should try to prevent this _third_ different behavior to stay in tree in the meantime, though, what do you think? Repository: rL LLVM https://reviews.llvm.org/D32566 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32592: [Analyzer] Iterator Checker - Part1: Minimal Checker for a Simple Test Case
baloghadamsoftware created this revision. Herald added a subscriber: mgorny. This is the first part of the new Iterator Checker. This part contains the very core infrastructure. It only checks for out-of-range iterators in a very simple case. https://reviews.llvm.org/D32592 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp test/Analysis/Inputs/system-header-simulator-cxx.h test/Analysis/diagnostics/explicit-suppression.cpp test/Analysis/iterator-past-end.cpp Index: test/Analysis/iterator-past-end.cpp === --- test/Analysis/iterator-past-end.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify -// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify - -#include "Inputs/system-header-simulator-cxx.h" - -void simple_good(const std::vector &v) { - auto i = v.end(); - if (i != v.end()) -*i; // no-warning -} - -void simple_good_negated(const std::vector &v) { - auto i = v.end(); - if (!(i == v.end())) -*i; // no-warning -} - -void simple_bad(const std::vector &v) { - auto i = v.end(); - *i; // expected-warning{{Iterator accessed past its end}} -} - -void copy(const std::vector &v) { - auto i1 = v.end(); - auto i2 = i1; - *i2; // expected-warning{{Iterator accessed past its end}} -} - -void decrease(const std::vector &v) { - auto i = v.end(); - --i; - *i; // no-warning -} - -void copy_and_decrease1(const std::vector &v) { - auto i1 = v.end(); - auto i2 = i1; - --i1; - *i1; // no-warning -} - -void copy_and_decrease2(const std::vector &v) { - auto i1 = v.end(); - auto i2 = i1; - --i1; - *i2; // expected-warning{{Iterator accessed past its end}} -} - -void copy_and_increase1(const std::vector &v) { - auto i1 = v.begin(); - auto i2 = i1; - ++i1; - if (i1 == v.end()) -*i2; // no-warning -} - -void copy_and_increase2(const std::vector &v) { - auto i1 = v.begin(); - auto i2 = i1; - ++i1; - if (i2 == v.end()) -*i2; // expected-warning{{Iterator accessed past its end}} -} - -void good_find(std::vector &vec, int e) { - auto first = std::find(vec.begin(), vec.end(), e); - if (vec.end() != first) -*first; // no-warning -} - -void bad_find(std::vector &vec, int e) { - auto first = std::find(vec.begin(), vec.end(), e); - *first; // expected-warning{{Iterator accessed past its end}} -} - -void good_find_end(std::vector &vec, std::vector &seq) { - auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); - if (vec.end() != last) -*last; // no-warning -} - -void bad_find_end(std::vector &vec, std::vector &seq) { - auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); - *last; // expected-warning{{Iterator accessed past its end}} -} - -void good_find_first_of(std::vector &vec, std::vector &seq) { - auto first = - std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end()); - if (vec.end() != first) -*first; // no-warning -} - -void bad_find_first_of(std::vector &vec, std::vector &seq) { - auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end()); - *first; // expected-warning{{Iterator accessed past its end}} -} - -bool odd(int i) { return i % 2; } - -void good_find_if(std::vector &vec) { - auto first = std::find_if(vec.begin(), vec.end(), odd); - if (vec.end() != first) -*first; // no-warning -} - -void bad_find_if(std::vector &vec, int e) { - auto first = std::find_if(vec.begin(), vec.end(), odd); - *first; // expected-warning{{Iterator accessed past its end}} -} - -void good_find_if_not(std::vector &vec) { - auto first = std::find_if_not(vec.begin(), vec.end(), odd); - if (vec.end() != first) -*first; // no-warning -} - -void bad_find_if_not(std::vector &vec, int e) { - auto first = std::find_if_not(vec.begin(), vec.end(), odd); - *first; // expected-warning{{Iterator accessed past its end}} -} - -void good_lower_bound(std::vector &vec, int e) { - auto first = std::lower_bound(vec.begin(), vec.end(), e); - if (vec.end() != first) -*first; // no-warning -} - -void bad_lower_bound(std::vector &vec, int e) { - auto first = std::lower_bound(vec.begin(), vec.end(), e); - *first; // expected-warning{{Iterator accessed past its end}} -} - -void good_upper_bound(std::vector &vec, int e) { - auto last = std::lower_bound(vec.begin(), vec.end(), e); - if (vec.end() != last) -*last; // no-warning -} - -void bad_upper_bound(std::vector &vec, int e) { - auto last = std::lower_bound(vec.begin(), vec.end(), e); - *last; // expected-warning{{Iterator accessed past its end}} -} - -void good_sear
r301542 - [libclang] Pass in the -fallow-editor-placeholders option
Author: arphaman Date: Thu Apr 27 08:47:03 2017 New Revision: 301542 URL: http://llvm.org/viewvc/llvm-project?rev=301542&view=rev Log: [libclang] Pass in the -fallow-editor-placeholders option This will suppress any live diagnostics caused by editor placeholders in Xcode. rdar://31833579 Added: cfe/trunk/test/Index/allow-editor-placeholders.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=301542&r1=301541&r2=301542&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Apr 27 08:47:03 2017 @@ -266,7 +266,8 @@ LANGOPT(SanitizeAddressFieldPadding, 2, LANGOPT(XRayInstrument, 1, 0, "controls whether to do XRay instrumentation") -LANGOPT(AllowEditorPlaceholders, 1, 0, "allow editor placeholders in source") +BENIGN_LANGOPT(AllowEditorPlaceholders, 1, 0, + "allow editor placeholders in source") #undef LANGOPT #undef COMPATIBLE_LANGOPT Added: cfe/trunk/test/Index/allow-editor-placeholders.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/allow-editor-placeholders.cpp?rev=301542&view=auto == --- cfe/trunk/test/Index/allow-editor-placeholders.cpp (added) +++ cfe/trunk/test/Index/allow-editor-placeholders.cpp Thu Apr 27 08:47:03 2017 @@ -0,0 +1,5 @@ +// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s + +<#placeholder#>; + +// CHECK-NOT: error Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=301542&r1=301541&r2=301542&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Thu Apr 27 08:47:03 2017 @@ -3371,7 +3371,10 @@ clang_parseTranslationUnit_Impl(CXIndex Args->push_back("-Xclang"); Args->push_back("-detailed-preprocessing-record"); } - + + // Suppress any editor placeholder diagnostics. + Args->push_back("-fallow-editor-placeholders"); + unsigned NumErrors = Diags->getClient()->getNumErrors(); std::unique_ptr ErrUnit; // Unless the user specified that they want the preamble on the first parse ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31887: [clangd] Add documentation page
malaperle-ericsson added a comment. Ping. Any more objections? https://reviews.llvm.org/D31887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31887: [clangd] Add documentation page
JDevlieghere added a comment. Looks good, nothing to add from my side. https://reviews.llvm.org/D31887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301547 - [OPENMP] Improve performance of the hasDSA() function, NFC.
Author: abataev Date: Thu Apr 27 09:46:26 2017 New Revision: 301547 URL: http://llvm.org/viewvc/llvm-project?rev=301547&view=rev Log: [OPENMP] Improve performance of the hasDSA() function, NFC. Remove some unneccesary code from the function after the fix for ASAN buildbots. Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301547&r1=301546&r2=301547&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 27 09:46:26 2017 @@ -824,23 +824,18 @@ DSAStackTy::hasDSA(ValueDecl *D, if (isStackEmpty()) return {}; D = getCanonicalDecl(D); - auto StartI = std::next(Stack.back().first.rbegin()); + auto I = (FromParent && Stack.back().first.size() > 1) + ? std::next(Stack.back().first.rbegin()) + : Stack.back().first.rbegin(); auto EndI = Stack.back().first.rend(); - if (FromParent && StartI != EndI) -StartI = std::next(StartI); - if (StartI == EndI) -return {}; - auto I = std::prev(StartI); do { -++I; -if (I == EndI) - break; +std::advance(I, 1); if (!DPred(I->Directive) && !isParallelOrTaskRegion(I->Directive)) continue; DSAVarData DVar = getDSA(I, D); if (CPred(DVar.CKind)) return DVar; - } while (I != EndI); + } while (std::distance(I, EndI) > 1); return {}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31975: [Analyzer] Iterator Checkers
NoQ added a comment. I've seen the new reviews. A lot of thanks for working on the patch split. I believe it'd eventually benefit everyone, similarly to how everybody benefits from code quality or something like that. I'd try to keep up with the "to split or not to split" discussion a bit below, not sure if it's of much interest since we're already trying this out practically and we'll see how much benefit it brings at the end :) And in any case, it's quite hard to see at first that the "incremental" mindset actually works in practice, as i do know that initially it feels strange at times. In https://reviews.llvm.org/D31975#737751, @baloghadamsoftware wrote: > Actually, I did neither merge the patches nor the checkers. Based on the > experiences in the prototype I created a totally new checker. Incremental > development sounds good, but I did a lot of experimenting in this particular > checker, which means I added things then removed them, I changed things then > changed them back etc. Yep. In this case, a high-level description of why a rewrite is necessary and what was wrong with the old approach would be really helpful, both after and //before// doing actual work. I'm really interested in what downsides you found in the old checker that needed a complete rewrite to mitigate. Because normally there are very few right ways to write the checker. I've a feeling this experience would be very useful to the community. While it's definitely not worth it to publish a review every time you're conducting an experiment, it's a good idea to maintain the local history clean and incremental (probably utilizing rebase regularly, eg. if you patch up an old feature, move the patch back to that feature and squash it up after committing), so that splitting it up later was trivial. In https://reviews.llvm.org/D31975#737751, @baloghadamsoftware wrote: > I can try to separate that small part (simple_good and simple_bad tests > pass), but cutting the patch in 12+ parts is overkill. For example, > separation of insert and emplace is pointless because they affect iterators > exactly the same way. But I woul also merge them with erase, the patches > remain small enough. I think 5 parts are more than enough Yep, that's right, i definitely don't insist on re-using my examples; they were done in a rush and blindly and often don't look harmonously. In https://reviews.llvm.org/D31975#737751, @baloghadamsoftware wrote: > because review will take weeks, so uploading them incrementally one-by-one > will take at least half a year. I believe it doesn't work that way :) - Smaller changes are non-linearly easier to review; large changes require keeping all the stuff in your head, and you cannot move forward with the review until you understand all of it. Ultimately, reducing per-line-of-code workload on us would allow us to do more reviews and keep contributors happy. - In my experience, it especially applies to estimating test coverage - it would be hard to notice what features are not covered by tests because you need to keep all the features in your head simultaneously. I think i've noticed some strange things in the coverage when i was splitting up the patches, but i didn't record these anywhere. - Small reviews can be completed in a few hours, maybe even in minutes, of continuous work, but large reviews require large continuous time slots; for patches with thousands of lines of code changed, we may never be able to find such time slots. - Small reviews increase the chances that at least a part of the contributor's work lands. If some patches are delayed because an alternative approach is proposed, probably involving changes that you're not taking up, we can at least have the rest of the changes in. - Small reviews would attract more reviewers, who may not be ready to review large changes, or are only sure about their skill in some technologies used but not in other. - Because our contributors are contributing large changes, we have to apply review pressure on them to make sure these changes are complete and self-contained, because we cannot be sure they will be maintained by the author later. We'd much more eagerly accept a smaller change when the author says he'd fix things up in follow-up commits, even if these changes are obviously incomplete and lacking features. So the review for smaller changes is ultimately less strict. So, ideally, i believe that reviews aren't normally slow; the impression that reviews are slow only appears when many authors try to contribute large patches. Sorry for the ranting, and thanks again for investing more and more time into the Analyzer>< https://reviews.llvm.org/D31975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32592: [Analyzer] Iterator Checker - Part1: Minimal Checker for a Simple Test Case
NoQ added a comment. Thank you very much! I think you might have forgotten to include the newly added files in this review(?)>< https://reviews.llvm.org/D32592 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301548 - [index] Mark the ObjC implicit accessor method definitions as 'dynamic' as well
Author: akirtzidis Date: Thu Apr 27 10:05:18 2017 New Revision: 301548 URL: http://llvm.org/viewvc/llvm-project?rev=301548&view=rev Log: [index] Mark the ObjC implicit accessor method definitions as 'dynamic' as well Modified: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/test/Index/Core/index-source.m Modified: cfe/trunk/lib/Index/IndexDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=301548&r1=301547&r2=301548&view=diff == --- cfe/trunk/lib/Index/IndexDecl.cpp (original) +++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Apr 27 10:05:18 2017 @@ -481,17 +481,17 @@ public: return true; assert(D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize); +SymbolRoleSet AccessorMethodRoles = + SymbolRoleSet(SymbolRole::Dynamic) | SymbolRoleSet(SymbolRole::Implicit); if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) { if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container)) -IndexCtx.handleDecl(MD, Loc, SymbolRoleSet(SymbolRole::Implicit), {}, -Container); +IndexCtx.handleDecl(MD, Loc, AccessorMethodRoles, {}, Container); } if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) { if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container)) -IndexCtx.handleDecl(MD, Loc, SymbolRoleSet(SymbolRole::Implicit), {}, -Container); +IndexCtx.handleDecl(MD, Loc, AccessorMethodRoles, {}, Container); } if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) { if (IvarD->getSynthesize()) { Modified: cfe/trunk/test/Index/Core/index-source.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=301548&r1=301547&r2=301548&view=diff == --- cfe/trunk/test/Index/Core/index-source.m (original) +++ cfe/trunk/test/Index/Core/index-source.m Thu Apr 27 10:05:18 2017 @@ -150,9 +150,9 @@ extern int setjmp(jmp_buf); // CHECK: [[@LINE+9]]:13 | instance-property/ObjC | prop | [[I2_prop_USR:.*]] | | Def,RelChild,RelAcc | rel: 2 // CHECK-NEXT: RelChild | I2 | [[I2_USR]] // CHECK-NEXT: RelAcc | _prop | c:objc(cs)I2@_prop -// CHECK: [[@LINE+6]]:13 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR]] | -[I2 prop] | Def,Impl,RelChild | rel: 1 +// CHECK: [[@LINE+6]]:13 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR]] | -[I2 prop] | Def,Dyn,Impl,RelChild | rel: 1 // CHECK-NEXT: RelChild | I2 | [[I2_USR]] -// CHECK: [[@LINE+4]]:13 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR]] | -[I2 setProp:] | Def,Impl,RelChild | rel: 1 +// CHECK: [[@LINE+4]]:13 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR]] | -[I2 setProp:] | Def,Dyn,Impl,RelChild | rel: 1 // CHECK-NEXT: RelChild | I2 | [[I2_USR]] // CHECK: [[@LINE+2]]:20 | field/ObjC | _prop | c:objc(cs)I2@_prop | | Def,RelChild | rel: 1 // CHECK-NEXT: RelChild | I2 | [[I2_USR]] @@ -214,8 +214,8 @@ extern int setjmp(jmp_buf); // CHECK: [[@LINE+5]]:13 | instance-property/ObjC | prop | c:objc(cs)I3(py)prop | | Def,RelChild,RelAcc | rel: 2 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3 // CHECK-NEXT: RelAcc | _prop | c:objc(cs)I3@_prop -// CHECK: [[@LINE+2]]:13 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Def,Impl,RelChild | rel: 1 -// CHECK: [[@LINE+1]]:13 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Def,Impl,RelChild | rel: 1 +// CHECK: [[@LINE+2]]:13 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Def,Dyn,Impl,RelChild | rel: 1 +// CHECK: [[@LINE+1]]:13 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Def,Dyn,Impl,RelChild | rel: 1 @synthesize prop = _prop; @end @@ -275,9 +275,9 @@ typedef MyGenCls // CHECK: [[@LINE-1]]:13 | instance-property/ObjC | foo | c:objc(cs)I4(py)foo | | Def,RelChild,RelAcc | rel: 2 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4 // CHECK-NEXT: RelAcc | _blahfoo | c:objc(cs)I4@_blahfoo -// CHECK: [[@LINE-4]]:13 | instance-method/acc-get/ObjC | foo | c:objc(cs)I4(im)foo | -[I4 foo] | Def,Impl,RelChild | rel: 1 +// CHECK: [[@LINE-4]]:13 | instance-method/acc-get/ObjC | foo | c:objc(cs)I4(im)foo | -[I4 foo] | Def,Dyn,Impl,RelChild | rel: 1 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4 -// CHECK: [[@LINE-6]]:13 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I4(im)setFoo: | -[I4 setFoo:] | Def,Impl,RelChild | rel: 1 +// CHECK: [[@LINE-6]]:13 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I4(im)setFoo: | -[I4 setFoo:] | Def,Dyn,Impl,RelChild | rel: 1 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4 // CHECK: [[@LINE-8]]:19 | field/ObjC | _blahfoo | c:objc(cs)I4@_blahfoo | | Ref | rel: 0 @@ -296,9 +296,9 @@ typedef MyGenCls // CHECK: [[@LINE
r301549 - [OPENMP] Add a check for iterator not reached the end of stack, NFC.
Author: abataev Date: Thu Apr 27 10:10:33 2017 New Revision: 301549 URL: http://llvm.org/viewvc/llvm-project?rev=301549&view=rev Log: [OPENMP] Add a check for iterator not reached the end of stack, NFC. Add an extra check for the iterator during checks of the data-sharing attributes. Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301549&r1=301548&r2=301549&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 27 10:10:33 2017 @@ -828,14 +828,14 @@ DSAStackTy::hasDSA(ValueDecl *D, ? std::next(Stack.back().first.rbegin()) : Stack.back().first.rbegin(); auto EndI = Stack.back().first.rend(); - do { + while (std::distance(I, EndI) > 1) { std::advance(I, 1); if (!DPred(I->Directive) && !isParallelOrTaskRegion(I->Directive)) continue; DSAVarData DVar = getDSA(I, D); if (CPred(DVar.CKind)) return DVar; - } while (std::distance(I, EndI) > 1); + } return {}; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function
NoQ added a comment. I've a feeling we need to roll this back a little bit. The `memset()` function does the following: 1. Accesses pointers in range R = [first argument, first argument + third argument] and crashes when accessing an invalid pointer. 2. Writes second argument to all bytes in range R. 3. Returns its first argument. Assuming R is an empty set, steps 1 and 2 are skipped. We handle step 1 through `checkNonNull` and `checkBufferAccess`. These easy-to-use functions are already available in the checker, just pass the arguments there directly. For step 2, we decided to skip most of the step, instead invalidating the whole //base region// around R. There's a separate task to come up with a better behavior here, but we decided to do it later, probably in the next patch. So for now, the relationship between the size of the buffer and the third argument are not relevant and should not be considered - this is an idea for the future. Finally, step 3 can be done by binding the call expression to the symbolic value of the first argument through `BindExpr`. You are already doing this in the zero-size case, but it should be similar in all cases. There is no need to construct a new symbol here - just use the existing `SVal`. Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2034 + // If the size can be nonzero, we have to check the other arguments. + if (stateNonZeroSize) { +state = stateNonZeroSize; danielmarjamaki wrote: > use early return: > > if (!stateNonZeroSize) > return; In fact this early return is unnecessary. Of the two states returned by `assume()`, at least one is always non-null (we have an assertion for that). However, the since the situation `(StateZeroSize && !StateNonZeroSize)` was checked above, it follows from `(!StateNonZeroSize)` that `StateZeroSize` is also null, which contradicts the above. So we can assert here that `StateNonZeroSize` is not null. Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2045-2049 + SVal RetVal = SB.getConjuredHeapSymbolVal(CE, LCtx, C.blockCount()); + const SymbolicRegion *SR = + dyn_cast_or_null(RetVal.getAsRegion()); + if (!SR) +return; Here you construct a new symbol that represents the pointer returned. However, we return our first argument, which is already denoted by symbolic value `MemVal`, so we don't need a new symbol here - we'd return `MemVal` directly, and work on it directly during invalidation. Also, note that it's not necessarily on the heap. Repository: rL LLVM https://reviews.llvm.org/D31868 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function
xiangzhai added a comment. Hi Artem, Thank you so much! you are my mentor teach me patiently and carefully, I will update my patch tomorrow, good night from my timezone:) Regards, Leslie Zhai Repository: rL LLVM https://reviews.llvm.org/D31868 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31650: [Analyzer] Detect when function pointer is freed
NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. Looks good, thanks! Did you evaluate this on a large codebase - were warnings plentiful and were there any false positives known? I'd like to summon Anna here for a little bit because that's a new check that is enabled by default, so it's always a bit of a historical moment: - Does the warning message sound reasonable? (it does to me). - Should we keep it as part of the unix.Malloc checker package, or should we be able to enable it separately? Repository: rL LLVM https://reviews.llvm.org/D31650 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32595: CMakeLists: Don't set LLVM_MAIN_SRC_DIR when building stand-alone clang
tstellar created this revision. clang was using LLVM_MAIN_SRC_DIR to search for lit.py to use for running clang's lit tests. This was dangerous though, because LLVM_MAIN_SRC_DIR was determined by using llvm-config --src-root and this directory may have been modified since llvm-config was built (e.g. User builds and install llvm trunk and then checks out the release_40 branch in their source tree). https://reviews.llvm.org/D32595 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -54,7 +54,6 @@ set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. # CMake assumes slashes as PATH. @@ -125,29 +124,11 @@ set(LLVM_UTILS_PROVIDED ON) endif() -if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - # Note: path not really used, except for checking if lit was found - set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - if(NOT LLVM_UTILS_PROVIDED) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/count utils/count) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not) -set(LLVM_UTILS_PROVIDED ON) -set(CLANG_TEST_DEPS FileCheck count not) - endif() - set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) - if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h - AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) -add_subdirectory(${UNITTEST_DIR} utils/unittest) - endif() -else() - # Seek installed Lit. - find_program(LLVM_LIT - NAMES llvm-lit lit.py lit - PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit" - DOC "Path to lit.py") -endif() +# Seek installed Lit. +find_program(LLVM_LIT + NAMES llvm-lit lit.py lit + PATHS "${LLVM_TOOLS_BINARY_DIR}" + DOC "Path to lit.py") if(LLVM_LIT) # Define the default arguments to use with 'lit', and an option for the user @@ -440,13 +421,7 @@ if( CLANG_INCLUDE_TESTS ) - if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) -add_subdirectory(unittests) -list(APPEND CLANG_TEST_DEPS ClangUnitTests) -list(APPEND CLANG_TEST_PARAMS - clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg - ) - endif() + add_subdirectory(test) if(CLANG_BUILT_STANDALONE) @@ -463,6 +438,14 @@ DEPENDS ${LLVM_LIT_DEPENDS} ARGS ${LLVM_LIT_EXTRA_ARGS} ) + else() +if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) + add_subdirectory(unittests) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS + clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg +) +endif() endif() add_subdirectory(utils/perf-training) endif() Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -54,7 +54,6 @@ set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. # CMake assumes slashes as PATH. @@ -125,29 +124,11 @@ set(LLVM_UTILS_PROVIDED ON) endif() -if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - # Note: path not really used, except for checking if lit was found - set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py) - if(NOT LLVM_UTILS_PROVIDED) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/count utils/count) -add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not) -set(LLVM_UTILS_PROVIDED ON) -set(CLANG_TEST_DEPS FileCheck count not) - endif() - set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest) - if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h - AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt) -add_subdirectory(${UNITTEST_DIR} utils/unittest) - endif() -else() -
[PATCH] D28867: [Profile] Add off-by-default -Wprofile-instr-missing warning
xur added a comment. Looks good to me. https://reviews.llvm.org/D28867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)
MatzeB added a comment. Just out of interested: I can see how `__attribute__ ((interrupt))` is useful, but in what situations would you use `no_caller_saved_registers`? https://reviews.llvm.org/D22045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags
v.g.vassilev added a comment. I think you will see the issue if you add a negative test case, too. I.e. as Raphael said in `-MD` and `-MMD` mode we should be able to see warnings. https://reviews.llvm.org/D32341 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22045: [X86] Support of no_caller_saved_registers attribute (Clang part)
MatzeB added a comment. In https://reviews.llvm.org/D22045#739627, @MatzeB wrote: > Just out of interested: I can see how `__attribute__ ((interrupt))` is > useful, but in what situations would you use `no_caller_saved_registers`? Actually please answer this question by documenting the attribute in `docs/LangRef.rst` in the llvm part of the changes. https://reviews.llvm.org/D22045 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301563 - Remove leaking UnknownPragmaHandlers right after we are done with them.
Author: vvassilev Date: Thu Apr 27 11:58:33 2017 New Revision: 301563 URL: http://llvm.org/viewvc/llvm-project?rev=301563&view=rev Log: Remove leaking UnknownPragmaHandlers right after we are done with them. The UnknownPragmaHandlers added by DoPrintPreprocessedInput conflict with the real PragmaHandlers from clang::Parser because they try to handle the same #pragma directives. This makes it impossible to use a Preprocessor (that was previously passed to DoPrintPreprocessedInput), as an Preprocessor for a clang::Parser instance which is what we currently do in cling. This patch removes the added UnknownPragmaHandler to avoid conflicts these conflicts and leave the PragmaHandlers of the Preprocessors in a the same state as before calling DoPrintPreprocessedInput. Patch by Raphael Isemann (D32486)! Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301563&r1=301562&r2=301563&view=diff == --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original) +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Thu Apr 27 11:58:33 2017 @@ -775,26 +775,33 @@ void clang::DoPrintPreprocessedInput(Pre // Expand macros in pragmas with -fms-extensions. The assumption is that // the majority of pragmas in such a file will be Microsoft pragmas. - PP.AddPragmaHandler(new UnknownPragmaHandler( - "#pragma", Callbacks, + // Remember the handlers we will add so that we can remove them later. + std::unique_ptr MicrosoftExtHandler( + new UnknownPragmaHandler( + "#pragma", Callbacks, + /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt)); + + std::unique_ptr GCCHandler(new UnknownPragmaHandler( + "#pragma GCC", Callbacks, + /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt)); + + std::unique_ptr ClangHandler(new UnknownPragmaHandler( + "#pragma clang", Callbacks, /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt)); - PP.AddPragmaHandler( - "GCC", new UnknownPragmaHandler( - "#pragma GCC", Callbacks, - /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt)); - PP.AddPragmaHandler( - "clang", new UnknownPragmaHandler( - "#pragma clang", Callbacks, - /*RequireTokenExpansion=*/PP.getLangOpts().MicrosoftExt)); + + PP.AddPragmaHandler(MicrosoftExtHandler.get()); + PP.AddPragmaHandler("GCC", GCCHandler.get()); + PP.AddPragmaHandler("clang", ClangHandler.get()); // The tokens after pragma omp need to be expanded. // // OpenMP [2.1, Directive format] // Preprocessing tokens following the #pragma omp are subject to macro // replacement. - PP.AddPragmaHandler("omp", - new UnknownPragmaHandler("#pragma omp", Callbacks, - /*RequireTokenExpansion=*/true)); + std::unique_ptr OpenMPHandler( + new UnknownPragmaHandler("#pragma omp", Callbacks, + /*RequireTokenExpansion=*/true)); + PP.AddPragmaHandler("omp", OpenMPHandler.get()); PP.addPPCallbacks(std::unique_ptr(Callbacks)); @@ -822,4 +829,11 @@ void clang::DoPrintPreprocessedInput(Pre // Read all the preprocessed tokens, printing them out to the stream. PrintPreprocessedTokens(PP, Tok, Callbacks, *OS); *OS << '\n'; + + // Remove the handlers we just added to leave the preprocessor in a sane state + // so that it can be reused (for example by a clang::Parser instance). + PP.RemovePragmaHandler(MicrosoftExtHandler.get()); + PP.RemovePragmaHandler("GCC", GCCHandler.get()); + PP.RemovePragmaHandler("clang", ClangHandler.get()); + PP.RemovePragmaHandler("omp", OpenMPHandler.get()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32486: Cleanup pragma handlers after DoPrintPreprocessedInput
v.g.vassilev closed this revision. v.g.vassilev added a comment. Landed in r301563. https://reviews.llvm.org/D32486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301564 - Fix -Wpedantic about extra semicolons in CGStmtOpenMP.cpp
Author: hans Date: Thu Apr 27 12:02:25 2017 New Revision: 301564 URL: http://llvm.org/viewvc/llvm-project?rev=301564&view=rev Log: Fix -Wpedantic about extra semicolons in CGStmtOpenMP.cpp Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=301564&r1=301563&r2=301564&view=diff == --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original) +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Apr 27 12:02:25 2017 @@ -1675,7 +1675,7 @@ static void emitOMPLoopBodyWithStopPoint CodeGenFunction::JumpDest LoopExit) { CGF.EmitOMPLoopBody(S, LoopExit); CGF.EmitStopPoint(&S); -}; +} void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) { auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) { @@ -2093,7 +2093,7 @@ emitDistributeParallelForDispatchBounds( llvm::Value *UBVal = CGF.EmitLoadOfScalar(UB, /*Volatile=*/false, IteratorTy, SourceLocation()); return {LBVal, UBVal}; -}; +} static void emitDistributeParallelForDistributeInnerBoundParams( CodeGenFunction &CGF, const OMPExecutableDirective &S, @@ -2110,7 +2110,7 @@ static void emitDistributeParallelForDis auto UBCast = CGF.Builder.CreateIntCast( CGF.Builder.CreateLoad(UB.getAddress()), CGF.SizeTy, /*isSigned=*/false); CapturedVars.push_back(UBCast); -}; +} static void emitInnerParallelForWhenCombined(CodeGenFunction &CGF, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31252: [clang-tidy] add readability-compound-statement-size check.
lebedev.ri abandoned this revision. lebedev.ri added a comment. Thank you all! After some thought, i have come to conclusion that it is best to start with something less controversial, and simpler. https://reviews.llvm.org/D31252 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301567 - clang-cl: Alias /d1reportAllClassLayout to -fdump-record-layouts (PR32826)
Author: hans Date: Thu Apr 27 12:19:07 2017 New Revision: 301567 URL: http://llvm.org/viewvc/llvm-project?rev=301567&view=rev Log: clang-cl: Alias /d1reportAllClassLayout to -fdump-record-layouts (PR32826) Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td cfe/trunk/test/Driver/cl-options.c Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=301567&r1=301566&r2=301567&view=diff == --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original) +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Apr 27 12:19:07 2017 @@ -61,6 +61,8 @@ def _SLASH_Brepro_ : CLFlag<"Brepro-">, def _SLASH_C : CLFlag<"C">, HelpText<"Don't discard comments when preprocessing">, Alias; def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias; +def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">, + HelpText<"Dump record layout information">, Alias; def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, MetaVarName<"">, Alias; def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias; Modified: cfe/trunk/test/Driver/cl-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=301567&r1=301566&r2=301567&view=diff == --- cfe/trunk/test/Driver/cl-options.c (original) +++ cfe/trunk/test/Driver/cl-options.c Thu Apr 27 12:19:07 2017 @@ -14,6 +14,9 @@ // C_P: "-E" // C_P: "-C" +// RUN: %clang_cl /d1reportAllClassLayout -### -- %s 2>&1 | FileCheck -check-prefix=d1reportAllClassLayout %s +// d1reportAllClassLayout: -fdump-record-layouts + // RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \ // RUN:-### -- %s 2>&1 | FileCheck -check-prefix=D %s // D: "-D" "foo=bar" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301568 - [libclang] Enhance clang_Cursor_isDynamicCall and clang_Cursor_getReceiverType to handle ObjC property references
Author: akirtzidis Date: Thu Apr 27 12:23:04 2017 New Revision: 301568 URL: http://llvm.org/viewvc/llvm-project?rev=301568&view=rev Log: [libclang] Enhance clang_Cursor_isDynamicCall and clang_Cursor_getReceiverType to handle ObjC property references Also enhance clang_Cursor_getReceiverType to handle C++ method calls. Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/test/Index/cursor-dynamic-call.mm cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=301568&r1=301567&r2=301568&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu Apr 27 12:23:04 2017 @@ -3975,8 +3975,8 @@ CINDEX_LINKAGE int clang_Cursor_getObjCS CINDEX_LINKAGE int clang_Cursor_isDynamicCall(CXCursor C); /** - * \brief Given a cursor pointing to an Objective-C message, returns the CXType - * of the receiver. + * \brief Given a cursor pointing to an Objective-C message or property + * reference, or C++ method call, returns the CXType of the receiver. */ CINDEX_LINKAGE CXType clang_Cursor_getReceiverType(CXCursor C); Modified: cfe/trunk/test/Index/cursor-dynamic-call.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cursor-dynamic-call.mm?rev=301568&r1=301567&r2=301568&view=diff == --- cfe/trunk/test/Index/cursor-dynamic-call.mm (original) +++ cfe/trunk/test/Index/cursor-dynamic-call.mm Thu Apr 27 12:23:04 2017 @@ -49,6 +49,14 @@ void test2() { id o = [[Test alloc] init]; } +@interface Test2 : NSObject +@property (assign) id someProp; +@end + +void test3(Test2 *o) { + id v = o.someProp; +} + // RUN: c-index-test -cursor-at=%s:8:11 \ // RUN: -cursor-at=%s:9:11 \ // RUN: -cursor-at=%s:25:11 \ @@ -59,6 +67,7 @@ void test2() { // RUN: -cursor-at=%s:36:9 \ // RUN: -cursor-at=%s:37:9 \ // RUN: -cursor-at=%s:49:26 \ +// RUN: -cursor-at=%s:57:12 \ // RUN: %s | FileCheck %s // CHECK: 8:11 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call @@ -67,9 +76,10 @@ void test2() { // CHECK-NOT: 26:3 {{.*}} Dynamic-call // CHECK-NOT: 29:3 {{.*}} Dynamic-call // CHECK: 29:3 {{.*}} Receiver-type=ObjCInterface -// CHECK: 34:7 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call +// CHECK: 34:7 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call Receiver-type=Pointer // CHECK: 35:3 ObjCMessageExpr=meth:14:8 {{.*}} Dynamic-call Receiver-type=ObjCObjectPointer // CHECK-NOT: 36:3 {{.*}} Dynamic-call // CHECK: 36:3 {{.*}} Receiver-type=ObjCInterface // CHECK: 37:3 ObjCMessageExpr=ClsMeth:15:8 {{.*}} Dynamic-call Receiver-type=ObjCClass // CHECK-NOT: 49:10 {{.*}} Dynamic-call +// CHECK: 57:12 MemberRefExpr=someProp:53:23 {{.*}} Dynamic-call Receiver-type=ObjCObjectPointer Modified: cfe/trunk/tools/c-index-test/c-index-test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=301568&r1=301567&r2=301568&view=diff == --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Apr 27 12:23:04 2017 @@ -2437,11 +2437,14 @@ static void inspect_print_cursor(CXCurso clang_Cursor_getObjCSelectorIndex(Cursor)); if (clang_Cursor_isDynamicCall(Cursor)) printf(" Dynamic-call"); - if (Cursor.kind == CXCursor_ObjCMessageExpr) { + if (Cursor.kind == CXCursor_ObjCMessageExpr || + Cursor.kind == CXCursor_MemberRefExpr) { CXType T = clang_Cursor_getReceiverType(Cursor); -CXString S = clang_getTypeKindSpelling(T.kind); -printf(" Receiver-type=%s", clang_getCString(S)); -clang_disposeString(S); +if (T.kind != CXType_Invalid) { + CXString S = clang_getTypeKindSpelling(T.kind); + printf(" Receiver-type=%s", clang_getCString(S)); + clang_disposeString(S); +} } { Modified: cfe/trunk/tools/libclang/CXCursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=301568&r1=301567&r2=301568&view=diff == --- cfe/trunk/tools/libclang/CXCursor.cpp (original) +++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Apr 27 12:23:04 2017 @@ -1523,6 +1523,10 @@ int clang_Cursor_isDynamicCall(CXCursor return true; } + if (auto *PropRefE = dyn_cast(E)) { +return !PropRefE->isSuperReceiver(); + } + const MemberExpr *ME = nullptr; if (isa(E)) ME = cast(E); @@ -1532,7 +1536,9 @@ int clang_Cursor_isDynamicCall(CXCursor if (ME) { if (const CXXMethodDecl * MD = dyn_cast_or_null(ME->getMemberDecl())) - return
[PATCH] D32342: Changed llvm/CMakeLists.txt and added relative path to llvm doxygen
v.g.vassilev closed this revision. v.g.vassilev added a comment. Landed in r301569. https://reviews.llvm.org/D32342 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301570 - [Profile] Add off-by-default -Wprofile-instr-missing warning
Author: vedantk Date: Thu Apr 27 12:30:58 2017 New Revision: 301570 URL: http://llvm.org/viewvc/llvm-project?rev=301570&view=rev Log: [Profile] Add off-by-default -Wprofile-instr-missing warning Clang warns that a profile is out-of-date if it can't find a profile record for any function in a TU. This warning became noisy after llvm started allowing dead-stripping of instrumented functions. To fix this, this patch changes the existing profile out-of-date warning (-Wprofile-instr-out-of-date) so that it only complains about mismatched data. Further, it introduces a new, off-by-default warning about missing function data (-Wprofile-instr-missing). Differential Revision: https://reviews.llvm.org/D28867 Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/Profile/c-outdated-data.c Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=301570&r1=301569&r2=301570&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 27 12:30:58 2017 @@ -890,6 +890,7 @@ def BackendOptimizationRemarkAnalysis : def BackendOptimizationFailure : DiagGroup<"pass-failed">; // Instrumentation based profiling warnings. +def ProfileInstrMissing : DiagGroup<"profile-instr-missing">; def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">; def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=301570&r1=301569&r2=301570&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 27 12:30:58 2017 @@ -8938,8 +8938,13 @@ def warn_not_a_doxygen_trailing_member_c let CategoryName = "Instrumentation Issue" in { def warn_profile_data_out_of_date : Warning< "profile data may be out of date: of %0 function%s0, %1 %plural{1:has|:have}1" - " no data and %2 %plural{1:has|:have}2 mismatched data that will be ignored">, + " mismatched data that will be ignored">, InGroup; +def warn_profile_data_missing : Warning< + "profile data may be incomplete: of %0 function%s0, %1 %plural{1:has|:have}1" + " no data">, + InGroup, + DefaultIgnore; def warn_profile_data_unprofiled : Warning< "no profile data available for file \"%0\"">, InGroup; Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=301570&r1=301569&r2=301570&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 27 12:30:58 2017 @@ -369,9 +369,13 @@ void InstrProfStats::reportDiagnostics(D if (MainFile.empty()) MainFile = ""; Diags.Report(diag::warn_profile_data_unprofiled) << MainFile; - } else -Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing - << Mismatched; + } else { +if (Mismatched > 0) + Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Mismatched; + +if (Missing > 0) + Diags.Report(diag::warn_profile_data_missing) << Visited << Missing; + } } void CodeGenModule::Release() { Modified: cfe/trunk/test/Profile/c-outdated-data.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-outdated-data.c?rev=301570&r1=301569&r2=301570&view=diff == --- cfe/trunk/test/Profile/c-outdated-data.c (original) +++ cfe/trunk/test/Profile/c-outdated-data.c Thu Apr 27 12:30:58 2017 @@ -4,23 +4,23 @@ // doesn't play well with warnings that have no line number. // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s -// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=NO_MISSING +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -Wprofile-instr-missing -fprofil
[PATCH] D28867: [Profile] Add off-by-default -Wprofile-instr-missing warning
This revision was automatically updated to reflect the committed changes. Closed by commit rL301570: [Profile] Add off-by-default -Wprofile-instr-missing warning (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D28867?vs=96847&id=96945#toc Repository: rL LLVM https://reviews.llvm.org/D28867 Files: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/Profile/c-outdated-data.c Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -8938,8 +8938,13 @@ let CategoryName = "Instrumentation Issue" in { def warn_profile_data_out_of_date : Warning< "profile data may be out of date: of %0 function%s0, %1 %plural{1:has|:have}1" - " no data and %2 %plural{1:has|:have}2 mismatched data that will be ignored">, + " mismatched data that will be ignored">, InGroup; +def warn_profile_data_missing : Warning< + "profile data may be incomplete: of %0 function%s0, %1 %plural{1:has|:have}1" + " no data">, + InGroup, + DefaultIgnore; def warn_profile_data_unprofiled : Warning< "no profile data available for file \"%0\"">, InGroup; Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td === --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td @@ -890,6 +890,7 @@ def BackendOptimizationFailure : DiagGroup<"pass-failed">; // Instrumentation based profiling warnings. +def ProfileInstrMissing : DiagGroup<"profile-instr-missing">; def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">; def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">; Index: cfe/trunk/test/Profile/c-outdated-data.c === --- cfe/trunk/test/Profile/c-outdated-data.c +++ cfe/trunk/test/Profile/c-outdated-data.c @@ -4,23 +4,23 @@ // doesn't play well with warnings that have no line number. // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | FileCheck %s -// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no data and 1 has mismatched data that will be ignored +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=NO_MISSING +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -Wprofile-instr-missing -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -check-prefix=WITH_MISSING + +// NO_MISSING: warning: profile data may be out of date: of 3 functions, 1 has mismatched data that will be ignored +// NO_MISSING-NOT: 1 has no data + +// WITH_MISSING: warning: profile data may be out of date: of 3 functions, 1 has mismatched data that will be ignored +// WITH_MISSING: warning: profile data may be incomplete: of 3 functions, 1 has no data void no_usable_data() { int i = 0; if (i) {} - -#ifdef GENERATE_OUTDATED_DATA - if (i) {} -#endif } -#ifndef GENERATE_OUTDATED_DATA void no_data() { } -#endif int main(int argc, const char *argv[]) { no_usable_data(); Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -369,9 +369,13 @@ if (MainFile.empty()) MainFile = ""; Diags.Report(diag::warn_profile_data_unprofiled) << MainFile; - } else -Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing - << Mismatched; + } else { +if (Mismatched > 0) + Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Mismatched; + +if (Missing > 0) + Diags.Report(diag::warn_profile_data_missing) << Visited << Missing; + } } void CodeGenModule::Release() { Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -8938,8 +8938,13 @@ let CategoryName = "Instrumentation Issue" in { def warn_profile_data_out_of_date : Warning< "profile data may be out of date: of %0 function%s0, %1 %plural{1:has|:have}1" - " no data and %2 %plural{1:has|:have}2 mismatched data that will be ignored">, + " mismatched data that
[PATCH] D32601: [CodeGen][ObjC] Don't retain/release capture objects at block creation that are const-qualified
ahatanak created this revision. When a block captures an ObjC object pointer, clang emits a retain/release pair to prevent prematurely destroying the object the pointer points to before the block is called or copied. When the captured object pointer is const-qualified, we can avoid emitting the retain/release pair since the pointer variable cannot be modified in the scope in which the block literal is introduced. void test(const id x) { callee(^{ (void)x; }); } This patch implements that optimization. rdar://problem/28894510 https://reviews.llvm.org/D32601 Files: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGObjC.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenObjC/arc-blocks.m test/CodeGenObjC/arc-foreach.m Index: test/CodeGenObjC/arc-foreach.m === --- test/CodeGenObjC/arc-foreach.m +++ test/CodeGenObjC/arc-foreach.m @@ -63,11 +63,11 @@ // CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-LP64-NEXT: [[T1:%.*]] = load i8*, i8** [[X]] -// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) -// CHECK-LP64-NEXT: store i8* [[T2]], i8** [[T0]] -// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] -// CHECK-LP64: call void @use_block( -// CHECK-LP64-NEXT: call void @objc_storeStrong(i8** [[D0]], i8* null) +// CHECK-LP64-NEXT: store i8* [[T1]], i8** [[T0]] +// CHECK-LP64-NEXT: [[BLOCK1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] +// CHECK-LP64-NEXT: call void @use_block(void ()* [[BLOCK1]]) +// CHECK-LP64-NEXT: [[CAPTURE:%.*]] = load i8*, i8** [[D0]] +// CHECK-LP64: call void (...) @clang.arc.use(i8* [[CAPTURE]]) // CHECK-LP64: [[T0:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8* @@ -200,13 +200,10 @@ // CHECK-LP64: [[T0:%.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, [[TY]]* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, [[TY]]* }>* [[BLOCK]], i32 0, i32 5 // CHECK-LP64: [[BC:%.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, [[TY]]* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, [[TY]]* }>* [[BLOCK]], i32 0, i32 5 // CHECK-LP64: [[T1:%.*]] = load [[TY]]*, [[TY]]** [[SELF_ADDR]] -// CHECK-LP64: [[T2:%.*]] = bitcast [[TY]]* [[T1]] to i8* -// CHECK-LP64: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) -// CHECK-LP64: [[T4:%.*]] = bitcast i8* [[T3]] to [[TY]]* -// CHECK-LP64: store [[TY]]* [[T4]], [[TY]]** [[BC]] +// CHECK-LP64: store [[TY]]* [[T1]], [[TY]]** [[BC]] -// CHECK-LP64: [[T5:%.*]] = bitcast [[TY]]** [[T0]] to i8** -// CHECK-LP64: call void @objc_storeStrong(i8** [[T5]], i8* null) +// CHECK-LP64: [[T5:%.*]] = load [[TY]]*, [[TY]]** [[T0]] +// CHECK-LP64: call void (...) @clang.arc.use([[TY]]* [[T5]]) // CHECK-LP64: switch i32 {{%.*}}, label %[[UNREACHABLE:.*]] [ // CHECK-LP64-NEXT: i32 0, label %[[CLEANUP_CONT:.*]] // CHECK-LP64-NEXT: i32 2, label %[[FORCOLL_END:.*]] Index: test/CodeGenObjC/arc-blocks.m === --- test/CodeGenObjC/arc-blocks.m +++ test/CodeGenObjC/arc-blocks.m @@ -298,15 +298,11 @@ // CHECK: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]*, [[TEST8]]** [[SELF]], -// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8* -// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) -// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST8]]* -// CHECK-NEXT: store [[TEST8]]* [[T4]], [[TEST8]]** [[T0]] +// CHECK-NEXT: store %0* [[T1]], %0** [[T0]] // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to // CHECK: call void @test8_helper( -// CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]*, [[TEST8]]** [[D0]] -// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8* -// CHECK-NEXT: call void @objc_release(i8* [[T2]]) +// CHECK-NEXT: [[T2:%.*]] = load [[TEST8]]*, [[TEST8]]** [[D0]] +// CHECK-NEXT: call void (...) @clang.arc.use([[TEST8]]* [[T2]]) // CHECK: ret void extern void test8_helper(void (^)(void)); @@ -741,5 +737,31 @@ // CHECK-NEXT: ret void } +// CHECK-LABEL: define void @test20( +// CHECK: [[XADDR:%.*]] = alloca i8* +// CHECK-NEXT: [[BLOCK:%.*]] = alloca <[[BLOCKTY:.*]]> +// CHECK-NEXT: [[RETAINEDX:%.*]] = call i8* @objc_retain(i8* %{{.*}}) +// CHECK-NEXT: store i8* [[RETAINEDX]], i8** [[XADDR]] +// CHECK-NEXT: [[CAPTUREFIELD:%.*]] = getelementptr inbounds <[[BLOCKTY]]>, <[[BLOCKTY]]>* [[BLOCK]], i32 0, i32 5 +// CHECK: [[BLOCKCAPTURED:%.*]] = getelementptr inbounds <[[B
[PATCH] D32601: [CodeGen][ObjC] Don't retain/release capture objects at block creation that are const-qualified
ahatanak added a comment. There is a comment in test/CodeGenObjC/arc-foreach.m that states the variable introduced by fast enumeration should be retained, but I don't think that is needed? https://reviews.llvm.org/D32601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
aprantl created this revision. Herald added subscribers: mehdi_amini, mgorny. Green dragon had a green stage2 modules bot for a long time now[1] and it is time to retire it and make a modules build the default for Apple-style stage2 builds. This patch turns on `LLVM_ENABLE_MODULES` and switches the debug info generation from `-gline-tables-only` to `-g` since full debug info does no longer cause any memory issues even for full LTO builds [2]. [1] http://green.lab.llvm.org/green/job/clang-stage2-cmake-modulesRDA_build/ [2] http://llvm.org/devmtg/2015-10/#talk19 rdar://problem/28672159 Repository: rL LLVM https://reviews.llvm.org/D32603 Files: cmake/caches/Apple-stage2.cmake Index: cmake/caches/Apple-stage2.cmake === --- cmake/caches/Apple-stage2.cmake +++ cmake/caches/Apple-stage2.cmake @@ -13,6 +13,7 @@ set(CMAKE_MACOSX_RPATH ON CACHE BOOL "") set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") @@ -28,8 +29,8 @@ set(LLVM_ENABLE_LTO ON CACHE BOOL "") set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") Index: cmake/caches/Apple-stage2.cmake === --- cmake/caches/Apple-stage2.cmake +++ cmake/caches/Apple-stage2.cmake @@ -13,6 +13,7 @@ set(CMAKE_MACOSX_RPATH ON CACHE BOOL "") set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") @@ -28,8 +29,8 @@ set(LLVM_ENABLE_LTO ON CACHE BOOL "") set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32604: CMakeLists: Deprecate using llvm-config to find llvm install path
tstellar created this revision. You can still specify an llvm-config to use by configuring with -DLLVM_CONFIG=/path/to/llvm/config, but this method is now deprecated and may be remove. Users should be setting CMAKE_PREFIX_PATH to the install prefix for their llvm install. Unless you are using the system llvm in which case, cmake should be able to automatically find the install prefix. https://reviews.llvm.org/D32604 Files: CMakeLists.txt Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -5,18 +5,12 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) project(Clang) + set(LLVM_CONFIG "" CACHE PATH "DEPRECATED: path to llvm-config. You should set CMAKE_PREFIX_PATH to the install prefix for llvm") # Rely on llvm-config. set(CONFIG_OUTPUT) - find_program(LLVM_CONFIG "llvm-config") if(LLVM_CONFIG) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") set(CONFIG_COMMAND ${LLVM_CONFIG} - "--assertion-mode" - "--bindir" - "--libdir" - "--includedir" - "--prefix" - "--src-root" "--cmakedir") execute_process( COMMAND ${CONFIG_COMMAND} @@ -32,41 +26,21 @@ message(STATUS "${CONFIG_COMMAND_STR}") message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") endif() - else() -message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}") - endif() - - list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) - list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) - list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) - list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) - list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) - list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) - list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) - - if(NOT MSVC_IDE) -set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} - CACHE BOOL "Enable assertions") -# Assertions should follow llvm-config's. -mark_as_advanced(LLVM_ENABLE_ASSERTIONS) +set(LLVM_CONFIG_CMAKE_PATH ${CONFIG_OUTPUT}) +# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. +# CMake assumes slashes as PATH. +file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) endif() - set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin") - set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib") - set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") - - # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. - # CMake assumes slashes as PATH. - file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH) - - find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} -NO_DEFAULT_PATH) - find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}") + message(STATUS "LLVM install found at ${LLVM_DIR}") list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR}) set(LLVM_MAIN_INCLUDE_DIR ${LLVM_BINARY_DIR}/include) + find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR} +NO_DEFAULT_PATH) + # They are used as destination of target generators. set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}) Index: CMakeLists.txt === --- CMakeLists.txt +++ CMakeLists.txt @@ -5,18 +5,12 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) project(Clang) + set(LLVM_CONFIG "" CACHE PATH "DEPRECATED: path to llvm-config. You should set CMAKE_PREFIX_PATH to the install prefix for llvm") # Rely on llvm-config. set(CONFIG_OUTPUT) - find_program(LLVM_CONFIG "llvm-config") if(LLVM_CONFIG) message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") set(CONFIG_COMMAND ${LLVM_CONFIG} - "--assertion-mode" - "--bindir" - "--libdir" - "--includedir" - "--prefix" - "--src-root" "--cmakedir") execute_process( COMMAND ${CONFIG_COMMAND} @@ -32,41 +26,21 @@ message(STATUS "${CONFIG_COMMAND_STR}") message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") endif() - else() -message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}") - endif() - - list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS) - list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR) - list(GET CONFIG_OUTPUT 2 LIBRARY_DIR) - list(GET CONFIG_OUTPUT 3 INCLUDE_DIR) - list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT) - list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR) - list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH) - - if(NOT MSVC_IDE) -set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS} - CACHE BOOL "Enable assertions") -# Assertions should follow llvm-config's. -mark_as_advanced(LLVM_ENABLE_ASSERTIONS) +set(LLVM_CONFIG_CMAKE_PATH ${CONFIG_OUTPUT}) +# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes. +# CMake assumes slashes as PATH. +file(TO_CMAKE_PATH ${LLVM_CONFIG
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
aprantl added a comment. @beanz: Would sorting all these set() commands alphabetically break anything? Repository: rL LLVM https://reviews.llvm.org/D32603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
beanz accepted this revision. beanz added a comment. This revision is now accepted and ready to land. SWEET! this is great to see! One small comment inline, otherwise LGTM. Comment at: cmake/caches/Apple-stage2.cmake:33 +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") Alternatively you can just remove these two lines because you're just setting this to the default value. It was only overridden to set line-tables-only. Repository: rL LLVM https://reviews.llvm.org/D32603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
dexonsmith added a comment. (Both changes SGTM, but I doubt you're looking for my advice on the CMake logic.) Comment at: cmake/caches/Apple-stage2.cmake:31-32 set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") It would simplify fallout, reverting, triaging issues, understanding compile time impact, etc., if the debug info change was left for a separate commit (maybe waiting a day). Thoughts? https://reviews.llvm.org/D32603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
aprantl updated this revision to Diff 96952. aprantl added a comment. Address review feedback. https://reviews.llvm.org/D32603 Files: cmake/caches/Apple-stage2.cmake Index: cmake/caches/Apple-stage2.cmake === --- cmake/caches/Apple-stage2.cmake +++ cmake/caches/Apple-stage2.cmake @@ -13,6 +13,7 @@ set(CMAKE_MACOSX_RPATH ON CACHE BOOL "") set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") @@ -28,8 +29,6 @@ set(LLVM_ENABLE_LTO ON CACHE BOOL "") set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") Index: cmake/caches/Apple-stage2.cmake === --- cmake/caches/Apple-stage2.cmake +++ cmake/caches/Apple-stage2.cmake @@ -13,6 +13,7 @@ set(CMAKE_MACOSX_RPATH ON CACHE BOOL "") set(LLVM_ENABLE_ZLIB ON CACHE BOOL "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +set(LLVM_ENABLE_MODULES ON CACHE BOOL "") set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "") set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "") set(BUG_REPORT_URL "http://developer.apple.com/bugreporter/"; CACHE STRING "") @@ -28,8 +29,6 @@ set(LLVM_ENABLE_LTO ON CACHE BOOL "") set(CMAKE_C_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fno-stack-protector -fno-common -Wno-profile-instr-unprofiled" CACHE STRING "") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "") set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32329: [libc++abi] Disable libc++ extern templates project-wide
smeenai added a comment. Ping. https://reviews.llvm.org/D32329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25113: [Sema] Don't display an invalid redefinition error when dealing with a redefinition of a function whose previous definition was typo-corrected
v.g.vassilev added a comment. LGTM! Repository: rL LLVM https://reviews.llvm.org/D25113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301573 - Added an Importer test for in-class member initializers.
Author: spyffe Date: Thu Apr 27 13:10:29 2017 New Revision: 301573 URL: http://llvm.org/viewvc/llvm-project?rev=301573&view=rev Log: Added an Importer test for in-class member initializers. Added: cfe/trunk/test/Import/in-class-initializer/ cfe/trunk/test/Import/in-class-initializer/Inputs/ cfe/trunk/test/Import/in-class-initializer/Inputs/S.cpp cfe/trunk/test/Import/in-class-initializer/test.cpp Added: cfe/trunk/test/Import/in-class-initializer/Inputs/S.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/in-class-initializer/Inputs/S.cpp?rev=301573&view=auto == --- cfe/trunk/test/Import/in-class-initializer/Inputs/S.cpp (added) +++ cfe/trunk/test/Import/in-class-initializer/Inputs/S.cpp Thu Apr 27 13:10:29 2017 @@ -0,0 +1,3 @@ +struct S { + int a = 3; +}; Added: cfe/trunk/test/Import/in-class-initializer/test.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/in-class-initializer/test.cpp?rev=301573&view=auto == --- cfe/trunk/test/Import/in-class-initializer/test.cpp (added) +++ cfe/trunk/test/Import/in-class-initializer/test.cpp Thu Apr 27 13:10:29 2017 @@ -0,0 +1,5 @@ +// RUN: clang-import-test -import %S/Inputs/S.cpp -expression %s +void expr() { + S MyS; + int b = MyS.a + MyS.a; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32603: Build the Apple-style stage2 with modules and full debug info
aprantl added a comment. > It would simplify fallout, reverting, triaging issues, understanding compile > time impact, etc., if the debug info change was left for a separate commit > (maybe waiting a day). Thoughts? Sounds like a good plan. https://reviews.llvm.org/D32603 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32601: [CodeGen][ObjC] Don't retain/release capture objects at block creation that are const-qualified
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. I agree, this seems reasonable. LGTM. https://reviews.llvm.org/D32601 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32613: [Driver] Update Fuchsia driver path handling
phosek created this revision. Several improvements to the Fuchsia driver: - Search for C++ library headers and libraries in directories that are part of the toolchain distribution rather than sysroot. - Use LLVM support utlities to construct paths to make sure the driver is also usable on Windows for cross-compiling. - Change the driver to inherit directly from ToolChain rather than Generic_GCC since we don't need any of the GCC related multilib logic. Repository: rL LLVM https://reviews.llvm.org/D32613 Files: lib/Driver/ToolChains/Fuchsia.cpp lib/Driver/ToolChains/Fuchsia.h test/Driver/fuchsia.cpp Index: test/Driver/fuchsia.cpp === --- test/Driver/fuchsia.cpp +++ test/Driver/fuchsia.cpp @@ -3,7 +3,7 @@ // CHECK: {{.*}}clang{{.*}}" "-cc1" // CHECK: "-fuse-init-array" // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]" -// CHECK: "-internal-isystem" "[[SYSROOT]]{{/|}}include{{/|}}c++{{/|}}v1" +// CHECK: "-internal-isystem" "{{.*[/\\]}}x86_64-unknown-fuchsia{{/|}}include{{/|}}c++{{/|}}v1" // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include" // CHECK: {{.*}}lld{{.*}}" "-flavor" "gnu" // CHECK: "--sysroot=[[SYSROOT]]" Index: lib/Driver/ToolChains/Fuchsia.h === --- lib/Driver/ToolChains/Fuchsia.h +++ lib/Driver/ToolChains/Fuchsia.h @@ -35,14 +35,22 @@ namespace toolchains { -class LLVM_LIBRARY_VISIBILITY Fuchsia : public Generic_ELF { +class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain { public: Fuchsia(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); - bool isPIEDefault() const override { return true; } bool HasNativeLLVMSupport() const override { return true; } bool IsIntegratedAssemblerDefault() const override { return true; } + RuntimeLibType GetDefaultRuntimeLibType() const override { +return ToolChain::RLT_CompilerRT; + } + CXXStdlibType GetDefaultCXXStdlibType() const override { +return ToolChain::CST_Libcxx; + } + bool isPICDefault() const override { return false; } + bool isPIEDefault() const override { return true; } + bool isPICDefaultForced() const override { return false; } llvm::DebuggerKind getDefaultDebuggerTuning() const override { return llvm::DebuggerKind::GDB; } @@ -59,16 +67,17 @@ void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - std::string findLibCxxIncludePath() const override; + void + AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override; const char *getDefaultLinker() const override { return "lld"; } protected: - Tool *buildAssembler() const override; Tool *buildLinker() const override; }; Index: lib/Driver/ToolChains/Fuchsia.cpp === --- lib/Driver/ToolChains/Fuchsia.cpp +++ lib/Driver/ToolChains/Fuchsia.cpp @@ -133,14 +133,17 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) -: Generic_ELF(D, Triple, Args) { - - getFilePaths().push_back(D.SysRoot + "/lib"); - getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia"); -} - -Tool *Fuchsia::buildAssembler() const { - return new tools::gnutools::Assembler(*this); +: ToolChain(D, Triple, Args) { + SmallString<128> P(getDriver().Dir); + llvm::sys::path::append(P, "..", getTriple().str()); + llvm::sys::path::append(P, "lib"); + getFilePaths().push_back(P.str()); + + if (!D.SysRoot.empty()) { +SmallString<128> P(D.SysRoot); +llvm::sys::path::append(P, "lib"); +getFilePaths().push_back(P.str()); + } } Tool *Fuchsia::buildLinker() const { @@ -207,19 +210,45 @@ return; } - addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include"); + if (!D.SysRoot.empty()) { +SmallString<128> P(D.SysRoot); +llvm::sys::path::append(P, "include"); +addExternCSystemInclude(DriverArgs, CC1Args, P.str()); + } } -std::string Fuchsia::findLibCxxIncludePath() const { - return getDriver().SysRoot + "/include/c++/v1"; +void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + if (DriverArgs.hasArg(options::OPT_nostdlibinc) || + DriverArgs.hasArg(options::OPT_nostdincxx)) +return; + + switch (GetCXXStdlibType(DriverArgs)) { + case ToolChain::CST_Libcxx: { +SmallString<128> P(getDriver().Dir); +llvm::sys::path::append(P, "..", getTriple().str()); +llvm::sys::path::append(P, "include", "c++", "v1"); +addSystemInclude(DriverArgs, CC1Ar
[PATCH] D32395: [clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls
Prazek accepted this revision. Prazek added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D32395 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301585 - libclang: remove unused variable.
Author: tnorthover Date: Thu Apr 27 15:22:40 2017 New Revision: 301585 URL: http://llvm.org/viewvc/llvm-project?rev=301585&view=rev Log: libclang: remove unused variable. Modified: cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/tools/libclang/CXCursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=301585&r1=301584&r2=301585&view=diff == --- cfe/trunk/tools/libclang/CXCursor.cpp (original) +++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Apr 27 15:22:40 2017 @@ -1565,8 +1565,7 @@ CXType clang_Cursor_getReceiverType(CXCu ME = dyn_cast_or_null(CE->getCallee()); if (ME) { -if (const CXXMethodDecl * - MD = dyn_cast_or_null(ME->getMemberDecl())) { +if (dyn_cast_or_null(ME->getMemberDecl())) { auto receiverTy = ME->getBase()->IgnoreImpCasts()->getType(); return cxtype::MakeCXType(receiverTy, TU); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.
aprantl accepted this revision. aprantl added a comment. This revision now requires changes to proceed. I think I may haved screwed up the phabricator process for this one. This landed as r300523. https://reviews.llvm.org/D31440 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301592 - Preprocessor: Suppress -Wnonportable-include-path for header maps
Author: dexonsmith Date: Thu Apr 27 16:41:51 2017 New Revision: 301592 URL: http://llvm.org/viewvc/llvm-project?rev=301592&view=rev Log: Preprocessor: Suppress -Wnonportable-include-path for header maps If a file search involves a header map, suppress -Wnonportable-include-path. It's firing lots of false positives for framework authors internally, and it's not trivial to fix. Consider a framework called "Foo" with a main (installed) framework header "Foo/Foo.h". It's atypical for "Foo.h" to actually live inside a directory called "Foo" in the source repository. Instead, the build system generates a header map while building the framework. If Foo.h lives at the top-level of the source repository (common), and the git repo is called ssh://some.url/foo.git, then the header map will have something like: Foo/Foo.h -> /Users/myname/code/foo/Foo.h where "/Users/myname/code/foo" is the clone of ssh://some.url/foo.git. After #import , the current implementation of -Wnonportable-include-path will falsely assume that Foo.h was found in a nonportable way, because of the name of the git clone (.../foo/Foo.h). However, that directory name was not involved in the header search at all. This commit adds an extra parameter to Preprocessor::LookupFile and HeaderSearch::LookupFile to track if the search used a header map, making it easy to suppress the warning. Longer term, once we find a way to avoid the false positive, we should turn the warning back on. rdar://problem/28863903 Added: cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/ cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap (with props) cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/ cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/ cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Foo.h cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Lex/PPDirectives.cpp cfe/trunk/lib/Lex/PPMacroExpansion.cpp cfe/trunk/lib/Lex/Pragma.cpp Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=301592&r1=301591&r2=301592&view=diff == --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Apr 27 16:41:51 2017 @@ -375,13 +375,16 @@ public: /// \param SuggestedModule If non-null, and the file found is semantically /// part of a known module, this will be set to the module that should /// be imported instead of preprocessing/parsing the file found. + /// + /// \param IsMapped If non-null, and the search involved header maps, set to + /// true. const FileEntry *LookupFile( StringRef Filename, SourceLocation IncludeLoc, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, ArrayRef> Includers, SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, - bool SkipCache = false, bool BuildSystemModule = false); + bool *IsMapped, bool SkipCache = false, bool BuildSystemModule = false); /// \brief Look up a subframework for the specified \#include file. /// Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=301592&r1=301591&r2=301592&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Apr 27 16:41:51 2017 @@ -1686,7 +1686,7 @@ public: SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath, ModuleMap::KnownHeader *SuggestedModule, - bool SkipCache = false); + bool *IsMapped, bool SkipCache = false); /// \brief Get the DirectoryLookup structure used to find the current /// FileEntry, if CurLexer is non-null and if applicable. Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=301592&r1=301591&r2=301592&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Apr 27 16:41:51 2017 @@ -858,7 +858,8 @@ bool CompilerInstance::InitializeSourceM
[PATCH] D32263: Preprocessor: Suppress -Wnonportable-include-path for header maps
dexonsmith closed this revision. dexonsmith added a comment. Fixed in r301592. https://reviews.llvm.org/D32263 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM lab network glitch
Some of builders lost connection with master recently due to network glitch. Thank you for understanding. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301593 - Headers: Make the type of SIZE_MAX the same as size_t
Author: dexonsmith Date: Thu Apr 27 16:49:45 2017 New Revision: 301593 URL: http://llvm.org/viewvc/llvm-project?rev=301593&view=rev Log: Headers: Make the type of SIZE_MAX the same as size_t size_t is usually defined as unsigned long, but on 64-bit platforms, stdint.h currently defines SIZE_MAX using "ull" (unsigned long long). Although this is the same width, it doesn't necessarily have the same alignment or calling convention. It also triggers printf warnings when using the format flag "%zu" to print SIZE_MAX. This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and provides similar fixes for the other integers: - INTPTR_MIN - INTPTR_MAX - UINTPTR_MAX - PTRDIFF_MIN - PTRDIFF_MAX - INTMAX_MIN - INTMAX_MAX - UINTMAX_MAX - INTMAX_C() - UINTMAX_C() ... and fixes the typedefs for intptr_t and uintptr_t to use __INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively reverting r89224, r89226, and r89237 (r89221 already having been effectively reverted). We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and __UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the per-target CHECK lines in this commit since those might serve their own purpose. rdar://problem/11811377 Added: cfe/trunk/test/Headers/stdint-typeof-MINMAX.cpp Modified: cfe/trunk/lib/Headers/stdint.h cfe/trunk/test/Preprocessor/stdint.c Modified: cfe/trunk/lib/Headers/stdint.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=301593&r1=301592&r2=301593&view=diff == --- cfe/trunk/lib/Headers/stdint.h (original) +++ cfe/trunk/lib/Headers/stdint.h Thu Apr 27 16:49:45 2017 @@ -255,19 +255,16 @@ typedef __uint_least8_t uint_fast8_t; */ #define __stdint_join3(a,b,c) a ## b ## c -#define __intn_t(n) __stdint_join3( int, n, _t) -#define __uintn_t(n) __stdint_join3(uint, n, _t) - #ifndef _INTPTR_T #ifndef __intptr_t_defined -typedef __intn_t(__INTPTR_WIDTH__) intptr_t; +typedef __INTPTR_TYPE__ intptr_t; #define __intptr_t_defined #define _INTPTR_T #endif #endif #ifndef _UINTPTR_T -typedef __uintn_t(__INTPTR_WIDTH__) uintptr_t; +typedef __UINTPTR_TYPE__ uintptr_t; #define _UINTPTR_T #endif @@ -659,12 +656,12 @@ typedef __UINTMAX_TYPE__ uintmax_t; /* C99 7.18.2.4 Limits of integer types capable of holding object pointers. */ /* C99 7.18.3 Limits of other integer types. */ -#define INTPTR_MIN __INTN_MIN(__INTPTR_WIDTH__) -#define INTPTR_MAX __INTN_MAX(__INTPTR_WIDTH__) -#define UINTPTR_MAX __UINTN_MAX(__INTPTR_WIDTH__) -#define PTRDIFF_MIN __INTN_MIN(__PTRDIFF_WIDTH__) -#define PTRDIFF_MAX __INTN_MAX(__PTRDIFF_WIDTH__) -#defineSIZE_MAX __UINTN_MAX(__SIZE_WIDTH__) +#define INTPTR_MIN (-__INTPTR_MAX__-1) +#define INTPTR_MAX__INTPTR_MAX__ +#define UINTPTR_MAX __UINTPTR_MAX__ +#define PTRDIFF_MIN (-__PTRDIFF_MAX__-1) +#define PTRDIFF_MAX __PTRDIFF_MAX__ +#defineSIZE_MAX __SIZE_MAX__ /* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__ * is enabled. */ @@ -673,9 +670,9 @@ typedef __UINTMAX_TYPE__ uintmax_t; #endif /* C99 7.18.2.5 Limits of greatest-width integer types. */ -#define INTMAX_MIN __INTN_MIN(__INTMAX_WIDTH__) -#define INTMAX_MAX __INTN_MAX(__INTMAX_WIDTH__) -#define UINTMAX_MAX __UINTN_MAX(__INTMAX_WIDTH__) +#define INTMAX_MIN (-__INTMAX_MAX__-1) +#define INTMAX_MAX __INTMAX_MAX__ +#define UINTMAX_MAX __UINTMAX_MAX__ /* C99 7.18.3 Limits of other integer types. */ #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__) @@ -700,8 +697,8 @@ typedef __UINTMAX_TYPE__ uintmax_t; #endif /* 7.18.4.2 Macros for greatest-width integer constants. */ -#define INTMAX_C(v) __INTN_C(__INTMAX_WIDTH__, v) -#define UINTMAX_C(v) __UINTN_C(__INTMAX_WIDTH__, v) +#define INTMAX_C(v) __int_c(v, __INTMAX_C_SUFFIX__) +#define UINTMAX_C(v) __int_c(v, __UINTMAX_C_SUFFIX__) #endif /* __STDC_HOSTED__ */ #endif /* __CLANG_STDINT_H */ Added: cfe/trunk/test/Headers/stdint-typeof-MINMAX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/stdint-typeof-MINMAX.cpp?rev=301593&view=auto == --- cfe/trunk/test/Headers/stdint-typeof-MINMAX.cpp (added) +++ cfe/trunk/test/Headers/stdint-typeof-MINMAX.cpp Thu Apr 27 16:49:45 2017 @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=aarch64-none-none +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=arm-none-none +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=i386-none-none +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=mips-none-none +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=mips64-none-none +// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=msp430-none-none +// RUN: %clang_cc1 %s -ffreestanding
[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t
dexonsmith accepted this revision. dexonsmith added a comment. Thanks for the reviews! Committed in r301593. https://reviews.llvm.org/D31856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t
dexonsmith added a comment. rsmith: I just noticed you still have a red "X" here (since Phab won't let me "close"). I think I addressed your comments, but let me know if you want me to revert until you have time to look. https://reviews.llvm.org/D31856 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301596 - [Modules] Refactor logic for incomplete umbrella warnings. NFC
Author: bruno Date: Thu Apr 27 17:29:10 2017 New Revision: 301596 URL: http://llvm.org/viewvc/llvm-project?rev=301596&view=rev Log: [Modules] Refactor logic for incomplete umbrella warnings. NFC Modified: cfe/trunk/include/clang/Lex/Preprocessor.h cfe/trunk/lib/Lex/PPLexerChange.cpp Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=301596&r1=301595&r2=301596&view=diff == --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Apr 27 17:29:10 2017 @@ -1602,6 +1602,7 @@ private: *Ident_AbnormalTermination; const char *getCurLexerEndPos(); + void diagnoseMissingHeaderInUmbrellaDir(const Module &Mod); public: void PoisonSEHIdentifiers(bool Poison = true); // Borland Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301596&r1=301595&r2=301596&view=diff == --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:10 2017 @@ -287,6 +287,40 @@ const char *Preprocessor::getCurLexerEnd return EndPos; } +void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { + assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); + SourceLocation StartLoc = + SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()); + if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc)) +return; + + ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap(); + const DirectoryEntry *Dir = Mod.getUmbrellaDir().Entry; + vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem(); + std::error_code EC; + for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), End; + Entry != End && !EC; Entry.increment(EC)) { +using llvm::StringSwitch; + +// Check whether this entry has an extension typically associated with +// headers. +if (!StringSwitch(llvm::sys::path::extension(Entry->getName())) + .Cases(".h", ".H", ".hh", ".hpp", true) + .Default(false)) + continue; + +if (const FileEntry *Header = getFileManager().getFile(Entry->getName())) + if (!getSourceManager().hasFileInfo(Header)) { +if (!ModMap.isHeaderInUnavailableModule(Header)) { + // Find the relative path that would access this header. + SmallString<128> RelativePath; + computeRelativePath(FileMgr, Dir, Header, RelativePath); + Diag(StartLoc, diag::warn_uncovered_module_header) + << Mod.getFullModuleName() << RelativePath; +} + } + } +} /// HandleEndOfFile - This callback is invoked when the lexer hits the end of /// the current file. This either returns the EOF token or pops a level off @@ -475,43 +509,8 @@ bool Preprocessor::HandleEndOfFile(Token // If we are building a module that has an umbrella header, make sure that // each of the headers within the directory covered by the umbrella header // was actually included by the umbrella header. - if (Module *Mod = getCurrentModule()) { -if (Mod->getUmbrellaHeader()) { - SourceLocation StartLoc -= SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID()); - - if (!getDiagnostics().isIgnored(diag::warn_uncovered_module_header, - StartLoc)) { -ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap(); -const DirectoryEntry *Dir = Mod->getUmbrellaDir().Entry; -vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem(); -std::error_code EC; -for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), End; - Entry != End && !EC; Entry.increment(EC)) { - using llvm::StringSwitch; - - // Check whether this entry has an extension typically associated with - // headers. - if (!StringSwitch(llvm::sys::path::extension(Entry->getName())) - .Cases(".h", ".H", ".hh", ".hpp", true) - .Default(false)) -continue; - - if (const FileEntry *Header = - getFileManager().getFile(Entry->getName())) -if (!getSourceManager().hasFileInfo(Header)) { - if (!ModMap.isHeaderInUnavailableModule(Header)) { -// Find the relative path that would access this header. -SmallString<128> RelativePath; -computeRelativePath(FileMgr, Dir, Header, RelativePath); -Diag(StartLoc, diag::warn_uncovered_module_header) - << Mod->getFullModuleName() << RelativePath; - } -} -} - } -} - } + if (Module *Mod = getCurrentModule
r301597 - [Modules] Improve diagnostics for incomplete umbrella
Author: bruno Date: Thu Apr 27 17:29:14 2017 New Revision: 301597 URL: http://llvm.org/viewvc/llvm-project?rev=301597&view=rev Log: [Modules] Improve diagnostics for incomplete umbrella One of the -Wincomplete-umbrella warnings diagnoses when a header is present in the directory but it's not present in the umbrella header. Currently, this warning only happens on top level modules; any submodule using an umbrella header does not get this warning. Fix that by also considering the submodules. Differential Revision: https://reviews.llvm.org/D32576 rdar://problem/22623686 Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h cfe/trunk/test/Modules/incomplete-umbrella.m Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597&r1=301596&r2=301597&view=diff == --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017 @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd return EndPos; } +static void collectAllSubModulesWithUmbrellaHeader( +const Module &Mod, SmallVectorImpl &SubMods) { + if (Mod.getUmbrellaHeader()) +SubMods.push_back(&Mod); + for (auto *M : Mod.submodules()) +collectAllSubModulesWithUmbrellaHeader(*M, SubMods); +} + void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); SourceLocation StartLoc = @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token } // If we are building a module that has an umbrella header, make sure that - // each of the headers within the directory covered by the umbrella header - // was actually included by the umbrella header. - if (Module *Mod = getCurrentModule()) -diagnoseMissingHeaderInUmbrellaDir(*Mod); + // each of the headers within the directory, including all submodules, is + // covered by the umbrella header was actually included by the umbrella + // header. + if (Module *Mod = getCurrentModule()) { +llvm::SmallVector AllMods; +collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods); +for (auto *M : AllMods) + diagnoseMissingHeaderInUmbrellaDir(*M); + } return true; } Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597&view=auto == --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h (added) +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h Thu Apr 27 17:29:14 2017 @@ -0,0 +1 @@ +#define BAR_PUBLIC 1 Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h?rev=301597&view=auto == --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h (added) +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h Thu Apr 27 17:29:14 2017 @@ -0,0 +1 @@ +// FooPublic.h Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap?rev=301597&view=auto == --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap (added) +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap Thu Apr 27 17:29:14 2017 @@ -0,0 +1,5 @@ +framework module Foo { +umbrella header "FooPublic.h" +requir
[PATCH] D32576: [Modules] Improve diagnostics for incomplete umbrella
This revision was automatically updated to reflect the committed changes. Closed by commit rL301597: [Modules] Improve diagnostics for incomplete umbrella (authored by bruno). Changed prior to commit: https://reviews.llvm.org/D32576?vs=96857&id=97007#toc Repository: rL LLVM https://reviews.llvm.org/D32576 Files: cfe/trunk/lib/Lex/PPLexerChange.cpp cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h cfe/trunk/test/Modules/incomplete-umbrella.m Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h @@ -0,0 +1 @@ +#define BAR_PUBLIC 1 Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h @@ -0,0 +1 @@ +// FooPublic.h Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap @@ -0,0 +1,5 @@ +framework module Foo { +umbrella header "FooPublic.h" +requires objc +export * +} Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap @@ -0,0 +1,5 @@ +explicit module Foo.Private { +umbrella header "Foo.h" +requires objc +export * +} Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h @@ -0,0 +1 @@ +#define BAZ_PRIVATE 1 Index: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h === --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h +++ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h @@ -0,0 +1 @@ +// Foo.h Index: cfe/trunk/test/Modules/incomplete-umbrella.m === --- cfe/trunk/test/Modules/incomplete-umbrella.m +++ cfe/trunk/test/Modules/incomplete-umbrella.m @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/incomplete-umbrella -fsyntax-only %s 2>&1 | FileCheck %s + +#import +#import +#import +@import Foo.Private; + +// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h' +// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h' +int foo() { + int a = BAR_PUBLIC; + int b = BAZ_PRIVATE; + return 0; +} Index: cfe/trunk/lib/Lex/PPLexerChange.cpp === --- cfe/trunk/lib/Lex/PPLexerChange.cpp +++ cfe/trunk/lib/Lex/PPLexerChange.cpp @@ -287,6 +287,14 @@ return EndPos; } +static void collectAllSubModulesWithUmbrellaHeader( +const Module &Mod, SmallVectorImpl &SubMods) { + if (Mod.getUmbrellaHeader()) +SubMods.push_back(&Mod); + for (auto *M : Mod.submodules()) +collectAllSubModulesWithUmbrellaHeader(*M, SubMods); +} + void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); SourceLocation StartLoc = @@ -507,10 +515,15 @@ } // If we are building a module that has an umbrella header, make sure that - // each of the headers within the directory covered by the umbrella header - // was actually included by the umbrella header. - if (Module *Mod = ge
[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags
yamaguchi updated this revision to Diff 97013. yamaguchi added a comment. show warnings with -M and -MD https://reviews.llvm.org/D32341 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/m_and_mm.c Index: test/Driver/m_and_mm.c === --- test/Driver/m_and_mm.c +++ test/Driver/m_and_mm.c @@ -1,3 +1,7 @@ // RUN: %clang -### \ // RUN: -M -MM %s 2> %t // RUN: not grep '"-sys-header-deps"' %t + +#warning "This warning shouldn't show up with -M and -MM" +// RUN: %clang -M -MM %s 2> %t +// RUN: not grep "warning" %t Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -980,6 +980,9 @@ DepTarget = Args.MakeArgString(llvm::sys::path::filename(P)); } + if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) { +CmdArgs.push_back("-w"); + } CmdArgs.push_back("-MT"); SmallString<128> Quoted; QuoteTarget(DepTarget, Quoted); Index: test/Driver/m_and_mm.c === --- test/Driver/m_and_mm.c +++ test/Driver/m_and_mm.c @@ -1,3 +1,7 @@ // RUN: %clang -### \ // RUN: -M -MM %s 2> %t // RUN: not grep '"-sys-header-deps"' %t + +#warning "This warning shouldn't show up with -M and -MM" +// RUN: %clang -M -MM %s 2> %t +// RUN: not grep "warning" %t Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -980,6 +980,9 @@ DepTarget = Args.MakeArgString(llvm::sys::path::filename(P)); } + if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) { +CmdArgs.push_back("-w"); + } CmdArgs.push_back("-MT"); SmallString<128> Quoted; QuoteTarget(DepTarget, Quoted); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32595: CMakeLists: Don't set LLVM_MAIN_SRC_DIR when building stand-alone clang
chapuni added a comment. Let me know steps for testing that you suppose. I guess; - Use installed version of lit via virtualenv. - Use out-of-tree version of gtest. - Use another build tree to use FileCheck &c. I know the clause CLANG_BUILT_STANDALONE would be made simpler if we could abandon testing in standalone build. https://reviews.llvm.org/D32595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags
yamaguchi updated this revision to Diff 97019. yamaguchi added a comment. Add testcase https://reviews.llvm.org/D32341 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/m_and_mm.c Index: test/Driver/m_and_mm.c === --- test/Driver/m_and_mm.c +++ test/Driver/m_and_mm.c @@ -1,3 +1,15 @@ // RUN: %clang -### \ // RUN: -M -MM %s 2> %t // RUN: not grep '"-sys-header-deps"' %t + +// RUN: %clang -M -MM %s 2> %t +// RUN: not grep "warning" %t + +// RUN: %clang -MMD -MD %s 2> %t +// RUN: grep "warning" %t + +#warning "This warning shouldn't show up with -M and -MM" +int main (void) +{ +return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -980,6 +980,9 @@ DepTarget = Args.MakeArgString(llvm::sys::path::filename(P)); } + if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) { +CmdArgs.push_back("-w"); + } CmdArgs.push_back("-MT"); SmallString<128> Quoted; QuoteTarget(DepTarget, Quoted); Index: test/Driver/m_and_mm.c === --- test/Driver/m_and_mm.c +++ test/Driver/m_and_mm.c @@ -1,3 +1,15 @@ // RUN: %clang -### \ // RUN: -M -MM %s 2> %t // RUN: not grep '"-sys-header-deps"' %t + +// RUN: %clang -M -MM %s 2> %t +// RUN: not grep "warning" %t + +// RUN: %clang -MMD -MD %s 2> %t +// RUN: grep "warning" %t + +#warning "This warning shouldn't show up with -M and -MM" +int main (void) +{ +return 0; +} Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -980,6 +980,9 @@ DepTarget = Args.MakeArgString(llvm::sys::path::filename(P)); } + if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) { +CmdArgs.push_back("-w"); + } CmdArgs.push_back("-MT"); SmallString<128> Quoted; QuoteTarget(DepTarget, Quoted); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32595: CMakeLists: Don't set LLVM_MAIN_SRC_DIR when building stand-alone clang
tstellar added a comment. In https://reviews.llvm.org/D32595#740222, @chapuni wrote: > Let me know steps for testing that you suppose. > I guess; > > - Use installed version of lit via virtualenv. Not necessarily via virtualenv, either by installing the lit pypi package or using a distro package: https://admin.fedoraproject.org/pkgdb/package/rpms/python-lit/ > - Use out-of-tree version of gtest. I don't really have a plan for gtest, but this already doesn't work for out of tree builds (unless you have the source tree on your system, but I don't think we should be relying on this). > - Use another build tree to use FileCheck &c. These could come from a build tree or could be installed on this system. > I know the clause CLANG_BUILT_STANDALONE would be made simpler if we could > abandon testing in standalone build. https://reviews.llvm.org/D32595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301601 - Use a consistent style. NFC
Author: gbiv Date: Thu Apr 27 18:59:45 2017 New Revision: 301601 URL: http://llvm.org/viewvc/llvm-project?rev=301601&view=rev Log: Use a consistent style. NFC Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=301601&r1=301600&r2=301601&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr 27 18:59:45 2017 @@ -6431,14 +6431,13 @@ static QualType checkConditionalPointerC return S.Context .getQualifiedType(CompositeTy.getUnqualifiedType(), CompositeQuals) .withCVRQualifiers(MergedCVRQual); -} else - return CompositeTy.withCVRQualifiers(MergedCVRQual); +} +return CompositeTy.withCVRQualifiers(MergedCVRQual); }(); if (IsBlockPointer) ResultTy = S.Context.getBlockPointerType(ResultTy); - else { + else ResultTy = S.Context.getPointerType(ResultTy); - } LHS = S.ImpCastExprToType(LHS.get(), ResultTy, LHSCastKind); RHS = S.ImpCastExprToType(RHS.get(), ResultTy, RHSCastKind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301602 - [ARCMigrate] When applying changes from remap files, disable the 'adjustRemovals' functionality of EditedSource
Author: akirtzidis Date: Thu Apr 27 19:25:06 2017 New Revision: 301602 URL: http://llvm.org/viewvc/llvm-project?rev=301602&view=rev Log: [ARCMigrate] When applying changes from remap files, disable the 'adjustRemovals' functionality of EditedSource 'adjustRemovals' is used to avoid situation when removing a range inadvertently causes 2 separate identifiers to get joined into one. But it is not useful when the edits are character precise, as is the case with the remap files. Added: cfe/trunk/test/ARCMT/remap-applying.c cfe/trunk/test/ARCMT/remap-applying.c.result Modified: cfe/trunk/include/clang/Edit/EditedSource.h cfe/trunk/lib/ARCMigrate/ObjCMT.cpp cfe/trunk/lib/Edit/EditedSource.cpp Modified: cfe/trunk/include/clang/Edit/EditedSource.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Edit/EditedSource.h?rev=301602&r1=301601&r2=301602&view=diff == --- cfe/trunk/include/clang/Edit/EditedSource.h (original) +++ cfe/trunk/include/clang/Edit/EditedSource.h Thu Apr 27 19:25:06 2017 @@ -65,7 +65,7 @@ public: bool commit(const Commit &commit); - void applyRewrites(EditsReceiver &receiver); + void applyRewrites(EditsReceiver &receiver, bool adjustRemovals = true); void clearRewrites(); StringRef copyString(StringRef str) { return str.copy(StrAlloc); } Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=301602&r1=301601&r2=301602&view=diff == --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original) +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Apr 27 19:25:06 2017 @@ -2189,7 +2189,7 @@ static std::string applyEditsToTemp(cons Rewriter rewriter(SM, LangOpts); RewritesReceiver Rec(rewriter); - Editor.applyRewrites(Rec); + Editor.applyRewrites(Rec, /*adjustRemovals=*/false); const RewriteBuffer *Buf = rewriter.getRewriteBufferFor(FID); SmallString<512> NewText; Modified: cfe/trunk/lib/Edit/EditedSource.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Edit/EditedSource.cpp?rev=301602&r1=301601&r2=301602&view=diff == --- cfe/trunk/lib/Edit/EditedSource.cpp (original) +++ cfe/trunk/lib/Edit/EditedSource.cpp Thu Apr 27 19:25:06 2017 @@ -363,13 +363,14 @@ static void adjustRemoval(const SourceMa static void applyRewrite(EditsReceiver &receiver, StringRef text, FileOffset offs, unsigned len, - const SourceManager &SM, const LangOptions &LangOpts) { + const SourceManager &SM, const LangOptions &LangOpts, + bool shouldAdjustRemovals) { assert(offs.getFID().isValid()); SourceLocation Loc = SM.getLocForStartOfFile(offs.getFID()); Loc = Loc.getLocWithOffset(offs.getOffset()); assert(Loc.isFileID()); - if (text.empty()) + if (text.empty() && shouldAdjustRemovals) adjustRemoval(SM, LangOpts, Loc, offs, len, text); CharSourceRange range = CharSourceRange::getCharRange(Loc, @@ -387,7 +388,8 @@ static void applyRewrite(EditsReceiver & receiver.insert(Loc, text); } -void EditedSource::applyRewrites(EditsReceiver &receiver) { +void EditedSource::applyRewrites(EditsReceiver &receiver, + bool shouldAdjustRemovals) { SmallString<128> StrVec; FileOffset CurOffs, CurEnd; unsigned CurLen; @@ -414,14 +416,16 @@ void EditedSource::applyRewrites(EditsRe continue; } -applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts); +applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts, + shouldAdjustRemovals); CurOffs = offs; StrVec = act.Text; CurLen = act.RemoveLen; CurEnd = CurOffs.getWithOffset(CurLen); } - applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts); + applyRewrite(receiver, StrVec, CurOffs, CurLen, SourceMgr, LangOpts, + shouldAdjustRemovals); } void EditedSource::clearRewrites() { Added: cfe/trunk/test/ARCMT/remap-applying.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/remap-applying.c?rev=301602&view=auto == --- cfe/trunk/test/ARCMT/remap-applying.c (added) +++ cfe/trunk/test/ARCMT/remap-applying.c Thu Apr 27 19:25:06 2017 @@ -0,0 +1,4 @@ +a bc + +// RUN: echo "[{\"file\": \"%s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap +// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result Added: cfe/trunk/test/ARCMT/remap-applying.c.result URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/remap-applying.c.result?rev=301602&view=auto == --- cfe/trunk/test/ARCM
Re: r301597 - [Modules] Improve diagnostics for incomplete umbrella
This is breaking a non related test in some windows bots. Takumi & other with windows access, can you help me figure why? For instance: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/3846 http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/4379 On Thu, Apr 27, 2017 at 3:29 PM, Bruno Cardoso Lopes via cfe-commits wrote: > Author: bruno > Date: Thu Apr 27 17:29:14 2017 > New Revision: 301597 > > URL: http://llvm.org/viewvc/llvm-project?rev=301597&view=rev > Log: > [Modules] Improve diagnostics for incomplete umbrella > > One of the -Wincomplete-umbrella warnings diagnoses when a header is present > in > the directory but it's not present in the umbrella header. Currently, this > warning only happens on top level modules; any submodule using an umbrella > header does not get this warning. Fix that by also considering the submodules. > > Differential Revision: https://reviews.llvm.org/D32576 > > rdar://problem/22623686 > > Added: > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/ > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/ > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/ > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/ > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/ > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h > > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h > cfe/trunk/test/Modules/incomplete-umbrella.m > Modified: > cfe/trunk/lib/Lex/PPLexerChange.cpp > > Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597&r1=301596&r2=301597&view=diff > == > --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) > +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017 > @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd >return EndPos; > } > > +static void collectAllSubModulesWithUmbrellaHeader( > +const Module &Mod, SmallVectorImpl &SubMods) { > + if (Mod.getUmbrellaHeader()) > +SubMods.push_back(&Mod); > + for (auto *M : Mod.submodules()) > +collectAllSubModulesWithUmbrellaHeader(*M, SubMods); > +} > + > void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { >assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); >SourceLocation StartLoc = > @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token >} > >// If we are building a module that has an umbrella header, make sure that > - // each of the headers within the directory covered by the umbrella header > - // was actually included by the umbrella header. > - if (Module *Mod = getCurrentModule()) > -diagnoseMissingHeaderInUmbrellaDir(*Mod); > + // each of the headers within the directory, including all submodules, is > + // covered by the umbrella header was actually included by the umbrella > + // header. > + if (Module *Mod = getCurrentModule()) { > +llvm::SmallVector AllMods; > +collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods); > +for (auto *M : AllMods) > + diagnoseMissingHeaderInUmbrellaDir(*M); > + } > >return true; > } > > Added: > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597&view=auto > == > --- > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h > (added) > +++ > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h > Thu Apr 27 17:29:14 2017 > @@ -0,0 +1 @@ > +#define BAR_PUBLIC 1 > > Added: > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h?rev=301597&view=auto > == > --- > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h > (added) > +++ > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h > Thu Apr 27 17:29:14 2017 > @@ -0,0 +1 @@ > +// FooPublic.h > > Added: > cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framewo
r301610 - Move functionality for handling module maps as inputs from the -emit-module
Author: rsmith Date: Thu Apr 27 20:49:42 2017 New Revision: 301610 URL: http://llvm.org/viewvc/llvm-project?rev=301610&view=rev Log: Move functionality for handling module maps as inputs from the -emit-module action to the general FrontendAction infrastructure. This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map compilation. (The -E form is not currently especially useful yet as there's no good way to take the output and use it to actually build a module.) In order to support this, -cc1 now accepts -x -module-map in all cases where it accepts -x for a language we can parse (not ir/ast). And for uniformity, we also accept -x -header for all such languages (we used to reject for cuda and renderscript), and -x -cpp-output for all such languages (we used to reject for c, cl, and renderscript). (None of these new alternatives are accepted by the driver yet, so no user-visible changes.) Added: cfe/trunk/test/Modules/preprocess-module.cpp Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h cfe/trunk/include/clang/Frontend/FrontendOptions.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/lib/Frontend/FrontendOptions.cpp Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=301610&r1=301609&r2=301610&view=diff == --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Apr 27 20:49:42 2017 @@ -99,8 +99,6 @@ class GenerateModuleAction : public ASTF CreateOutputFile(CompilerInstance &CI, StringRef InFile) = 0; protected: - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; - std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef InFile) override; @@ -112,20 +110,11 @@ protected: }; class GenerateModuleFromModuleMapAction : public GenerateModuleAction { - clang::Module *Module = nullptr; - const FileEntry *ModuleMapForUniquing = nullptr; - bool IsSystem = false; - private: bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override; std::unique_ptr CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; - -public: - GenerateModuleFromModuleMapAction() {} - GenerateModuleFromModuleMapAction(const FileEntry *ModuleMap, bool IsSystem) - : ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) {} }; class GenerateModuleInterfaceAction : public GenerateModuleAction { Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=301610&r1=301609&r2=301610&view=diff == --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original) +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Apr 27 20:49:42 2017 @@ -23,6 +23,7 @@ class MemoryBuffer; } namespace clang { +class FileEntry; namespace frontend { enum ActionKind { @@ -100,9 +101,8 @@ public: Precompiled }; - constexpr InputKind(Language L = Unknown, bool PP = false) - : Lang(L), Fmt(Source), Preprocessed(PP) {} - constexpr InputKind(Language L, Format F, bool PP = false) + constexpr InputKind(Language L = Unknown, Format F = Source, + bool PP = false) : Lang(L), Fmt(F), Preprocessed(PP) {} Language getLanguage() const { return static_cast(Lang); } @@ -118,6 +118,9 @@ public: InputKind getPreprocessed() const { return InputKind(getLanguage(), getFormat(), true); } + InputKind withFormat(Format F) const { +return InputKind(getLanguage(), F, isPreprocessed()); + } }; /// \brief An input file for the front end. @@ -256,6 +259,10 @@ public: /// The input files and their types. std::vector Inputs; + /// When the input is a module map, the original module map file from which + /// that map was inferred, if any (for umbrella modules). + std::string OriginalModuleMap; + /// The output file, if any. std::string OutputFile; Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=301610&r1=301609&r2=301610&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Apr 27 20:49:42 2017 @@ -1080,6 +1080,8 @@ static bool compileModuleImpl(CompilerIn FrontendOpts.DisableFree = false; FrontendOpts.GenerateGlobalModuleIndex = false; FrontendOpts.BuildingImplicitModule = tr
[PATCH] D30427: Fix whitespace before token-paste of an argument.
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM Comment at: test/Preprocessor/macro_paste_commaext.c:4 +// In the following tests, note that the output is sensitive to the +// whitespace *preceeding* the varargs argument, as well as to +// interior whitespace. AFAIK, this is the only case where whitespace Typo (too many 'e's in "preceding"). https://reviews.llvm.org/D30427 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r301597 - [Modules] Improve diagnostics for incomplete umbrella
Hi Bruno, I don’t know if you are still trying to figure out the problem here, but if you are, I believe the problem is that the forward slashes need to changed to search for either a forward slash or a backward slash since Windows will change them to a backslash. Locally I can get the test to pass on my Windows machine if I change line 31 to the following: // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other Douglas Yung From: Bruno Cardoso Lopes via cfe-commits mailto:cfe-commits@lists.llvm.org>> Date: April 27, 2017 at 17:48:32 PDT To: cfe-commits mailto:cfe-commits@lists.llvm.org>> Subject: Re: r301597 - [Modules] Improve diagnostics for incomplete umbrella Reply-To: Bruno Cardoso Lopes mailto:bruno.card...@gmail.com>> This is breaking a non related test in some windows bots. Takumi & other with windows access, can you help me figure why? For instance: http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/3846 http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/4379 On Thu, Apr 27, 2017 at 3:29 PM, Bruno Cardoso Lopes via cfe-commits mailto:cfe-commits@lists.llvm.org>> wrote: Author: bruno Date: Thu Apr 27 17:29:14 2017 New Revision: 301597 URL: http://llvm.org/viewvc/llvm-project?rev=301597&view=rev Log: [Modules] Improve diagnostics for incomplete umbrella One of the -Wincomplete-umbrella warnings diagnoses when a header is present in the directory but it's not present in the umbrella header. Currently, this warning only happens on top level modules; any submodule using an umbrella header does not get this warning. Fix that by also considering the submodules. Differential Revision: https://reviews.llvm.org/D32576 rdar://problem/22623686 Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/ cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h cfe/trunk/test/Modules/incomplete-umbrella.m Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597&r1=301596&r2=301597&view=diff == --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original) +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017 @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd return EndPos; } +static void collectAllSubModulesWithUmbrellaHeader( +const Module &Mod, SmallVectorImpl &SubMods) { + if (Mod.getUmbrellaHeader()) +SubMods.push_back(&Mod); + for (auto *M : Mod.submodules()) +collectAllSubModulesWithUmbrellaHeader(*M, SubMods); +} + void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); SourceLocation StartLoc = @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token } // If we are building a module that has an umbrella header, make sure that - // each of the headers within the directory covered by the umbrella header - // was actually included by the umbrella header. - if (Module *Mod = getCurrentModule()) -diagnoseMissingHeaderInUmbrellaDir(*Mod); + // each of the headers within the directory, including all submodules, is + // covered by the umbrella header was actually included by the umbrella + // header. + if (Module *Mod = getCurrentModule()) { +llvm::SmallVector AllMods; +collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods); +for (auto *M : AllMods) + diagnoseMissingHeaderInUmbrellaDir(*M); + } return true; } Added: cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597&view=auto == --- cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Fo
r301613 - clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597.
Author: chapuni Date: Thu Apr 27 23:17:31 2017 New Revision: 301613 URL: http://llvm.org/viewvc/llvm-project?rev=301613&view=rev Log: clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597. Modified: cfe/trunk/test/Index/index-module.m Modified: cfe/trunk/test/Index/index-module.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=301613&r1=301612&r2=301613&view=diff == --- cfe/trunk/test/Index/index-module.m (original) +++ cfe/trunk/test/Index/index-module.m Thu Apr 27 23:17:31 2017 @@ -28,7 +28,7 @@ int glob; // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_OTHER_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]other\.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_NOT_CXX_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]not_cxx\.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.NotCXX // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.SubFramework -// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other +// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.Private.DependsOnModule // CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: "Module" | isImplicit: 1 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r301610 - Move functionality for handling module maps as inputs from the -emit-module
On Thu, Apr 27, 2017 at 6:49 PM, Richard Smith via cfe-commits wrote: > Author: rsmith > Date: Thu Apr 27 20:49:42 2017 > New Revision: 301610 > > URL: http://llvm.org/viewvc/llvm-project?rev=301610&view=rev > Log: > Move functionality for handling module maps as inputs from the -emit-module > action to the general FrontendAction infrastructure. > > This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map > compilation. (The -E form is not currently especially useful yet as there's no > good way to take the output and use it to actually build a module.) Yay! This is awesome Richard!! > In order to support this, -cc1 now accepts -x -module-map in all cases > where it accepts -x for a language we can parse (not ir/ast). And for > uniformity, we also accept -x -header for all such languages (we used > to reject for cuda and renderscript), and -x -cpp-output for all such > languages (we used to reject for c, cl, and renderscript). > > (None of these new alternatives are accepted by the driver yet, so no > user-visible changes.) > > Added: > cfe/trunk/test/Modules/preprocess-module.cpp > Modified: > cfe/trunk/include/clang/Frontend/FrontendActions.h > cfe/trunk/include/clang/Frontend/FrontendOptions.h > cfe/trunk/lib/Frontend/CompilerInstance.cpp > cfe/trunk/lib/Frontend/CompilerInvocation.cpp > cfe/trunk/lib/Frontend/FrontendAction.cpp > cfe/trunk/lib/Frontend/FrontendActions.cpp > cfe/trunk/lib/Frontend/FrontendOptions.cpp > > Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=301610&r1=301609&r2=301610&view=diff > == > --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original) > +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Apr 27 20:49:42 > 2017 > @@ -99,8 +99,6 @@ class GenerateModuleAction : public ASTF >CreateOutputFile(CompilerInstance &CI, StringRef InFile) = 0; > > protected: > - bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) > override; > - >std::unique_ptr CreateASTConsumer(CompilerInstance &CI, > StringRef InFile) override; > > @@ -112,20 +110,11 @@ protected: > }; > > class GenerateModuleFromModuleMapAction : public GenerateModuleAction { > - clang::Module *Module = nullptr; > - const FileEntry *ModuleMapForUniquing = nullptr; > - bool IsSystem = false; > - > private: >bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) > override; > >std::unique_ptr >CreateOutputFile(CompilerInstance &CI, StringRef InFile) override; > - > -public: > - GenerateModuleFromModuleMapAction() {} > - GenerateModuleFromModuleMapAction(const FileEntry *ModuleMap, bool > IsSystem) > - : ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) {} > }; > > class GenerateModuleInterfaceAction : public GenerateModuleAction { > > Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=301610&r1=301609&r2=301610&view=diff > == > --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original) > +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Apr 27 20:49:42 > 2017 > @@ -23,6 +23,7 @@ class MemoryBuffer; > } > > namespace clang { > +class FileEntry; > > namespace frontend { >enum ActionKind { > @@ -100,9 +101,8 @@ public: > Precompiled >}; > > - constexpr InputKind(Language L = Unknown, bool PP = false) > - : Lang(L), Fmt(Source), Preprocessed(PP) {} > - constexpr InputKind(Language L, Format F, bool PP = false) > + constexpr InputKind(Language L = Unknown, Format F = Source, > + bool PP = false) >: Lang(L), Fmt(F), Preprocessed(PP) {} > >Language getLanguage() const { return static_cast(Lang); } > @@ -118,6 +118,9 @@ public: >InputKind getPreprocessed() const { > return InputKind(getLanguage(), getFormat(), true); >} > + InputKind withFormat(Format F) const { > +return InputKind(getLanguage(), F, isPreprocessed()); > + } > }; > > /// \brief An input file for the front end. > @@ -256,6 +259,10 @@ public: >/// The input files and their types. >std::vector Inputs; > > + /// When the input is a module map, the original module map file from which > + /// that map was inferred, if any (for umbrella modules). > + std::string OriginalModuleMap; > + >/// The output file, if any. >std::string OutputFile; > > > Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=301610&r1=301609&r2=301610&view=diff > ==
Re: r301613 - clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597.
Thanks!! On Thu, Apr 27, 2017 at 9:17 PM, NAKAMURA Takumi via cfe-commits wrote: > Author: chapuni > Date: Thu Apr 27 23:17:31 2017 > New Revision: 301613 > > URL: http://llvm.org/viewvc/llvm-project?rev=301613&view=rev > Log: > clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path > separator \\, since r301597. > > Modified: > cfe/trunk/test/Index/index-module.m > > Modified: cfe/trunk/test/Index/index-module.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=301613&r1=301612&r2=301613&view=diff > == > --- cfe/trunk/test/Index/index-module.m (original) > +++ cfe/trunk/test/Index/index-module.m Thu Apr 27 23:17:31 2017 > @@ -28,7 +28,7 @@ int glob; > // CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_OTHER_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]other\.h]] > | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule > // CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_NOT_CXX_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]not_cxx\.h]] > | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.NotCXX > // CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] > | {{.*}} | hash loc: | {{.*}} | module: > DependsOnModule.SubFramework > -// CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]] > | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 > | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other > +// CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]Other\.h]] > | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 > | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other > // CHECK-DMOD-NEXT: [ppIncludedFile]: > [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]] > | {{.*}} | hash loc: | {{.*}} | module: > DependsOnModule.Private.DependsOnModule > // CHECK-DMOD-NEXT: [importedASTFile]: > {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: > "Module" | isImplicit: 1 > // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: > depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5 > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits -- Bruno Cardoso Lopes http://www.brunocardoso.cc ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function
xiangzhai updated this revision to Diff 97042. xiangzhai added a comment. Hi Artem, Please review my updated patch, thanks a lot! Regards, Leslie Zhai Repository: rL LLVM https://reviews.llvm.org/D31868 Files: lib/StaticAnalyzer/Checkers/CStringChecker.cpp test/Analysis/null-deref-ps-region.c Index: test/Analysis/null-deref-ps-region.c === --- test/Analysis/null-deref-ps-region.c +++ test/Analysis/null-deref-ps-region.c @@ -1,6 +1,11 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-store=region -verify %s -// expected-no-diagnostics +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,unix,alpha.unix -std=gnu99 -analyzer-store=region -verify %s +#include "Inputs/system-header-simulator.h" + +typedef __typeof(sizeof(int)) size_t; +void *memset(void *__s, int __c, size_t __n); +void *malloc(size_t __size); +void free(void *__ptr); // The store for 'a[1]' should not be removed mistakenly. SymbolicRegions may // also be live roots. @@ -13,3 +18,55 @@ i = *p; // no-warning } } + +void foo() { + int *x = malloc(sizeof(int)); + memset(x, 0, sizeof(int)); + int n = 1 / *x; + free(x); +} + +void bar() { + int *x = malloc(sizeof(int)); + memset(x, 0, 1); + int n = 1 / *x; // no-warning + free(x); +} + +void f531() { + int *x = 0; + memset(x, 0, 1); // expected-warning {{Null pointer argument in call to memory set function}} +} + +void f61() { + char buf[13]; + memset(buf, 0, 1); // no-warning +} + +void f611() { + char *buf = (char *)malloc(13); + memset(buf, 0, 1); // no-warning + free(buf); +} + +void f66() { + char buf[1]; + memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}} +} + +void f666() { + char *buf = (char *)malloc(1); + memset(buf, 0, 1024); // expected-warning {{Memory set function accesses out-of-bound array element}} + free(buf); +} + +void f77() { + char buf[1]; + memset(buf, 0, sizeof(buf)); // no-warning +} + +void f777() { + char *buf = (char *)malloc(1); + memset(buf, 0, 1); // no-warning + free(buf); +} Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp === --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -120,6 +120,7 @@ void evalStdCopy(CheckerContext &C, const CallExpr *CE) const; void evalStdCopyBackward(CheckerContext &C, const CallExpr *CE) const; void evalStdCopyCommon(CheckerContext &C, const CallExpr *CE) const; + void evalMemset(CheckerContext &C, const CallExpr *CE) const; // Utility methods std::pair @@ -1999,6 +2000,55 @@ C.addTransition(State); } +void CStringChecker::evalMemset(CheckerContext &C, const CallExpr *CE) const { + if (CE->getNumArgs() != 3) +return; + + CurrentFunctionDescription = "memory set function"; + + const Expr *Mem = CE->getArg(0); + const Expr *Const = CE->getArg(1); + const Expr *Size = CE->getArg(2); + ProgramStateRef State = C.getState(); + + // See if the size argument is zero. + const LocationContext *LCtx = C.getLocationContext(); + SVal SizeVal = State->getSVal(Size, LCtx); + QualType SizeTy = Size->getType(); + + ProgramStateRef StateZeroSize, StateNonZeroSize; + std::tie(StateZeroSize, StateNonZeroSize) = +assumeZero(C, State, SizeVal, SizeTy); + + // Get the value of the memory area. + SVal MemVal = State->getSVal(Mem, LCtx); + + // If the size is zero, there won't be any actual memory access, so + // just bind the return value to the Mem buffer and return. + if (StateZeroSize && !StateNonZeroSize) { +StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, MemVal); +C.addTransition(StateZeroSize); +return; + } + + // Ensure the memory area is not null. + // If it is NULL there will be a NULL pointer dereference. + State = checkNonNull(C, StateNonZeroSize, Mem, MemVal); + if (!State) +return; + + State = CheckBufferAccess(C, State, Size, Mem); + if (!State) +return; + State = InvalidateBuffer(C, State, Mem, C.getSVal(Mem), + /*IsSourceBuffer*/false, Size); + if (!State) +return; + + State = State->BindExpr(CE, LCtx, MemVal); + C.addTransition(State); +} + static bool isCPPStdLibraryFunction(const FunctionDecl *FD, StringRef Name) { IdentifierInfo *II = FD->getIdentifier(); if (!II) @@ -2032,6 +2082,8 @@ evalFunction = &CStringChecker::evalMemcmp; else if (C.isCLibraryFunction(FDecl, "memmove")) evalFunction = &CStringChecker::evalMemmove; + else if (C.isCLibraryFunction(FDecl, "memset")) +evalFunction = &CStringChecker::evalMemset; else if (C.isCLibraryFunction(FDecl, "strcpy")) evalFunction = &CStringChecker::evalStrcpy; else if (C.isCLibraryFunction(FDecl, "strncpy")) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://li
r301619 - clang/test/ARCMT/remap-applying.c: Use %/s on the command line of echo(1).
Author: chapuni Date: Fri Apr 28 00:02:52 2017 New Revision: 301619 URL: http://llvm.org/viewvc/llvm-project?rev=301619&view=rev Log: clang/test/ARCMT/remap-applying.c: Use %/s on the command line of echo(1). Modified: cfe/trunk/test/ARCMT/remap-applying.c cfe/trunk/test/ARCMT/remap-applying.c.result Modified: cfe/trunk/test/ARCMT/remap-applying.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/remap-applying.c?rev=301619&r1=301618&r2=301619&view=diff == --- cfe/trunk/test/ARCMT/remap-applying.c (original) +++ cfe/trunk/test/ARCMT/remap-applying.c Fri Apr 28 00:02:52 2017 @@ -1,4 +1,4 @@ a bc -// RUN: echo "[{\"file\": \"%s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap +// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result Modified: cfe/trunk/test/ARCMT/remap-applying.c.result URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/remap-applying.c.result?rev=301619&r1=301618&r2=301619&view=diff == --- cfe/trunk/test/ARCMT/remap-applying.c.result (original) +++ cfe/trunk/test/ARCMT/remap-applying.c.result Fri Apr 28 00:02:52 2017 @@ -1,4 +1,4 @@ ac -// RUN: echo "[{\"file\": \"%s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap +// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap // RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler
xiangzhai updated this revision to Diff 97047. xiangzhai added a subscriber: cfe-commits. xiangzhai added a comment. Hi Artem, Please review my updated patch, I use SourceManager's getFilename and add some testcases, thanks a lot! Regards, Leslie Zhai Repository: rL LLVM https://reviews.llvm.org/D31320 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp test/Analysis/copypaste/k3blib_automoc.cpp test/Analysis/copypaste/moc_k3bactivepipe.cpp Index: test/Analysis/copypaste/k3blib_automoc.cpp === --- test/Analysis/copypaste/k3blib_automoc.cpp +++ test/Analysis/copypaste/k3blib_automoc.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s + +// expected-no-diagnostics + +/* This file is autogenerated, do not edit*/ + +// clang -E RealMetaObjectCompiler_automoc.cpp > ~/PreprocessedMOC_automoc.cpp + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { +delete [] p1; +p1 = nullptr; + } + // Copy-paste above block but careless forget to change something + if (p2) { +delete [] p1; // no-warning +p2 = nullptr; + } +} Index: test/Analysis/copypaste/moc_k3bactivepipe.cpp === --- test/Analysis/copypaste/moc_k3bactivepipe.cpp +++ test/Analysis/copypaste/moc_k3bactivepipe.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s + +// expected-no-diagnostics + +/ +** Meta object code from reading C++ file 'k3bactivepipe.h' +** +** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) +** +** WARNING! All changes made in this file will be lost! +*/ + +// clang -E moc_RealMetaObjectCompiler.cpp > ~/moc_PreprocessedMOC.cpp + +void f1() { + int *p1 = new int[1]; + int *p2 = new int[1]; + if (p1) { +delete [] p1; +p1 = nullptr; + } + // Copy-paste above block but careless forget to change something + if (p2) { +delete [] p1; // no-warning +p2 = nullptr; + } +} Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp === --- lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -78,7 +78,8 @@ // because reportSuspiciousClones() wants to search them for errors. std::vector AllCloneGroups; - Detector.findClones(AllCloneGroups, RecursiveCloneTypeIIConstraint(), + Detector.findClones(AllCloneGroups, AutoGeneratedCloneConstraint(), + RecursiveCloneTypeIIConstraint(), MinComplexityConstraint(MinComplexity), MinGroupSizeConstraint(2), OnlyLargestCloneConstraint()); Index: lib/Analysis/CloneDetection.cpp === --- lib/Analysis/CloneDetection.cpp +++ lib/Analysis/CloneDetection.cpp @@ -366,6 +366,24 @@ } } +bool AutoGeneratedCloneConstraint::isAutoGenerated(const CloneDetector::CloneGroup &Group) { + if (Group.empty()) +return false; + + for (const StmtSequence &S : Group) { +const Decl *D = S.getContainingDecl(); +const SourceManager &SM = D->getASTContext().getSourceManager(); +StringRef Filename = SM.getFilename(D->getLocation()); +if (Filename.find(StringRef("moc_")) != StringRef::npos || +Filename.find(StringRef("_automoc.")) != StringRef::npos || +Filename.find(StringRef(".moc")) != StringRef::npos) { + return true; +} + } + + return false; +} + static size_t createHash(llvm::MD5 &Hash) { size_t HashCode; Index: include/clang/Analysis/CloneDetection.h === --- include/clang/Analysis/CloneDetection.h +++ include/clang/Analysis/CloneDetection.h @@ -319,6 +319,17 @@ void constrain(std::vector &Result); }; +struct AutoGeneratedCloneConstraint { + bool isAutoGenerated(const CloneDetector::CloneGroup &Group); + + void constrain(std::vector &CloneGroups) { +CloneConstraint::filterGroups( +CloneGroups, [this](const CloneDetector::CloneGroup &Group) { + return isAutoGenerated(Group); +}); + } +}; + /// Analyzes the pattern of the referenced variables in a statement. class VariablePattern { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31320: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler
NoQ added a comment. Thanks! Because LLVM's Illinois license is rather permissive than copyleft, we try to avoid stuff copied from GPL/LGPL software (such as Qt or K3B) in our codebase. The code doesn't seem to have been copy-pasted from a copyleft project, but I guess it's better to rename the file to avoid referencing to K3B, and i added inline comments regarding `moc` intro comments. Comment at: lib/Analysis/CloneDetection.cpp:377 +StringRef Filename = SM.getFilename(D->getLocation()); +if (Filename.find(StringRef("moc_")) != StringRef::npos || +Filename.find(StringRef("_automoc.")) != StringRef::npos || Maybe `.startswith("moc_")` would be more accurate? In fact, you could also try to use a single LLVM regex here. Comment at: test/Analysis/copypaste/k3blib_automoc.cpp:5-7 +/* This file is autogenerated, do not edit*/ + +// clang -E RealMetaObjectCompiler_automoc.cpp > ~/PreprocessedMOC_automoc.cpp Other LLVM contributors are free to edit this file, and i doubt it was autogenerated; i believe these comments should be removed. That said, there should be a comment explaining why the file has no warning. Eg.: ``` // Because files that have `_automoc' in their names are most likely autogenerated, // we suppress copy-paste warnings here. // expected-no-diagnostics ``` (same in the other file) Comment at: test/Analysis/copypaste/k3blib_automoc.cpp:16 + } + // Copy-paste above block but careless forget to change something + if (p2) { My idea regarding the comment above would make this comment unnecessary. (same in the other file) Comment at: test/Analysis/copypaste/moc_k3bactivepipe.cpp:5-13 +/ +** Meta object code from reading C++ file 'k3bactivepipe.h' +** +** Created by: The Qt Meta Object Compiler version 67 (Qt 5.8.0) +** +** WARNING! All changes made in this file will be lost! +*/ This file wasn't in fact created by `moc`, does not seem to be anyhow related to `k3b`; i believe these comments should be removed. Repository: rL LLVM https://reviews.llvm.org/D31320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits